Skip to content

Commit

Permalink
Improve opening OME-Zarr files as a grid view
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Jun 7, 2024
1 parent 624a77f commit eedee2a
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/embl/mobie/MoBIE.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class MoBIE
new Thread(() -> {
long start = System.currentTimeMillis();
AmazonS3ClientBuilder.standard();
IJ.log( "Initialised AmazonS3ClientBuilder in " + ( System.currentTimeMillis() -start ) + " ms." );
IJ.log( "( Initialised AmazonS3ClientBuilder in " + ( System.currentTimeMillis() -start ) + " ms. )" );
}).start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public class OpenImageAndLabelsFilesCommand implements Command {

static { net.imagej.patcher.LegacyInjector.preinit(); }

@Parameter( label = "Image Path", required = false )
// FIXME: https://forum.image.sc/t/scijava-ui-open-both-file-and-directory/97389
@Parameter( label = "Image Path", style = "both", required = false )
public File image;

@Parameter( label = "Label Mask Path", required = false )
@Parameter( label = "Label Mask Path", style = "both", required = false )
public File labels;

@Parameter( label = "Label Mask Table Path", required = false )
Expand All @@ -58,13 +59,14 @@ public class OpenImageAndLabelsFilesCommand implements Command {
@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = "If the images are different and not too many, use Transformed; otherwise use Stitched for better performance.")
public GridType gridType = GridType.Transformed;

@Override
public void run()
{
final MoBIESettings settings = new MoBIESettings();

final GridType gridType = GridType.Stitched; // TODO: fetch from UI

final ArrayList< String > imageList = new ArrayList<>();
if ( image != null ) imageList.add( image.getAbsolutePath() );

Expand All @@ -85,7 +87,7 @@ public void run()
}
catch ( IOException e )
{
e.printStackTrace();
throw new RuntimeException( e );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ public class OpenImageAndLabelsURIsCommand implements Command {
@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = "If the images are different and not too many, use Transformed; otherwise use Stitched for better performance.")
public GridType gridType = GridType.Transformed;

@Override
public void run()
{
final MoBIESettings settings = new MoBIESettings();

final GridType gridType = GridType.Stitched; // TODO: maybe fetch from UI

final ArrayList< String > imageList = new ArrayList<>();
if ( image != null ) imageList.add( image );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ public class OpenMultipleImagesAndLabelsFilesCommand implements Command {
@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = "If the images are different and not too many, use Transformed; otherwise use Stitched for better performance.")
public GridType gridType = GridType.Transformed;

@Override
public void run()
{
final MoBIESettings settings = new MoBIESettings();

final GridType gridType = GridType.Stitched; // TODO: fetch from UI

final ArrayList< String > imageList = new ArrayList<>();
if ( image0 != null ) imageList.add( image0.getAbsolutePath() );
if ( image1 != null ) imageList.add( image1.getAbsolutePath() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ public class OpenMultipleImagesAndLabelsURIsCommand implements Command {
@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = "If the images are different and not too many, use Transformed; otherwise use Stitched for better performance.")
public GridType gridType = GridType.Transformed;

@Override
public void run()
{
final MoBIESettings settings = new MoBIESettings();

final GridType gridType = GridType.Stitched; // TODO: fetch from UI

final ArrayList< String > imageList = new ArrayList<>();
if ( image0 != null ) imageList.add( image0 );
if ( image1 != null ) imageList.add( image1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ public class OpenTableCommand implements Command {
@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = "If the images are different and not too many, use \"Transformed\"; otherwise use \"Stitched\" for better performance.")
public GridType gridType = GridType.Transformed;

@Override
public void run()
{
run( GridType.Stitched );
run( gridType );
}

public void run( GridType gridType )
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public static BdvHandle createBdv( boolean is2D, String frameTitle )
final MobieSerializableBdvOptions sOptions = new MobieSerializableBdvOptions();
sOptions.is2D = is2D;
sOptions.frameTitle = frameTitle;
sOptions.interpolate = !is2D;
IBdvSupplier bdvSupplier = new MobieBdvSupplier( sOptions );
//SourceAndConverterServices.getBdvDisplayService().setDefaultBdvSupplier( bdvSupplier );
//BdvHandle bdvHandle = SourceAndConverterServices.getBdvDisplayService().getNewBdv();
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/embl/mobie/lib/files/ImageFileSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import bdv.viewer.Source;
import ij.IJ;
import loci.formats.in.CellSensReader;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.Volatile;
import net.imglib2.realtransform.AffineTransform3D;
import org.apache.commons.io.FilenameUtils;
import org.embl.mobie.MoBIE;
import org.embl.mobie.io.ImageDataOpener;
import org.embl.mobie.io.imagedata.ImageData;
import org.embl.mobie.io.util.IOHelper;
Expand Down Expand Up @@ -169,12 +171,17 @@ protected static boolean isCellProfilerColumn( String column, Table table )
private void setMetadata( Integer channelIndex )
{
metadataSource = nameToFullPath.keySet().iterator().next();
IJ.log( "Fetching metadata from " + nameToFullPath.get( metadataSource ) );
ImageData< ? > imageData = ImageDataOpener.open( nameToFullPath.get( metadataSource ) );
CanonicalDatasetMetadata canonicalDatasetMetadata = imageData.getMetadata( channelIndex );
metadata = new Metadata( canonicalDatasetMetadata );
Source< ? extends Volatile< ? > > source = imageData.getSourcePair( channelIndex ).getB();
Source< ? > source = imageData.getSourcePair( channelIndex ).getA();
metadata.numZSlices = (int) source.getSource( 0, 0 ).dimension( 2 );
metadata.numTimePoints = SourceHelper.getNumTimePoints( source );
metadata.contrastLimits = MoBIEHelper.computeMinMax( ( RandomAccessibleInterval ) source.getSource( 0, source.getNumMipmapLevels() -1 ) );
IJ.log( "Slices: " + metadata.numZSlices );
IJ.log( "Frames: " + metadata.numTimePoints );
IJ.log( "Min, max: " + Arrays.toString( metadata.contrastLimits ) );
}

private static String applyPathMapping( String pathMapping, String path )
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/embl/mobie/lib/source/SourceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static int getNumTimePoints( Source< ? > source )
if ( numSourceTimepoints == maxNumTimePoints )
{
System.err.println( source.getName() + " has more than " + maxNumTimePoints + " time-points. Is this an error?!" );
return 1;
}

return numSourceTimepoints;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/develop/OpenAutoMicTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
package develop;

import net.imagej.ImageJ;
import org.embl.mobie.command.open.OpenTableAdvancedCommand;
import org.embl.mobie.lib.transform.GridType;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,33 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package org.embl.mobie.command.open;
package projects;

import org.embl.mobie.command.CommandConstants;
import net.imagej.ImageJ;
import org.embl.mobie.MoBIE;
import org.embl.mobie.MoBIESettings;
import org.embl.mobie.command.open.OpenImageAndLabelsFilesCommand;
import org.embl.mobie.lib.transform.GridType;
import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Table (Advanced)..." )
public class OpenTableAdvancedCommand extends OpenTableCommand {
import java.io.File;
import java.io.IOException;

static { net.imagej.patcher.LegacyInjector.preinit(); }
public class OpenLocalYannickZarrs
{
public static void main( String[] args ) throws IOException
{
final ImageJ imageJ = new ImageJ();
imageJ.ui().showUI();

@Parameter( label = "Grid type" )
public GridType gridType = GridType.Transformed;
OpenImageAndLabelsFilesCommand command = new OpenImageAndLabelsFilesCommand();
command.gridType = GridType.Transformed;
command.image = new File("/Volumes/schwab/schwab/MoBIE-GRIDtestJUNE2024/JEOL1400_20240426/.*.ome.zarr");
//command.image = new File("/Volumes/schwab/schwab/MoBIE-GRIDtestJUNE2024/JEOL1400_20240426/Alex_ASH_BlockA1_Grid11_PS_ser1_cell4_8k_blend.ome.zarr");

@Override
public void run()
{
super.run( gridType );
// FIXME
// - why does the software complain that there are more than 1000 time-points?
// - add the relative paths to the table
// - add the full paths to the table
command.run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
package projects.muscle_patterning_drosophila;

import net.imagej.ImageJ;
import org.embl.mobie.command.open.OpenTableAdvancedCommand;
import org.embl.mobie.lib.transform.GridType;

import java.io.File;
Expand Down

0 comments on commit eedee2a

Please sign in to comment.