Skip to content
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

Jump to the center of the segment does not always work #227

Open
fedorov opened this issue Apr 4, 2018 · 1 comment
Open

Jump to the center of the segment does not always work #227

fedorov opened this issue Apr 4, 2018 · 1 comment
Labels

Comments

@fedorov
Copy link
Member

fedorov commented Apr 4, 2018

@che85 no need to work on this right away, but can you add the pointer here to the relevant part of code?

@fedorov fedorov added the bug label Apr 4, 2018
@che85
Copy link
Member

che85 commented Apr 4, 2018

It's

def jumpToSegmentCenter(self, segment):
centroid = self.logic.getSegmentCentroid(self.segmentationNode, segment)
if centroid:
markupsLogic = slicer.modules.markups.logic()
markupsLogic.JumpSlicesToLocation(centroid[0], centroid[1], centroid[2], False)

and

def getSegmentCentroid(segmentationNode, segment):
imageData = vtkSegmentationCore.vtkOrientedImageData()
segmentID = segmentationNode.GetSegmentation().GetSegmentIdBySegment(segment)
segmentationsLogic = slicer.modules.segmentations.logic()
segmentationsLogic.GetSegmentBinaryLabelmapRepresentation(segmentationNode, segmentID, imageData)
extent = imageData.GetExtent()
if extent[1] != -1 and extent[3] != -1 and extent[5] != -1:
tempLabel = slicer.vtkMRMLLabelMapVolumeNode()
slicer.mrmlScene.AddNode(tempLabel)
tempLabel.SetName(segment.GetName() + "CentroidHelper")
segmentationsLogic.CreateLabelmapVolumeFromOrientedImageData(imageData, tempLabel)
CustomSegmentEditorLogic.applyThreshold(tempLabel, 1)
centroid = ModuleLogicMixin.getCentroidForLabel(tempLabel, 1)
slicer.mrmlScene.RemoveNode(tempLabel)
return centroid
return None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants