Skip to content

Commit 5f8dea1

Browse files
committed
listof to arraylist if channels are null
1 parent eb13429 commit 5f8dea1

3 files changed

Lines changed: 44 additions & 3 deletions

File tree

src/main/java/fiji/plugin/appose/cellpose/cp3/Cellpose3Parameters.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fiji.plugin.appose.cellpose.cp3;
22

3+
import java.util.Arrays;
34
import java.util.List;
45
import java.util.Map;
56

@@ -89,13 +90,13 @@ public Builder channels( final List< Integer > channels )
8990

9091
public Builder channels( final Integer channel1, final Integer channel2 )
9192
{
92-
this.channels = List.of( channel1, channel2 );
93+
this.channels = Arrays.asList( channel1, channel2 );
9394
return this;
9495
}
9596

9697
public Builder channels( final int channel1, final int channel2 )
9798
{
98-
this.channels = List.of( channel1, channel2 );
99+
this.channels = Arrays.asList( channel1, channel2 );
99100
return this;
100101
}
101102

src/main/java/fiji/plugin/appose/cellpose/cp3/CellposeAppose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public < T extends RealType< T > & NativeType< T > > void process( final ImagePl
303303

304304
try
305305
{
306-
final List<Integer> channels = List.of(
306+
final List<Integer> channels = Arrays.asList(
307307
ApposeUtils.convertChannelChoiceToInt( cyto_channel, true ),
308308
ApposeUtils.convertChannelChoiceToInt( nuclei_channel, true ));
309309

src/test/java/fiji/plugin/appose/cellpose/TestCellPoseAppose.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import ij.ImagePlus;
1616
import ij.WindowManager;
1717
import ij.gui.NewImage;
18+
import ij.plugin.Duplicator;
1819
import ij.process.ImageStatistics;
1920

2021
import static org.junit.jupiter.api.Assertions.*;
@@ -104,4 +105,43 @@ public void defaultRunCP3() throws Exception
104105
throw e;
105106
}
106107
}
108+
109+
@Test
110+
public void runCP3_Image3DMultiChannels() throws Exception
111+
{
112+
try
113+
{
114+
final ImagePlus stack = IJ.openImage( "https://imagej.net/images/mitosis.tif" );
115+
// Keep only one time point
116+
ImagePlus imp = new Duplicator().run(
117+
stack,
118+
1, stack.getNChannels(),
119+
1, stack.getNSlices(),
120+
3, 3
121+
);
122+
// Get all default parameters
123+
final Cellpose3Parameters paramsCP3 = Cellpose3Parameters.builder()
124+
.do3D(false)
125+
.stitchThreshold(0.1)
126+
.channels(1, null)
127+
.build();
128+
// Run it
129+
final ImagePlus[] outputCP3 = Cellpose.cellpose3( imp, paramsCP3 );
130+
// Get the label image results
131+
final ImagePlus labelsCP3 = outputCP3[ 0 ];
132+
// Check the label image dimensions
133+
assertEquals( imp.getWidth(), labelsCP3.getWidth(), "CP3, 3D+chan image: labels image dimension (width) is uncorrect" );
134+
assertEquals( imp.getHeight(), labelsCP3.getHeight(), "CP3, 3D+chan image: labels image dimension (height) is uncorrect" );
135+
136+
// Check the image statistics if it looks like a successfull run
137+
labelsCP3.setSlice(2);
138+
ImageStatistics stats = labelsCP3.getStatistics();
139+
assertFalse( stats.max <= 0, "CP3: No labels were found in test image, with default parameters" );
140+
assertTrue( stats.max > 1, "CP3: Not enough labels were found in test image, with default parameters" );
141+
}
142+
catch (Exception e)
143+
{
144+
throw e;
145+
}
146+
}
107147
}

0 commit comments

Comments
 (0)