2929
3030package org .scijava .ops .image .coloc .saca ;
3131
32- import io .scif .img .ImgOpener ;
3332import net .imglib2 .RandomAccess ;
3433import net .imglib2 .img .Img ;
3534import net .imglib2 .type .logic .BitType ;
36- import net .imglib2 .type .numeric .real .FloatType ;
3735import net .imglib2 .type .numeric .real .DoubleType ;
3836import net .imglib2 .type .numeric .integer .UnsignedByteType ;
3937
40- import org .scijava .io .location .FileLocation ;
4138import org .scijava .types .Nil ;
4239import org .scijava .ops .image .AbstractColocalisationTest ;
4340
4441import org .junit .jupiter .api .Test ;
42+ import org .junit .jupiter .api .BeforeAll ;
4543import static org .junit .jupiter .api .Assertions .assertEquals ;
4644
4745/**
@@ -58,27 +56,33 @@ public class SACATest extends AbstractColocalisationTest {
5856 private final static int [] yPositions = { 30 , 36 , 80 , 79 , 139 , 102 , 77 , 41 ,
5957 142 , 118 };
6058
61- // green and red colocalization images
62- private Img <UnsignedByteType > green = getPositiveCorrelationImageCh1 ();
63- private Img <UnsignedByteType > red = getPositiveCorrelationImageCh2 ();
59+ // image containers
60+ private static Img <DoubleType > zscore ;
6461
65- @ Test
66- public void testSACAHeatmapZScore () {
67- final double [] zscoreExpected = { 0.0 , 6.117364936585281 , 0.0 ,
68- - 1.282447034877343 , 0.0 , 6.642396454955293 , 0.0 , - 1.6567255788972388 , 0.0 ,
69- 3.5385003044434877 } ;
62+ @ BeforeAll
63+ public static void setUpTest () {
64+ // green and red colocalization images
65+ Img < UnsignedByteType > green = getPositiveCorrelationImageCh1 ();
66+ Img < UnsignedByteType > red = getPositiveCorrelationImageCh2 () ;
7067
7168 // get slice 15 from colocalization data
7269 var gs = ops .op ("transform.hyperSliceView" ).input (green , 2 , 15 ).apply ();
7370 var rs = ops .op ("transform.hyperSliceView" ).input (red , 2 , 15 ).apply ();
7471
7572 // create image container
76- Img < DoubleType > zscore = ops .op ("create.img" ).input (gs , new DoubleType ())
77- . outType ( new Nil <Img <DoubleType >>()
73+ zscore = ops .op ("create.img" ).input (gs , new DoubleType ()). outType (
74+ new Nil <Img <DoubleType >>()
7875 {}).apply ();
7976
8077 // run SACA heatmap Z score op
8178 ops .op ("coloc.saca.heatmapZScore" ).input (gs , rs ).output (zscore ).compute ();
79+ }
80+
81+ @ Test
82+ public void testSACAHeatmapZScore () {
83+ final double [] zscoreExpected = { 0.0 , 6.117364936585281 , 0.0 ,
84+ -1.282447034877343 , 0.0 , 6.642396454955293 , 0.0 , -1.6567255788972388 , 0.0 ,
85+ 3.5385003044434877 };
8286
8387 // get random access and assert results are equal
8488 final RandomAccess <DoubleType > zRA = zscore .randomAccess ();
@@ -92,17 +96,15 @@ public void testSACAHeatmapZScore() {
9296 @ Test
9397 public void testSACASigMask () {
9498 final double [] sigExpected = { 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ,
95- 1.0 };
96-
97- Img <FloatType > zscore_ref = openFloatImg ("stats/zscore_test_data.tif" );
99+ 0.0 };
98100
99101 // create image container
100- Img <BitType > sigMask = ops .op ("create.img" ).input (zscore_ref , new BitType ())
102+ Img <BitType > sigMask = ops .op ("create.img" ).input (zscore , new BitType ())
101103 .outType (new Nil <Img <BitType >>()
102104 {}).apply ();
103105
104106 // run SACA significant pixel mask op
105- ops .op ("coloc.saca.sigMask" ).input (zscore_ref ).output (sigMask ).compute ();
107+ ops .op ("coloc.saca.sigMask" ).input (zscore ).output (sigMask ).compute ();
106108
107109 // get random access and assert results are equal
108110 final RandomAccess <BitType > sRA = sigMask .randomAccess ();
@@ -112,12 +114,4 @@ public void testSACASigMask() {
112114 assertEquals (sigExpected [i ], sRA .get ().getRealDouble ());
113115 }
114116 }
115-
116- @ SuppressWarnings ("unchecked" )
117- public Img <FloatType > openFloatImg (final String relPath ) {
118- final ImgOpener opener = new ImgOpener ();
119- String source = "src/test/resources/org/scijava/ops/image/" + relPath ;
120- FileLocation loc = new FileLocation (source );
121- return (Img ) opener .openImgs (loc ).get (0 );
122- }
123117}
0 commit comments