Skip to content

Commit

Permalink
Make InCarta HCS format work, #1137
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Jun 17, 2024
1 parent 1b6308b commit a577faf
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import java.util.List;
import java.util.stream.Collectors;

@Plugin(type = BdvPlaygroundActionCommand.class, menuPath = CommandConstants.CONTEXT_MENU_ITEMS_ROOT + "Transform>Registration - Manual")
@Plugin(type = BdvPlaygroundActionCommand.class, attrs = {}, menuPath = CommandConstants.CONTEXT_MENU_ITEMS_ROOT + "Transform>Registration - Manual")
public class ManualTransformationCommand extends AbstractTransformationCommand
{

Expand Down
47 changes: 47 additions & 0 deletions src/main/java/org/embl/mobie/command/open/OpenBlobsCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*-
* #%L
* Fiji viewer for MoBIE projects
* %%
* Copyright (C) 2018 - 2024 EMBL
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package org.embl.mobie.command.open;

import ij.IJ;
import org.embl.mobie.command.CommandConstants;
import org.scijava.command.Command;
import org.scijava.plugin.Plugin;

@Plugin(type = Command.class, menuPath = CommandConstants.MOBIE_PLUGIN_OPEN + "Open Blobs..." )
public class OpenBlobsCommand implements Command {

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

@Override
public void run()
{
IJ.run("Blobs (25K)");
}

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

// FIXME: What would happen here if the user chooses GridType.None ?
@Parameter( label = "Grid", description = MoBIEHelper.GRID_TYPE_HELP )
public GridType gridType = GridType.Transformed;

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/org/embl/mobie/lib/hcs/HCSPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public enum HCSPattern
IncuCyteRaw,
InCell, // https://github.com/embl-cba/plateviewer/issues/45
MolecularDevices,
YokogawaCQ1;
YokogawaCQ1,
InCarta;

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

Expand Down Expand Up @@ -101,6 +102,13 @@ public enum HCSPattern
public static final String INCELL = ".*(?<"+WELL+">[A-Z]{1} - [0-9]{2})\\(fld (?<"+SITE+">[0-9]{1}) (?<"+CHANNEL+">.*)\\).tif";


/*
example:
t1_D04_s1_w1_z3.tif
well = D04, site = 1, channel = 1, slice = 3
*/
public static final String INCARTA = ".*_(?<"+WELL+">[A-Z][0-9]{2})_s(?<"+SITE+">[0-9])_w(?<"+CHANNEL+">[0-9])_z(?<"+SLICE+">[0-9]).tif";

/*
example:
W0018F0001T0001Z001C1.tif
Expand Down Expand Up @@ -147,6 +155,8 @@ private Matcher getMatcher( String path )
return Pattern.compile( INCUCYTE_RAW ).matcher( path );
case YokogawaCQ1:
return Pattern.compile( YOKOGAWACQ1 ).matcher( path );
case InCarta:
return Pattern.compile( INCARTA ).matcher( path );
default:
case IncuCyte:
return Pattern.compile( INCUCYTE ).matcher( path );
Expand Down Expand Up @@ -233,6 +243,7 @@ private boolean hasChannels()
case Operetta:
case MolecularDevices:
case IncuCyteRaw:
case InCarta:
return true;
default:
return false;
Expand All @@ -247,6 +258,7 @@ public boolean hasT()
case Operetta:
case MolecularDevices:
case InCell:
case InCarta: // TODO could be made true
return false;
default:
return true;
Expand All @@ -262,6 +274,7 @@ public boolean hasZ()
switch ( this )
{
case YokogawaCQ1:
case InCarta:
return true;
default:
return false;
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/org/embl/mobie/lib/hcs/Plate.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,11 @@ else if ( hcsPattern.equals( HCSPattern.YokogawaCQ1 ) )
}
else if ( hcsPattern.equals( HCSPattern.MolecularDevices ) )
{
try
{
imageDataFormat = ImageDataFormat.Tiff;
ImagePlus imagePlus = IOHelper.openTiffFromFile( imagePaths.get( 0 ) );
}
catch ( Exception e )
{
imageDataFormat = ImageDataFormat.BioFormats;
ImagePlus imagePlus = IOHelper.openWithBioFormatsFromFile( imagePaths.get( 0 ), 0 );
}
imageDataFormat = ImageDataFormat.Tiff;
}
else if ( hcsPattern.equals( HCSPattern.InCarta ) )
{
imageDataFormat = ImageDataFormat.Tiff;
}
}
IJ.log( "Found " + imagePaths.size() + " image file(s) in " + ( System.currentTimeMillis() - start ) + " ms." );
Expand Down
45 changes: 45 additions & 0 deletions src/test/java/develop/hcs/HCSInCarta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*-
* #%L
* Fiji viewer for MoBIE projects
* %%
* Copyright (C) 2018 - 2024 EMBL
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package develop.hcs;

import net.imagej.ImageJ;
import org.embl.mobie.command.open.OpenHCSDatasetCommand;

public class HCSInCarta
{
public static void main( String[] args )
{
final ImageJ imageJ = new ImageJ();
imageJ.ui().showUI();

OpenHCSDatasetCommand command = new OpenHCSDatasetCommand();
command.hcsDirectory = "/Users/tischer/Downloads/timepoint0";
command.run();
}
}
5 changes: 5 additions & 0 deletions src/test/java/org/embl/mobie/lib/hcs/HCSPatternTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ class HCSPatternTest
private static final String incucyteRaw = "/Users/tischer/Downloads/incu-test-data/2207/19/1110/262/B3-1-C2.tif";
private static final String incell = "A - 01(fld 1 wv Green - dsRed z 3).tif";

private static final String incarta = "t1_D04_s1_w1_z3.tif";

private static final String yokogawaCQ1 = "W0018F0001T0001Z001C1.tif";

@Test
void fromPath()
{
final HCSPattern incarta = HCSPattern.fromPath( HCSPatternTest.incarta );
assertEquals( incarta, HCSPattern.InCarta );

final HCSPattern operetta = HCSPattern.fromPath( HCSPatternTest.operetta );
assertEquals( operetta, HCSPattern.Operetta );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ public static void main( String[] args )
command.spatialCalibration = SpatialCalibration.FromTable;

command.run();

// https://forum.image.sc/t/make-fiji-not-quit-when-launching-a-macro-headless/97814
// run("Open Image and Labels...", "image=/Volumes/Microbial_Predation_Analysis_Dev/Interval_output/Source/.*.tif labels=/Volumes/Microbial_Predation_Analysis_Dev/Interval_output/.*_profile_labels.tif table=/Volumes/Microbial_Predation_Analysis_Dev/Interval_output/.*_measurements.csv spatialcalibration=FromTable gridtype=Transformed");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run("Open Image and Labels...", "image=/Volumes/Microbial_Predation_Analysis_Dev/Interval_output/Source/.*.tif labels=/Volumes/Microbial_Predation_Analysis_Dev/Interval_output/.*_profile_labels.tif table=/Volumes/Microbial_Predation_Analysis_Dev/Interval_output/.*_measurements.csv spatialcalibration=FromTable gridtype=Transformed");

0 comments on commit a577faf

Please sign in to comment.