Prof @lassoan ,
I was following the discussion at
At this momement, if we tell to grow the margin by 0.5 mm in a cylinder, is only 0.25 mm is grown on either side ? so if we want 0.5 in one side do we need to grow it by 1 mm ?
Prof @lassoan ,
I was following the discussion at
At this momement, if we tell to grow the margin by 0.5 mm in a cylinder, is only 0.25 mm is grown on either side ? so if we want 0.5 in one side do we need to grow it by 1 mm ?
Margin size will mean the how much a boundary will be moved (if you set 1mm as margin then the object will be 2mm wider).
Now as margin growing working perfectly we started working on analysis of data and we noticed a very minor offset of the ROI.
We expected the Bar of the ROI to align to all the fiducials. we initially thought it was due to error in placement of marks and we incorporated auto update and played around
markupObservation = [markups, markups.AddObserver(slicer.vtkMRMLMarkupsNode.PointModifiedEvent, UpdateSlicePlane, 0)]
In Slice view it is nicely in plane but the ROI does not fit perfectly to that. Is this expected ? Is there something that need to be changed in the ROI code ?
The Coplanar script is working perfectly i think as you can see. It is something wrong with the ROI.
How did you position the ROI? Is it the oriented bounding box provided by Segment statistics?
I could not figure out how to gt the bounding box with the segment statistics.
I did it with the Script in the repository.
segmentationNode = getNode(âSegmentationâ)
import SegmentStatistics
segStatLogic = SegmentStatistics.SegmentStatisticsLogic()
segStatLogic.getParameterNode().SetParameter(âSegmentationâ, segmentationNode.GetID())
segStatLogic.getParameterNode().SetParameter(âLabelmapSegmentStatisticsPlugin.obb_origin_ras.enabledâ,str(True))
segStatLogic.getParameterNode().SetParameter(âLabelmapSegmentStatisticsPlugin.obb_diameter_mm.enabledâ,str(True))
segStatLogic.getParameterNode().SetParameter(âLabelmapSegmentStatisticsPlugin.obb_direction_ras_x.enabledâ,str(True))
segStatLogic.getParameterNode().SetParameter(âLabelmapSegmentStatisticsPlugin.obb_direction_ras_y.enabledâ,str(True))
segStatLogic.getParameterNode().SetParameter(âLabelmapSegmentStatisticsPlugin.obb_direction_ras_z.enabledâ,str(True))
segStatLogic.computeStatistics()
stats = segStatLogic.getStatistics()
import numpy as np
for segmentId in stats[âSegmentIDsâ]:
# Get bounding box
obb_origin_ras = np.array(stats[segmentId,âLabelmapSegmentStatisticsPlugin.obb_origin_rasâ])
obb_diameter_mm = np.array(stats[segmentId,âLabelmapSegmentStatisticsPlugin.obb_diameter_mmâ])
obb_direction_ras_x = np.array(stats[segmentId,âLabelmapSegmentStatisticsPlugin.obb_direction_ras_xâ])
obb_direction_ras_y = np.array(stats[segmentId,âLabelmapSegmentStatisticsPlugin.obb_direction_ras_yâ])
obb_direction_ras_z = np.array(stats[segmentId,âLabelmapSegmentStatisticsPlugin.obb_direction_ras_zâ])
# Create ROI
segment = segmentationNode.GetSegmentation().GetSegment(segmentId)
roi=slicer.mrmlScene.AddNewNodeByClass(âvtkMRMLAnnotationROINodeâ)
roi.SetName(segment.GetName()+â bounding boxâ)
roi.SetXYZ(0.0, 0.0, 0.0)
roi.SetRadiusXYZ((0.5obb_diameter_mm))
# Position and orient ROI using a transform
obb_center_ras = obb_origin_ras+0.5*(obb_diameter_mm[0] * obb_direction_ras_x + obb_diameter_mm[1] * obb_direction_ras_y + obb_diameter_mm[2] * obb_direction_ras_z)
boundingBoxToRasTransform = np.row_stack((np.column_stack((obb_direction_ras_x, obb_direction_ras_y, obb_direction_ras_z, obb_center_ras)), (0, 0, 0, 1)))
boundingBoxToRasTransformMatrix = slicer.util.vtkMatrixFromArray(boundingBoxToRasTransform)
transformNode = slicer.mrmlScene.AddNewNodeByClass(âvtkMRMLTransformNodeâ)
transformNode.SetAndObserveMatrixTransformToParent(boundingBoxToRasTransformMatrix)
roi.SetAndObserveTransformNodeID(transformNode.GetID())