@@ -97,7 +97,7 @@ def segment_ROI(
9797 # Shape from (czyx) to (tzyxc)
9898 input_data = np .moveaxis (input_data , 0 , - 1 )
9999 input_data = np .expand_dims (input_data , axis = 0 )
100- print (f"{ input_data .shape = } " )
100+ logger . info (f"{ input_data .shape = } " )
101101 data = [
102102 {
103103 "Raw Data" : PreloadedArrayDatasetInfo (
@@ -109,26 +109,22 @@ def segment_ROI(
109109 ilastik_output = shell .workflow .batchProcessingApplet .run_export (
110110 data , export_to_array = True
111111 )[0 ]
112- logger .info (f"{ ilastik_output .shape = } " )
112+ logger .info (f"{ ilastik_output .shape = } after ilastik prediction " )
113113
114114 # Get foreground class and reshape to 3D
115- ilastik_output = ilastik_output [..., foreground_class ]
116- ilastik_output = np .reshape (
117- ilastik_output , (input_data .shape [1 ], input_data .shape [2 ], input_data .shape [3 ])
118- )
119- logger .info (f"{ ilastik_output .shape = } " )
115+ ilastik_output = np .squeeze (ilastik_output [..., foreground_class ])
116+ print (f"{ ilastik_output .shape = } after foreground class selection" )
120117
121118 # take mask of regions above threshold
122- ilastik_output [ilastik_output < threshold ] = 0
123- ilastik_output [ilastik_output >= threshold ] = 1
119+ ilastik_labels = ilastik_output > threshold
124120
125121 # remove small holes
126- ilastik_output = remove_small_holes (
127- ilastik_output . astype ( bool ) , area_threshold = min_size
122+ ilastik_labels = remove_small_holes (
123+ ilastik_labels , area_threshold = min_size
128124 )
129125
130126 # label image
131- ilastik_labels = label (ilastik_output )
127+ ilastik_labels = label (ilastik_labels )
132128
133129 # remove objects below min_size - also removes anything with major or minor axis
134130 # length of 0 for compatibility with current measurements task (01.24)
@@ -141,10 +137,10 @@ def segment_ROI(
141137 or (label_props [i ].axis_major_length < 1 )
142138 or (label_props [i ].major_axis_length < 1 )
143139 ]
144- print (f"number of labels before filtering for size = { ilastik_labels .max ()} " )
140+ logger . info (f"number of labels before filtering for size = { ilastik_labels .max ()} " )
145141 ilastik_labels [np .isin (ilastik_labels , labels2remove )] = 0
146142 ilastik_labels = label (ilastik_labels )
147- print (f"number of labels after filtering for size = { ilastik_labels .max ()} " )
143+ logger . info (f"number of labels after filtering for size = { ilastik_labels .max ()} " )
148144 label_props = regionprops (ilastik_labels )
149145
150146 return ilastik_labels .astype (label_dtype )
@@ -255,7 +251,7 @@ def ilastik_pixel_classification_segmentation(
255251 label = channel2 .label ,
256252 )
257253 if tmp_channel_2 :
258- ind_channel_c2 = tmp_channel .index
254+ ind_channel_c2 = tmp_channel_2 .index
259255 else :
260256 return ValueError (f"Channel { channel2 } could not be loaded." )
261257
@@ -382,7 +378,7 @@ def ilastik_pixel_classification_segmentation(
382378 chunks = chunks ,
383379 dtype = label_dtype ,
384380 store = store ,
385- overwrite = False ,
381+ overwrite = overwrite ,
386382 dimension_separator = "/" ,
387383 )
388384
0 commit comments