-
Notifications
You must be signed in to change notification settings - Fork 4
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
BUG: Fix 4DCT vrg pipeline not properly centering sequences #106
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
1e87e54
to
1cdd824
Compare
We are getting close 🙏 Few nitpicks:
|
3cb2228
to
89fb6aa
Compare
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.
in onGenerateVRG
, after line 512, I suggest to simplify doing something like this:
# center the volume
transformOutputDir = os.path.join(mainOutputDir, tfmPath)
self.logic.createPathsIfNotExists(transformOutputDir)
if not self.logic.IsSequenceVolume(volumeNode):
IO.exportOrigin2DicomTransform(volumeNode, transformOutputDir)
else:
# Just export the first frame
proxyNode = self.logic.getItemInSequence(volumeNode, 0)[0]
IO.exportOrigin2DicomTransform(proxyNode, transformOutputDir)
if tfmNode is not None:
# if still needed, explain here why calling "AddCenteringTransform" and reverting its effect is still needed
And here is the function exportOrigin2DicomTransform
:
def exportOrigin2DicomTransform(volumeNode, exportDir):
"""If volume is not already centered, save corresponding transform as `Origin2Dicom.tfm`"""
if volumeNode.IsCentered():
return False
volumeNode.AddCenteringTransform():
# Get reference to the centering transform (Volume to Center)
tfmNode = volumeNode.GetParentTransformNode()
# Revert effect of "AddCenteringTransform"
volumeNode.HardenTransform()
volumeNode.SetAndObserveTransformNodeID(None)
# Update from "Volume to Center" to "Center to Volume"
tfmNode.Inverse()
# Save as "Origin2Dicom.tfm"
tfmPath = os.path.join(exportDir, "Origin2Dicom.tfm")
slicer.util.saveNode(tfmNode, tfmPath)
slicer.mrmlScene.RemoveNode(tfmNode)
return True
Ideally, we should also look into adding support to call GetCenterPositionRAS
from Python, this would simplify the logic.
7be5d19
to
ea12bb2
Compare
This doesn't seem to be exposed in the Python API: >>> x.GetCenterPositionRAS()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'MRMLCorePython.vtkMRMLScalarVolumeNode' object has no attribute 'GetCenterPositionRAS' It also seems to be a protected function for the vtkMRMLVolumeNode. Was this exposed somewhere else? |
ea12bb2
to
8f9f21f
Compare
8f9f21f
to
94011eb
Compare
Suggest with the depreciation of vrgs- also close this |
Regression introduced in e036c22
Closes #105
Also resolves this comment #102 (comment)