Skip to content

Commit

Permalink
Improve collection table functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Jul 18, 2024
1 parent ebdc03e commit ba5ab6f
Show file tree
Hide file tree
Showing 107 changed files with 199 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hs_err_*.log

pom.xml.releaseBackup

src/test/java/projects
src/test/java/projects/


mobie-files
Expand Down
4 changes: 2 additions & 2 deletions 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.2.4-SNAPSHOT</version>
<version>5.3.0-SNAPSHOT</version>

<!-- mvn clean install -Dmaven.test.skip=true -Dscijava.app.directory=/Users/tischer/Desktop/Fiji/Fiji-MoBIE.app -->

Expand Down Expand Up @@ -84,7 +84,7 @@
<license.copyrightOwners>EMBL</license.copyrightOwners>
<enforcer.skip>true</enforcer.skip>

<mobie-io.version>3.0.2</mobie-io.version>
<mobie-io.version>3.0.3</mobie-io.version>
<imagej-utils.version>0.7.0</imagej-utils.version>

<bigdataviewer-playground.version>0.9.0</bigdataviewer-playground.version>
Expand Down
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 @@ -120,7 +120,7 @@ public MoBIE( String uri, MoBIESettings settings ) throws IOException
initImageJAndMoBIE();
initProject( IOHelper.getFileName( uri ) );

CollectionTableDataSetter dataSetter = new CollectionTableDataSetter( table );
CollectionTableDataSetter dataSetter = new CollectionTableDataSetter( table, settings.values.getDataRoot() );
dataSetter.addToDataset( dataset );
dataset.is2D( false ); // TODO: determine from data?!

Expand Down
19 changes: 12 additions & 7 deletions src/main/java/org/embl/mobie/MoBIESettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ public MoBIESettings setVoxelDimensions( VoxelDimensions voxelDimensions )
return this;
}

public MoBIESettings appendGroovyCode( String groovyCode )
{
this.values.groovyScript += groovyCode;
return this;
}

public MoBIESettings openedFromCLI( Boolean cli )
{
this.values.openedFromCLI = cli;
Expand All @@ -126,6 +120,12 @@ public MoBIESettings projectType( ProjectType projectType )
return this;
}

public MoBIESettings dataRoot( String dataRoot )
{
this.values.dataRoot = dataRoot;
return this;
}


public static class Values
{
Expand All @@ -141,7 +141,12 @@ public static class Values
private VoxelDimensions voxelDimensions = null;
private Boolean openedFromCLI = false; // started from CLI
private ProjectType projectType = ProjectType.MoBIEJSON;
private String groovyScript = "";
private String dataRoot = null;

public String getDataRoot()
{
return dataRoot;
}

public VoxelDimensions getVoxelDimensions()
{
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/embl/mobie/cmd/ProjectCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
package org.embl.mobie.cmd;

import net.imagej.ImageJ;
import org.embl.mobie.MoBIE;
import org.embl.mobie.MoBIESettings;
import picocli.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@
import org.embl.mobie.MoBIESettings;
import org.embl.mobie.ProjectType;
import org.embl.mobie.command.CommandConstants;
import org.embl.mobie.command.SpatialCalibration;
import org.embl.mobie.lib.MoBIEHelper;
import org.embl.mobie.lib.transform.GridType;
import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Collection Table..." )
public class OpenCollectionTableCommand implements Command {
Expand All @@ -55,16 +49,24 @@ public class OpenCollectionTableCommand implements Command {
@Parameter( label = "Table Path", required = true )
public File table;

@Parameter( label = "Data Root Folder",
style = "directory",
description = "Use this is if the paths to the images and labels in the table are relative.",
required = false )
public File dataRoot;

@Override
public void run()
{
DebugTools.setRootLevel( "OFF" );

final MoBIESettings settings = new MoBIESettings()
.projectType( ProjectType.CollectionTable );
.projectType( ProjectType.CollectionTable )
.dataRoot( dataRoot.getAbsolutePath() );

try
{
String rootPath = dataRoot == null ? null : dataRoot.getAbsolutePath();
new MoBIE( MoBIEHelper.toURI( table ), settings );
}
catch ( IOException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class OpenTableCommand implements Command {
@Parameter( label = "Labels Path Columns (Comma Separated)", required = false )
public String labels;

@Parameter( label = "Images & Labels Root Folder",
@Parameter( label = "Data Root Folder",
style = "directory",
description = "Use this is if the images and labels paths in the table are relative.",
description = "Use this is if the paths to the images and labels in the table are relative.",
required = false )
public File root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@
import org.embl.mobie.MoBIE;
import org.embl.mobie.MoBIESettings;
import org.embl.mobie.command.CommandConstants;
import org.embl.mobie.lib.MoBIEHelper;
import org.embl.mobie.lib.io.DataFormats;
import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

import java.io.IOException;
import java.net.URI;
import java.net.URL;


@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN_PROJECT + "Open MoBIE Project..." )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void run()

try
{
new MoBIE( "https://github.com/mobie/platybrowser-project", settings );
new MoBIE( "https://github.com/mobie/platybrowser-project", settings );
}
catch ( IOException e )
{
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/embl/mobie/lib/ImageDataAdder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
package org.embl.mobie.lib;

import mpicbg.spim.data.generic.sequence.BasicViewSetup;
import org.apache.commons.io.FilenameUtils;
import org.embl.mobie.MoBIESettings;
import org.embl.mobie.io.ImageDataFormat;
Expand All @@ -44,8 +43,6 @@
import org.embl.mobie.lib.serialize.display.SegmentationDisplay;
import org.embl.mobie.lib.table.TableDataFormat;
import org.janelia.saalfeldlab.n5.universe.metadata.canonical.CanonicalDatasetMetadata;
import org.janelia.saalfeldlab.n5.universe.metadata.canonical.CanonicalSpatialDatasetMetadata;
import spimdata.util.Displaysettings;

import java.io.File;
import java.util.Arrays;
Expand Down Expand Up @@ -110,7 +107,7 @@ private void addData( ImageData< ? > imageData, boolean isSegmentation )
}

dataSource.preInit( true );
dataset.addDataSource( dataSource );
dataset.putDataSource( dataSource );
dataset.is2D( MoBIEHelper.is2D( imageData, datasetIndex ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,39 @@

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

public class DefaultAnnotationAdapter< A extends Annotation > implements AnnotationAdapter< A >
{
private final AtomicBoolean throwError = new AtomicBoolean( true );
private final AnnData< A > annData;
private final String source;
private final A annotation;
private Map< String, A > stlToAnnotation; // source, timepoint, label

public DefaultAnnotationAdapter( AnnData< A > annData )
{
this.annData = annData;
this.source = null;
this.annotation = null;
}

public DefaultAnnotationAdapter( AnnData< A > annData, String source )
{
this.annData = annData;
this.source = source;
this.annotation = null;
}

public DefaultAnnotationAdapter( AnnData< A > annData, String source, A annotation )
{
this.annData = annData;
this.source = source;
this.annotation = annotation;
}

// FIXME: Can we get rid of this? Currently not used...
@Override
public A createVariable()
{
Expand Down Expand Up @@ -87,6 +96,7 @@ public synchronized A getAnnotation( String source, final int timePoint, final i

if ( annotation == null )
{
// FIXME: Check whether this could be done lazy?
if ( throwError.get() )
{
System.err.println( "AnnotationAdapter: Missing annotation: " + source+ "; time point = " + timePoint + "; label = " + label + "\nSuppressing further errors of that kind." );
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/embl/mobie/lib/bdv/MobieBdvSupplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public BdvHandle get()
JFrame bdvFrame = (JFrame) SwingUtilities.getWindowAncestor(bdvHandle.getViewerPanel());

// Get the existing menu bar
// Here we could add or remove stuff...
// TODO: Here we could add or remove stuff...
JMenuBar menuBar = bdvFrame.getJMenuBar();

setTimepointTextColor( bdvHandle );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
public class CollectionTableDataSetter
{
private final Table table;
private final String rootPath;

public CollectionTableDataSetter( Table table )
public CollectionTableDataSetter( Table table, String rootPath )
{
this.table = table;
this.rootPath = rootPath;
}

public void addToDataset( Dataset dataset )
Expand All @@ -45,10 +47,12 @@ public void addToDataset( Dataset dataset )
for ( Row row : table )
{
final StorageLocation storageLocation = new StorageLocation();

storageLocation.absolutePath = getUri( row );
if ( rootPath != null )
storageLocation.absolutePath = IOHelper.combinePath( rootPath, storageLocation.absolutePath );

ImageDataFormat imageDataFormat = ImageDataFormat.fromPath( storageLocation.absolutePath );
// FIXME: how to decide?
//imageDataFormat = ImageDataFormat.BioFormats;
storageLocation.setChannel( getChannel( row ) ); // TODO: Fetch from table or URI? https://forum.image.sc/t/loading-only-one-channel-from-an-ome-zarr/97798
String imageName = getName( row );
String pixelType = getPixelType( row );
Expand All @@ -65,7 +69,7 @@ public void addToDataset( Dataset dataset )
);

segmentationDataSource.preInit( false );
dataset.addDataSource( segmentationDataSource );
dataset.putDataSource( segmentationDataSource );

display = createSegmentationDisplay(
imageName,
Expand All @@ -75,7 +79,7 @@ public void addToDataset( Dataset dataset )
{
final ImageDataSource imageDataSource = new ImageDataSource( imageName, imageDataFormat, storageLocation );
imageDataSource.preInit( false );
dataset.addDataSource( imageDataSource );
dataset.putDataSource( imageDataSource );

display = createImageDisplay(
imageName,
Expand All @@ -84,7 +88,8 @@ public void addToDataset( Dataset dataset )

addDisplayToViews( dataset, display, row );

IJ.log("## " + imageName );
IJ.log(" " );
IJ.log("Name: " + imageName );
IJ.log("URI: " + storageLocation.absolutePath );
IJ.log("Opener: " + imageDataFormat );
IJ.log("Type: " + pixelType );
Expand Down Expand Up @@ -147,7 +152,7 @@ private static void addDisplayToViews( Dataset dataset, Display< ? > display, Ro
{
final View newView = new View(
viewName,
getGroup( display ),
getGroup( display, row ),
displays,
transforms, // asserting that display name == image name
null,
Expand All @@ -160,10 +165,21 @@ private static void addDisplayToViews( Dataset dataset, Display< ? > display, Ro
}

@NotNull
private static String getGroup( Display< ? > display )
private static String getGroup( Display< ? > display, Row row )
{
// TODO: fetch from table
return "views";
try
{
String name = row.getString( CollectionTableConstants.GROUP );

if ( name.isEmpty() )
return "views";

return name;
}
catch ( Exception e )
{
return "views";
}
}

private static String getViewName( Display< ? > display, Row row )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ public void addDataAndDisplaysAndViews( Dataset dataset )
final TableSource tableSource = ( ( LabelGridSources ) sources ).getLabelTable( imageName );
SegmentationDataSource segmentationDataSource = SegmentationDataSource.create( imageName, imageDataFormat, storageLocation, tableSource );
segmentationDataSource.preInit( false );
dataset.addDataSource( segmentationDataSource );
dataset.putDataSource( segmentationDataSource );
}
else
{
final ImageDataSource imageDataSource = new ImageDataSource( imageName, imageDataFormat, storageLocation );
imageDataSource.preInit( false );
dataset.addDataSource( imageDataSource );
dataset.putDataSource( imageDataSource );
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/embl/mobie/lib/hcs/HCSPlateAdder.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void addPlateToDataset( Dataset dataset )
//
String siteID = getSiteID( plate, channel, well, site );
ImageDataSource imageDataSource = createImageDataSource( channel, site, siteID );
dataset.addDataSource( imageDataSource );
dataset.putDataSource( imageDataSource );

// add site image source to site grid
siteGrid.sources.add( imageDataSource.getName() );
Expand All @@ -166,7 +166,7 @@ public void addPlateToDataset( Dataset dataset )
// the one site is the well
//
ImageDataSource imageDataSource = createImageDataSource( channel, site, wellID );
dataset.addDataSource( imageDataSource );
dataset.putDataSource( imageDataSource );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@

import net.imglib2.type.numeric.IntegerType;
import org.embl.mobie.lib.annotation.Annotation;
import org.embl.mobie.lib.annotation.AnnotationAdapter;

public interface AnnotationLabelImage< A extends Annotation > extends AnnotationImage< A >
{
// Label image corresponding to {@code annotation.label()}
Image< ? extends IntegerType< ? > > getLabelImage();

AnnotationAdapter< A > getAnnotationAdapter();
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@ public AnnData< A > getAnnData()
return labelImage;
}

@Override
public AnnotationAdapter< A > getAnnotationAdapter()
{
return annotationAdapter;
}
}
Loading

0 comments on commit ba5ab6f

Please sign in to comment.