Skip to content

Commit

Permalink
Emmanuel comments
Browse files Browse the repository at this point in the history
  • Loading branch information
frheault committed Aug 6, 2024
1 parent e27c357 commit ca306f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 8 additions & 2 deletions scilpy/image/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,17 @@ def get_labels_from_mask(mask_data, labels=None, background_label=0,
# Get the number of structures and assign labels to each blob
label_map, nb_structures = ndi.label(mask_data)
if min_voxel_count:
new_count = 0
for label in range(1, nb_structures + 1):
if np.count_nonzero(label_map == label) < min_voxel_count:
label_map[label_map == label] = 0
mask_data = label_map > 0
label_map, nb_structures = ndi.label(mask_data)
else:
new_count += 1
label_map[label_map == label] = new_count
logging.debug(
f"Ignored blob {nb_structures-new_count} with fewer "
"than {min_voxel_count} voxels")
nb_structures = new_count

# Assign labels to each blob if provided
if labels:
Expand Down
4 changes: 0 additions & 4 deletions scripts/scil_lesions_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
Then, the second input can either be streamlines, binary bundle mask, or a
bundle voxel label map.
To be considered a valid lesion, the lesion volume must be at least
--min_lesion_vol mm3. This avoid the detection of thousand of single voxel
lesions if an automatic lesion segmentation tool is used.
Formerly: scil_analyse_lesions_load.py
"""

Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/test_labels_from_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_execution(script_runner, monkeypatch):
'bundle_4_head_tail_offset.nii.gz')
ret = script_runner.run('scil_labels_from_mask.py',
in_mask, 'labels_from_mask.nii.gz',
'-f')
'--min_volume', '0', '-f')
assert ret.success


Expand Down

0 comments on commit ca306f8

Please sign in to comment.