1616
1717
1818@pytest .fixture (scope = "function" )
19- def test_data_dir_3d (tmp_path : Path , zenodo_zarr_3d : list ) -> str :
19+ def ome_zarr_3d_url (tmp_path : Path , testdata_path : Path ) -> str :
2020 """
2121 Copy a test-data folder into a temporary folder.
2222 """
23+ source_dir = testdata_path / "AssayPlate_Greiner_CELLSTAR655090_B03_0.zarr"
2324 dest_dir = (tmp_path / "ilastik_data_3d" ).as_posix ()
2425 if Path (dest_dir ).exists ():
2526 shutil .rmtree (dest_dir )
26- debug (zenodo_zarr_3d , dest_dir )
27- shutil .copytree (zenodo_zarr_3d , dest_dir )
27+ debug (f"Copying { source_dir } to { dest_dir } " )
28+ shutil .copytree (source_dir , dest_dir )
2829 return dest_dir
2930
3031
3132def test_ilastik_pixel_classification_segmentation_task_3D_dual_channel (
32- test_data_dir_3d ,
33+ ome_zarr_3d_url ,
3334):
3435 """
3536 Test the 3D ilastik_pixel_classification_segmentation task with dual channel input.
3637 """
3738 ilastik_model = (
38- Path (__file__ ).parent / "data/ pixel_classifier_3D_dual_channel.ilp"
39+ Path (__file__ ).parent / "data" / " pixel_classifier_3D_dual_channel.ilp"
3940 ).as_posix ()
40- zarr_url = f"{ test_data_dir_3d } /B/03/0"
4141
4242 ilastik_pixel_classification_segmentation (
43- zarr_url = zarr_url ,
44- level = 4 ,
43+ zarr_url = ome_zarr_3d_url ,
44+ level = 0 ,
4545 channel = IlastikChannel1InputModel (label = "DAPI_2" ),
4646 channel2 = IlastikChannel2InputModel (label = "ECadherin_2" ),
4747 ilastik_model = str (ilastik_model ),
@@ -53,8 +53,8 @@ def test_ilastik_pixel_classification_segmentation_task_3D_dual_channel(
5353 # but only one is provided
5454 with pytest .raises (ValueError ):
5555 ilastik_pixel_classification_segmentation (
56- zarr_url = zarr_url ,
57- level = 4 ,
56+ zarr_url = ome_zarr_3d_url ,
57+ level = 0 ,
5858 channel = IlastikChannel1InputModel (label = "DAPI_2" ),
5959 channel2 = IlastikChannel2InputModel (label = None ),
6060 ilastik_model = str (ilastik_model ),
@@ -64,7 +64,7 @@ def test_ilastik_pixel_classification_segmentation_task_3D_dual_channel(
6464
6565
6666def test_ilastik_pixel_classification_segmentation_task_3D_single_channel (
67- test_data_dir_3d ,
67+ ome_zarr_3d_url ,
6868):
6969 """
7070 Test the 3D ilastik_pixel_classification_segmentation task
@@ -73,11 +73,10 @@ def test_ilastik_pixel_classification_segmentation_task_3D_single_channel(
7373 ilastik_model = (
7474 Path (__file__ ).parent / "data/pixel_classifier_3D_single_channel.ilp"
7575 ).as_posix ()
76- zarr_url = f"{ test_data_dir_3d } /B/03/0"
7776
7877 ilastik_pixel_classification_segmentation (
79- zarr_url = zarr_url ,
80- level = 4 ,
78+ zarr_url = ome_zarr_3d_url ,
79+ level = 0 ,
8180 channel = IlastikChannel1InputModel (label = "DAPI_2" ),
8281 channel2 = IlastikChannel2InputModel (label = None ),
8382 ilastik_model = str (ilastik_model ),
@@ -89,8 +88,57 @@ def test_ilastik_pixel_classification_segmentation_task_3D_single_channel(
8988 # but two are provided
9089 with pytest .raises (ValueError ):
9190 ilastik_pixel_classification_segmentation (
92- zarr_url = zarr_url ,
93- level = 4 ,
91+ zarr_url = ome_zarr_3d_url ,
92+ level = 0 ,
93+ channel = IlastikChannel1InputModel (label = "DAPI_2" ),
94+ channel2 = IlastikChannel2InputModel (label = "ECadherin_2" ),
95+ ilastik_model = str (ilastik_model ),
96+ output_label_name = "test_label" ,
97+ relabeling = True ,
98+ )
99+
100+
101+ @pytest .fixture (scope = "function" )
102+ def ome_zarr_2d_url (tmp_path : Path , testdata_path : Path ) -> str :
103+ """
104+ Copy a test-data folder into a temporary folder for 2D tests.
105+ """
106+ source_dir = testdata_path / "test_mip_ome.zarr"
107+ dest_dir = (tmp_path / "ilastik_data_2d" ).as_posix ()
108+ if Path (dest_dir ).exists ():
109+ shutil .rmtree (dest_dir )
110+ debug (f"Copying { source_dir } to { dest_dir } " )
111+ shutil .copytree (source_dir , dest_dir )
112+ return dest_dir
113+
114+
115+ def test_ilastik_pixel_classification_segmentation_task_2D_single_channel (
116+ ome_zarr_2d_url ,
117+ ):
118+ """
119+ Test the 2D ilastik_pixel_classification_segmentation task
120+ with single channel input.
121+ """
122+ ilastik_model = (
123+ Path (__file__ ).parent / "data/pixel_classifier_2D_single_channel.ilp"
124+ ).as_posix ()
125+
126+ ilastik_pixel_classification_segmentation (
127+ zarr_url = ome_zarr_2d_url ,
128+ level = 1 ,
129+ channel = IlastikChannel1InputModel (label = "DAPI_2" ),
130+ channel2 = IlastikChannel2InputModel (label = None ),
131+ ilastik_model = str (ilastik_model ),
132+ output_label_name = "test_label" ,
133+ relabeling = True ,
134+ )
135+
136+ # Test failing of task if model was trained with one channel
137+ # but two are provided
138+ with pytest .raises (ValueError ):
139+ ilastik_pixel_classification_segmentation (
140+ zarr_url = ome_zarr_2d_url ,
141+ level = 1 ,
94142 channel = IlastikChannel1InputModel (label = "DAPI_2" ),
95143 channel2 = IlastikChannel2InputModel (label = "ECadherin_2" ),
96144 ilastik_model = str (ilastik_model ),
0 commit comments