Split confulent lesions scil_labels_from_mask#1308
Split confulent lesions scil_labels_from_mask#1308zinelya wants to merge 3 commits intoscilus:masterfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1308 +/- ##
==========================================
- Coverage 72.72% 72.70% -0.02%
==========================================
Files 295 295
Lines 25445 25457 +12
Branches 3565 3566 +1
==========================================
+ Hits 18505 18509 +4
- Misses 5437 5443 +6
- Partials 1503 1505 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| p.add_argument('--min_volume', type=float, default=7, | ||
| help='Minimum volume in mm3 [%(default)s],' | ||
| 'Useful for lesions.') | ||
| p.add_argument('--min_distance', type=int, default=None, |
There was a problem hiding this comment.
I think this will allow you to do what you want here:
p.add_argument('--watershed', metavar='MIN_DISTANCE', type=int, nargs='?', const=1, help='Use a watershed algorithm, if provided the parameter (default: 1 voxel) allow to ...')
This make so p.watershed is None by default, if you use --watershep it is 1 by default, but you can do --watershed 10 to change it.
| min_voxel_count: int, optional | ||
| Minimum number of voxels for a blob to be considered. Blobs with fewer | ||
| voxels will be ignored. | ||
| min_distance : int, optional |
There was a problem hiding this comment.
I think it should be explicit in the docstring that this trigger a change to a watershed algorithm
| label_map = watershed(-distance, markers, mask=mask_data) | ||
| nb_structures = np.max(label_map) | ||
| else: | ||
| label_map, nb_structures = ndi.label(mask_data) |
There was a problem hiding this comment.
Maybe a small comment saying "Any contigous regions touching even by a single voxel will be considered a single label"
|
|
||
| def get_labels_from_mask(mask_data, labels=None, background_label=0, | ||
| min_voxel_count=0): | ||
| min_voxel_count=0, min_distance=0): |
There was a problem hiding this comment.
It would be clearer if it was None and if your condition was if min_distance is not None: later
|
Very cool extension, it works very well for me, but there are some ( small) lesions for which segmentation is a bit messy, and I don't know how to adjust the minimum distance to compensate for this. I'm having a little trouble understanding how the minimum distance system works in the algorithm. Perhaps it needs to be a little more verbose in the min distance parameter. For the code, I have nothing to add at this point other than François' comments. |
Quick description
This PR introduces a new optional parameter --min_distance to the scil_labels_from_mask script. This feature allows the user to split "confluent" lesions—multiple lesions that have merged into a single connected component—using the Watershed algorithm.
Type of change
Check the relevant options.
Provide data, screenshots, command line to test (if relevant)
mask.nii.gz
default_labels.nii.gz
min_dist_labels.nii.gz
Checklist