Skip to content

Commit

Permalink
Re #46: Added ultrasound 2D and 3D view
Browse files Browse the repository at this point in the history
  • Loading branch information
ungi committed Sep 13, 2021
1 parent b831a2e commit 77e57ca
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions LumpNav2/LumpNav2.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,31 @@ def setup(self):

self.setupTransformHierarchy()

# Show ultrasound in 2D view

layoutManager = slicer.app.layoutManager()
# Show ultrasound in red view.
redSlice = layoutManager.sliceWidget('Red')
controller = redSlice.sliceController()
controller.setSliceVisible(True)
redSliceLogic = redSlice.sliceLogic()
image_Image = parameterNode.GetNodeReference(self.IMAGE_IMAGE)
redSliceLogic.GetSliceCompositeNode().SetBackgroundVolumeID(image_Image.GetID())
# Set up volume reslice driver.
resliceLogic = slicer.modules.volumereslicedriver.logic()
if resliceLogic:
redNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
# Typically the image is zoomed in, therefore it is faster if the original resolution is used
# on the 3D slice (and also we can show the full image and not the shape and size of the 2D view)
redNode.SetSliceResolutionMode(slicer.vtkMRMLSliceNode.SliceResolutionMatchVolumes)
resliceLogic.SetDriverForSlice(image_Image.GetID(), redNode)
resliceLogic.SetModeForSlice(6, redNode) # Transverse mode, default for PLUS ultrasound.
resliceLogic.SetFlipForSlice(False, redNode)
resliceLogic.SetRotationForSlice(180, redNode)
redSliceLogic.FitSliceToAll()
else:
logging.warning('Logic not found for Volume Reslice Driver')

# Create models

createModelsLogic = slicer.modules.createmodels.logic()
Expand Down Expand Up @@ -947,6 +972,7 @@ def setupTransformHierarchy(self):
imageImage.CreateDefaultDisplayNodes()
imageArray = np.zeros((512, 512, 1), dtype="uint8")
slicer.util.updateVolumeFromArray(imageImage, imageArray)
parameterNode.SetNodeReferenceID(self.IMAGE_IMAGE, imageImage.GetID())
imageImage.SetAndObserveTransformNodeID(imageToTransd.GetID())

def updateImageToTransdFromDepth(self, depthMm):
Expand Down

0 comments on commit 77e57ca

Please sign in to comment.