@@ -53,12 +53,12 @@ def intensity_measures(seg_id):
5353
5454 bb_min = np .array ([
5555 row .bb_min_z .item (), row .bb_min_y .item (), row .bb_min_x .item ()
56- ]) / resolution
56+ ]). astype ( "float32" ) / resolution
5757 bb_min = np .round (bb_min , 0 ).astype ("uint32" )
5858
5959 bb_max = np .array ([
6060 row .bb_max_z .item (), row .bb_max_y .item (), row .bb_max_x .item ()
61- ]) / resolution
61+ ]). astype ( "float32" ) / resolution
6262 bb_max = np .round (bb_max , 0 ).astype ("uint32" )
6363
6464 bb = tuple (
@@ -68,15 +68,16 @@ def intensity_measures(seg_id):
6868
6969 local_image = image [bb ]
7070 mask = segmentation [bb ] == seg_id
71+ assert mask .sum () > 0 , f"Segmentation ID { seg_id } is empty."
7172 masked_intensity = local_image [mask ]
7273
7374 # Do the base intensity measurements.
7475 measures = {
7576 "label_id" : seg_id ,
7677 "mean" : np .mean (masked_intensity ),
7778 "stdev" : np .std (masked_intensity ),
78- "min" : np .nanmin (masked_intensity ),
79- "max" : np .nanmax (masked_intensity ),
79+ "min" : np .min (masked_intensity ),
80+ "max" : np .max (masked_intensity ),
8081 "median" : np .median (masked_intensity ),
8182 }
8283 for percentile in (5 , 10 , 25 , 75 , 90 , 95 ):
0 commit comments