Skip to content

Commit

Permalink
Simplify UI for opening images and labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Jun 10, 2024
1 parent 6bed6f9 commit 980d654
Show file tree
Hide file tree
Showing 26 changed files with 120 additions and 267 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>org.embl.mobie</groupId>
<artifactId>mobie-viewer-fiji</artifactId>
<version>5.0.1-SNAPSHOT</version>
<version>5.0.1</version>

<!-- force javadoc generation to fetch errors: -->
<!-- mvn javadoc:javadoc | grep error -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

import bdv.util.BdvHandle;
import ij.IJ;
import ij.gui.Roi;
import ij.plugin.frame.RoiManager;
import org.embl.mobie.MoBIE;
import org.embl.mobie.command.CommandConstants;
import org.embl.mobie.lib.bdv.ScreenShotMaker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@
import java.io.IOException;
import java.util.ArrayList;

@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Image and Labels Files..." )
public class OpenImageAndLabelsFilesCommand implements Command {
@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Image and Labels..." )
public class OpenImageAndLabelsCommand implements Command {

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

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

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

@Parameter( label = "Label Mask Table Path", required = false )
@Parameter( label = "Label Mask Table URI", required = false )
public File table;

@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = MoBIEHelper.GRID_TYPE_HELP )
@Parameter( label = "Grid", description = MoBIEHelper.GRID_TYPE_HELP )
public GridType gridType = GridType.Transformed;

@Override
Expand All @@ -69,18 +69,18 @@ public void run()
final MoBIESettings settings = new MoBIESettings();

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

final ArrayList< String > labelsList = new ArrayList<>();
if ( labels != null ) labelsList.add( labels.getAbsolutePath() );
if ( labels != null ) labelsList.add( MoBIEHelper.toURI( labels ) );

final ArrayList< String > tablesList = new ArrayList<>();
if ( table != null )
{
tablesList.add( table.getAbsolutePath() );
tablesList.add( MoBIEHelper.toURI( table ) );
}

spatialCalibration.setVoxelDimensions( settings, table != null ? table.getAbsolutePath() : null );
spatialCalibration.setVoxelDimensions( settings, table != null ? MoBIEHelper.toURI( table ) : null );

try
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,43 @@
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Multiple Images and Label URIs..." )
public class OpenMultipleImagesAndLabelsURIsCommand implements Command {
@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Multiple Images and Labels..." )
public class OpenMultipleImagesAndLabelsCommand implements Command {

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

@Parameter( label = "Image URI", required = false )
public String image0;
public File image0;

@Parameter( label = "Image URI", required = false )
public String image1;
public File image1;

@Parameter( label = "Image URI", required = false )
public String image2;
public File image2;

@Parameter( label = "Image URI", required = false )
public String image3;
public File image3;

@Parameter( label = "Labels URI", required = false )
public String labels0;
public File labels0;

@Parameter( label = "Labels Table URI", required = false )
public String table0;
public File table0;

@Parameter( label = "Labels URI", required = false )
public String labels1;
public File labels1;

@Parameter( label = "Labels Table URI", required = false )
public String table1;
public File table1;

@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = MoBIEHelper.GRID_TYPE_HELP )
@Parameter( label = "Grid", description = MoBIEHelper.GRID_TYPE_HELP )
public GridType gridType = GridType.Transformed;

@Override
Expand All @@ -82,20 +83,20 @@ public void run()
final MoBIESettings settings = new MoBIESettings();

final ArrayList< String > imageList = new ArrayList<>();
if ( image0 != null ) imageList.add( image0 );
if ( image1 != null ) imageList.add( image1 );
if ( image2 != null ) imageList.add( image2 );
if ( image3 != null ) imageList.add( image3 );
if ( image0 != null ) imageList.add( MoBIEHelper.toURI( image0 ) );
if ( image1 != null ) imageList.add( MoBIEHelper.toURI( image1 ) );
if ( image2 != null ) imageList.add( MoBIEHelper.toURI( image2 ) );
if ( image3 != null ) imageList.add( MoBIEHelper.toURI( image3 ) );

final ArrayList< String > labelsList = new ArrayList<>();
if ( labels0 != null ) labelsList.add( labels0 );
if ( labels1 != null ) labelsList.add( labels1 );
if ( labels0 != null ) labelsList.add( MoBIEHelper.toURI( labels0 ) );
if ( labels1 != null ) labelsList.add( MoBIEHelper.toURI( labels1 ) );

final ArrayList< String > tablesList = new ArrayList<>();
if ( table0 != null ) tablesList.add( table0 );
if ( table1 != null ) tablesList.add( table1 );
if ( table0 != null ) tablesList.add( MoBIEHelper.toURI( table0 ) );
if ( table1 != null ) tablesList.add( MoBIEHelper.toURI( table1 ) );

spatialCalibration.setVoxelDimensions( settings, table0 != null ? table0 : null );
spatialCalibration.setVoxelDimensions( settings, table0 != null ? MoBIEHelper.toURI( table0 ) : null );

try
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class OpenTableCommand implements Command {
@Parameter( label = "Spatial Calibration" )
public SpatialCalibration spatialCalibration = SpatialCalibration.FromImage;

@Parameter( label = "Grid type", description = MoBIEHelper.GRID_TYPE_HELP )
@Parameter( label = "Grid", description = MoBIEHelper.GRID_TYPE_HELP )
public GridType gridType = GridType.Transformed;

@Override
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/org/embl/mobie/lib/MoBIEHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@

public abstract class MoBIEHelper
{
public static final String GRID_TYPE_HELP = "If the images are different and not too many, use Transformed; otherwise use Stitched for better performance.";
public static final String GRID_TYPE_HELP = "If the images are different and not too many, use Transformed for more flexible visualisation.\n" +
"If all images are identical use Stitched for better performance.";

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

Expand Down Expand Up @@ -332,4 +333,17 @@ public static <T extends RealType<T> > double[] computeMinMax( RandomAccessibleI

return new double[]{ min.getRealDouble(), max.getRealDouble() };
}

public static String toURI( File file )
{
String string = file.toString();

if (string.startsWith("https:/") || string.startsWith("http:/")) {
string = string
.replaceFirst("https:/", "https://")
.replaceFirst("http:/", "http://");
}

return string;
}
}
Loading

0 comments on commit 980d654

Please sign in to comment.