Search in sources :

Example 1 with DefaultDataset

use of net.imagej.DefaultDataset in project vcell by virtualcell.

the class SmallCR method openExample.

public static ExampleDatasets openExample(ImageJ ij, File exampleDataDir) throws Exception {
    final String[] exampleFiles = new String[] { "Experimental.zip", "Seg Geom_3d.zip", "PreBleach.zip", "Analysis ROI.zip" };
    // final String[] exampleFiles = new String[] {"testDiff_1_2.zip","Seg Geom_3d.zip","testPreBleach.zip","Analysis ROI.zip"};// for test
    // List<Display<?>> displays0 = ij.display().getDisplays();
    // for (Display<?> display : displays0) {
    // System.out.println("----------disp "+display.getName()+" "+display.getIdentifier());
    // }
    List<ImageDisplay> knownImageDisplays = ij.imageDisplay().getImageDisplays();
    // for (ImageDisplay imageDisplay : imageDisplays0) {
    // System.out.println("----------imgdisp "+imageDisplay.getName()+" "+imageDisplay.getIdentifier());
    // }
    // 2D
    ImgPlus<? extends RealType<?>> experimentalData = null;
    // 2D or 3D (if 3D will be z-project for analysis withg 2D experimental data)
    ImgPlus<UnsignedByteType> segmentedGeom = null;
    // 2D
    ImgPlus<? extends RealType<?>> preBleachImage = null;
    // 2D
    ImgPlus<UnsignedByteType> analysisROI = null;
    // Open example images if they are not already open
    for (int exampleFilesIndex = 0; exampleFilesIndex < exampleFiles.length; exampleFilesIndex++) {
        DefaultDataset exampleFileDataset = null;
        for (ImageDisplay imageDisplay : knownImageDisplays) {
            if (imageDisplay.getName().equals(exampleFiles[exampleFilesIndex])) {
                exampleFileDataset = (DefaultDataset) imageDisplay.getActiveView().getData();
                break;
            }
        }
        if (exampleFileDataset == null) {
            exampleFileDataset = (DefaultDataset) ij.io().open(new File(exampleDataDir, exampleFiles[exampleFilesIndex]).getAbsolutePath());
            // ij.ui().show(exampleFileDataset);
            showAndZoom(ij, exampleFiles[exampleFilesIndex], exampleFileDataset, 4);
        }
        // Print names of axes (x,y,z,time,channel,unknown,...)
        System.out.print(exampleFileDataset.getName() + ": ");
        for (int dimensionIndex = 0; dimensionIndex < exampleFileDataset.numDimensions(); dimensionIndex++) {
            System.out.print((exampleFileDataset.axis(dimensionIndex) != null ? exampleFileDataset.axis(dimensionIndex).type().toString() + " " : "null "));
        }
        System.out.println();
        // Assign variables (defaultDataset corresponds to open 'exampleFiles' element
        switch(exampleFilesIndex) {
            case 0:
                experimentalData = exampleFileDataset.getImgPlus();
                break;
            case 1:
                segmentedGeom = (ImgPlus<UnsignedByteType>) exampleFileDataset.getImgPlus();
                break;
            case 2:
                preBleachImage = exampleFileDataset.getImgPlus();
                break;
            case 3:
                analysisROI = (ImgPlus<UnsignedByteType>) exampleFileDataset.getImgPlus();
                break;
        }
    }
    return new ExampleDatasets(experimentalData, preBleachImage, segmentedGeom, analysisROI);
}
Also used : UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) DefaultDataset(net.imagej.DefaultDataset) File(java.io.File) ImageDisplay(net.imagej.display.ImageDisplay)

Aggregations

File (java.io.File)1 DefaultDataset (net.imagej.DefaultDataset)1 ImageDisplay (net.imagej.display.ImageDisplay)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1