-
Notifications
You must be signed in to change notification settings - Fork 227
Fix labels from Slicer plugin offset by extra background class #716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1279,8 +1279,9 @@ def onSaveLabel(self): | |
qt.QApplication.setOverrideCursor(qt.Qt.WaitCursor) | ||
segmentationNode = self._segmentNode | ||
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode") | ||
slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode( | ||
segmentationNode, labelmapVolumeNode, self._volumeNode | ||
save_segment_ids = [segment_id for segment_id in segmentationNode.GetSegmentation().GetSegmentIDs() if segment_id != "background"] | ||
slicer.modules.segmentations.logic().ExportSegmentsToLabelmapNode( | ||
segmentationNode, save_segment_ids, labelmapVolumeNode, self._volumeNode | ||
) | ||
|
||
segmentation = segmentationNode.GetSegmentation() | ||
|
@@ -1722,8 +1723,11 @@ def onUpdateScribbles(self): | |
# get scribbles + label | ||
segmentationNode = self._segmentNode | ||
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode") | ||
slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode( | ||
segmentationNode, labelmapVolumeNode, self._volumeNode | ||
_, segment = self.currentSegment() | ||
selected_label_name = segment.GetName() | ||
save_segment_ids = [selected_label_name, "background_scribbles", "foreground_scribbles"] | ||
slicer.modules.segmentations.logic().ExportSegmentsToLabelmapNode( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a known issue for scribbles.. it currently can't support/persist scribbles per label.. specially in case for multi-label.. what you need is save/persist the bg/fg scribbles (similar to fg/bg fudical/click points) per label.. so the behavior/user experience in case of multilabel might not be good. However, i will let @masadcv to decide what he needs from the label node.. i guess he might want to get all labels and pick fg/bg label masks as part of pre-transforms + again only corrected label should get updated.. i guess it needs to be fixed/verified as well.. In future these methods might want to use existing label masks as input along with fg/bg label masks.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adamaji @SachidanandAlle understood. The scribbles labels are currently hard-coded in server app, these need to be passed from the client - in case the order changes or similar shift in label are present (due to any changes to client). Hence, a need for dynamic updates for this. As Sachi said, background may need to be removed before saving final segmentation output, but this can be done at https://github.com/Project-MONAI/MONAILabel/blob/main/plugins/slicer/MONAILabel/MONAILabel.py#L1293 I will continue this in PR #717 where I will merge the changes from here for updating the current label and provide a generalisable solution to the problem that we can extend in future to multi-label problems. As this needs proper testing with multilabel problem, I will take sometime and get back with an update when ready. |
||
segmentationNode, save_segment_ids, labelmapVolumeNode, self._volumeNode | ||
) | ||
scribbles_in = tempfile.NamedTemporaryFile(suffix=self.file_ext, dir=self.tmpdir).name | ||
self.reportProgress(5) | ||
|
@@ -1753,9 +1757,7 @@ def onUpdateScribbles(self): | |
|
||
# display result from server | ||
self.reportProgress(90) | ||
_, segment = self.currentSegment() | ||
label = segment.GetName() | ||
self.updateSegmentationMask(result_file, [label]) | ||
self.updateSegmentationMask(result_file, [selected_label_name]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes,, this will make sure we update the selected mask only 👍 |
||
except: | ||
slicer.util.errorDisplay( | ||
"Failed to post process label on MONAI Label Server using {}".format(scribblesMethod), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can discard the
background
label (which is normally used by deepedit multilabel model) along with scribbles background/foreground when you save the label..but the fix possibly by adding "background" to the list mentioned at: https://github.com/Project-MONAI/MONAILabel/blob/main/plugins/slicer/MONAILabel/MONAILabel.py#L1293