Search in sources :

Example 1 with SwingProgressWriter

use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.

the class CustomizedSegmentationComponentDemo method onSaveResultsClicked.

private void onSaveResultsClicked(ActionEvent actionEvent) {
    SegmentationItem selectedSegmenter = segmentationModel.segmenterList().selectedSegmenter().get();
    if (selectedSegmenter == null || !selectedSegmenter.isTrained()) {
        JOptionPane.showMessageDialog(null, "Please select a segmentation algoritm and train it");
        return;
    }
    ImageLabelingModel imageLabeling = segmentationModel.imageLabelingModel();
    RandomAccessibleInterval<ShortType> segmentation = selectedSegmenter.results(imageLabeling).segmentation();
    ParallelUtils.runInOtherThread(() -> {
        ParallelUtils.populateCachedImg(segmentation, new SwingProgressWriter(null, "Calculate Entire Segmentation"));
        JOptionPane.showMessageDialog(null, "Calculation completed");
        BdvFunctions.show(segmentation, "Segmentation").setDisplayRange(0, 1);
    });
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) ShortType(net.imglib2.type.numeric.integer.ShortType) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter)

Example 2 with SwingProgressWriter

use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.

the class SwingProgressWriterDemo method main.

public static void main(String... args) throws InterruptedException {
    ProgressWriter progressWriter = new SwingProgressWriter(null, "Swing Progress Writer Demo");
    for (double progress = 0; progress < 1.0; progress += 0.01) {
        if (progress > 0.5)
            progressWriter.out().println("half done");
        progressWriter.setProgress(progress);
        Thread.sleep(50);
    }
    progressWriter.setProgress(1.0);
}
Also used : ProgressWriter(bdv.export.ProgressWriter) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter)

Example 3 with SwingProgressWriter

use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.

the class HDF5SaverDemo method main.

public static <T extends RealType<T>> void main(String... args) throws SpimDataException, IOException {
    String outputFilename = File.createTempFile("output-", ".xml").getAbsolutePath();
    RandomAccessibleInterval<T> image = (RandomAccessibleInterval<T>) VirtualStackAdapter.wrap(new ImagePlus("https://imagej.nih.gov/ij/images/t1-head.zip"));
    image = Views.interval(Views.extendPeriodic(image), new FinalInterval(1000, 1000, 1000));
    RandomAccessibleInterval<UnsignedShortType> result = treshold(image);
    HDF5Saver saver = new HDF5Saver(result, outputFilename);
    saver.setProgressWriter(new SwingProgressWriter(null, "Save Huge Image"));
    saver.writeAll();
}
Also used : RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) UnsignedShortType(net.imglib2.type.numeric.integer.UnsignedShortType) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter) FinalInterval(net.imglib2.FinalInterval) HDF5Saver(sc.fiji.labkit.ui.utils.HDF5Saver) ImagePlus(ij.ImagePlus)

Example 4 with SwingProgressWriter

use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.

the class ParallelUtilsDemo method main.

public static void main(String... args) {
    ProgressWriter progress = new SwingProgressWriter(null, "In progress");
    CellLoader<ShortType> loader = cell -> Thread.sleep(1000);
    Img<ShortType> img = new DiskCachedCellImgFactory<>(new ShortType()).create(new long[] { 40, 40, 40 }, loader);
    ParallelUtils.populateCachedImg(img, progress);
    System.out.println("done");
}
Also used : ProgressWriter(bdv.export.ProgressWriter) DiskCachedCellImgFactory(net.imglib2.cache.img.DiskCachedCellImgFactory) CellLoader(net.imglib2.cache.img.CellLoader) ParallelUtils(sc.fiji.labkit.ui.utils.ParallelUtils) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter) ShortType(net.imglib2.type.numeric.integer.ShortType) Img(net.imglib2.img.Img) ShortType(net.imglib2.type.numeric.integer.ShortType) ProgressWriter(bdv.export.ProgressWriter) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter)

Example 5 with SwingProgressWriter

use of sc.fiji.labkit.ui.utils.progress.SwingProgressWriter in project labkit-ui by juglab.

the class TrainClassifier method train.

private static void train(List<Pair<ImgPlus<?>, Labeling>> trainingData, SegmentationItem item) {
    SwingProgressWriter progressWriter = new SwingProgressWriter(null, "Training in Progress");
    progressWriter.setVisible(true);
    progressWriter.setProgressBarVisible(false);
    progressWriter.setDetailsVisible(false);
    try {
        item.train(trainingData);
    } catch (CancellationException e) {
        progressWriter.setVisible(false);
        JOptionPane.showMessageDialog(null, e.getMessage(), "Training Cancelled", JOptionPane.PLAIN_MESSAGE);
    } catch (Throwable e) {
        progressWriter.setVisible(false);
        JOptionPane.showMessageDialog(null, e.toString(), "Training Failed", JOptionPane.WARNING_MESSAGE);
        e.printStackTrace();
    } finally {
        progressWriter.setVisible(false);
    }
}
Also used : CancellationException(java.util.concurrent.CancellationException) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter)

Aggregations

SwingProgressWriter (sc.fiji.labkit.ui.utils.progress.SwingProgressWriter)7 ProgressWriter (bdv.export.ProgressWriter)3 ShortType (net.imglib2.type.numeric.integer.ShortType)2 HDF5Saver (sc.fiji.labkit.ui.utils.HDF5Saver)2 ImagePlus (ij.ImagePlus)1 ImgSaver (io.scif.img.ImgSaver)1 CancellationException (java.util.concurrent.CancellationException)1 FinalInterval (net.imglib2.FinalInterval)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 CellLoader (net.imglib2.cache.img.CellLoader)1 DiskCachedCellImgFactory (net.imglib2.cache.img.DiskCachedCellImgFactory)1 Img (net.imglib2.img.Img)1 UnsignedShortType (net.imglib2.type.numeric.integer.UnsignedShortType)1 ImageLabelingModel (sc.fiji.labkit.ui.models.ImageLabelingModel)1 SegmentationItem (sc.fiji.labkit.ui.models.SegmentationItem)1 ParallelUtils (sc.fiji.labkit.ui.utils.ParallelUtils)1