Skip to content

Commit

Permalink
Fix bug in CollectionTable where different channels would wrongly yie…
Browse files Browse the repository at this point in the history
…ld the same image name
  • Loading branch information
tischi committed Feb 9, 2025
1 parent 4a0e08a commit 53e588d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

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

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

<!-- ../scijava-scripts/release-version.sh - -skip-version-check - -skip-license-update -->
<!-- ../scijava-scripts/release-version.sh - -skip-version-check - -skip-license-update -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.embl.mobie.lib.data;

import IceInternal.Ex;
import ij.IJ;
import net.imglib2.type.numeric.ARGBType;
import org.embl.mobie.DataStore;
Expand Down Expand Up @@ -235,7 +236,7 @@ else if ( existingDisplay instanceof ImageDisplay )
gridRegionDisplay.sources.put( source, Collections.singletonList( source ) );

// TODO: in some cases only do this once for several grids
dataset.views().get( viewName ).displays().add( gridRegionDisplay );
dataset.views().get( viewName ).displays().add( gridRegionDisplay );
}

}
Expand Down Expand Up @@ -313,7 +314,17 @@ private static String getName( Row row )
private static String getNameFromURI( Row row )
{
String uri = getUri( row );
return MoBIEHelper.removeExtension( IOHelper.getFileName( uri ) );
String name = MoBIEHelper.removeExtension( IOHelper.getFileName( uri ) );
try
{
int channelIndex = row.getInt( CollectionTableConstants.CHANNEL );
name = name + "_c" + channelIndex;
}
catch ( Exception e )
{
// do nothing
}
return name;
}

private static String getDataType( Row row )
Expand Down Expand Up @@ -351,7 +362,10 @@ private static String getGridId( Row row )
private static int getChannel( Row row )
{
try {
return row.getInt( CollectionTableConstants.CHANNEL );
int channelIndex = row.getInt( CollectionTableConstants.CHANNEL );
if ( channelIndex < 0 )
return 0; // Sometimes an empty string yields a negative number
return channelIndex;
}
catch ( Exception e )
{
Expand Down Expand Up @@ -482,7 +496,7 @@ private static double[] getContrastLimits( Row row )

if ( doubles.length != 2 )
throw new UnsupportedOperationException("Contrast limits must have exactly two values: (min, max).\n" +
"This table cell entry does not adhere to this specification: " + string );
string + "does not adhere to this specification." );

return doubles;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/embl/mobie/lib/image/ImageDataImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ImageDataImage< T extends NumericType< T > & NativeType< T > > impl
{
private ImageDataFormat imageDataFormat;
private String uri;
private int setupId;
private int setupId = 0;
private SourcePair< T > sourcePair;
private String name;
private Site site;
Expand All @@ -68,7 +68,7 @@ public ImageDataImage( ImageData< ? > imageData, Integer setupId, String name, V
this.imageDataFormat = null;
this.uri = null;
this.sharedQueue = null;
this.setupId = setupId == null ? 0 : setupId;
if ( setupId != null ) this.setupId = setupId;
this.name = name; // FIXME: add the datasetname to the name ?!
System.out.println("Name: " + name );
System.out.println("SetupID: " + setupId );
Expand All @@ -80,14 +80,14 @@ public ImageDataImage( ImageData< ? > imageData, Integer setupId, String name, V
public ImageDataImage(
ImageDataFormat imageDataFormat,
String uri,
int setupId,
Integer setupId,
String name,
@Nullable SharedQueue sharedQueue,
VoxelDimensions voxelDimensions )
{
this.imageDataFormat = imageDataFormat;
this.uri = uri;
this.setupId = setupId;
if ( setupId != null ) this.setupId = setupId;
this.name = name;
this.sharedQueue = sharedQueue;
this.voxelDimensions = voxelDimensions;
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/embl/mobie/lib/io/FileImageSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
package org.embl.mobie.lib.io;

import org.apache.commons.io.FilenameUtils;
import org.embl.mobie.lib.util.MoBIEHelper;

import java.io.File;
Expand All @@ -44,15 +43,15 @@ public class FileImageSource
* "path=name;channelIndex"
* where everything after path is optional
*
* @param string
* the string to be parsed
* @param uri
* the uri to be parsed
*/
public FileImageSource( String string )
public FileImageSource( String uri )
{
String[] split = new String[]{ string };
if ( string.contains( ";" ) )
String[] split = new String[]{ uri };
if ( uri.contains( ";" ) )
{
split = string.split( ";" );
split = uri.split( ";" );
channelIndex = Integer.parseInt( split[ 1 ] );
}

Expand Down

0 comments on commit 53e588d

Please sign in to comment.