Created
November 25, 2025 15:13
-
-
Save ebrahimebrahim/c8bde4cc4f32a1da8c4e8561fdcba6a5 to your computer and use it in GitHub Desktop.
Non-working Slicer curved planar reformat module test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| slicer.mrmlScene.Clear(0) | |
| # Check that registration of "ResampleScalarVectorDWIVolume" worked. | |
| resamplerName = "ResampleScalarVectorDWIVolume" | |
| generalizedReformatLogic = slicer.modules.generalizedreformat.logic() | |
| generalizedReformatLogic.SetMRMLApplicationLogic(slicer.app.applicationLogic()) | |
| found = generalizedReformatLogic.IsVolumeResamplerRegistered(resamplerName) | |
| print(f"{resamplerName!r} was{'' if found else ' NOT'} found in module logic") | |
| # Check that we can find an existing vtkMRMLSliceLogic. | |
| appLogic = slicer.app.applicationLogic() | |
| collectionOfSliceLogics = appLogic.GetSliceLogics() | |
| numSliceLogics = collectionOfSliceLogics.GetNumberOfItems() | |
| print(f"SliceLogic was{'' if numSliceLogics else ' NOT'} found in ApplicationLogic") | |
| sliceLogic = collectionOfSliceLogics.GetItemAsObject(0) | |
| # Get a dental CT scan | |
| import SampleData | |
| volumeNode = SampleData.SampleDataLogic().downloadDentalSurgery()[1] | |
| # Define curve | |
| curveNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsCurveNode") | |
| curveNode.CreateDefaultDisplayNodes() | |
| # Add more curve points between control points than the default 10 | |
| curveNode.GetCurveGenerator().SetNumberOfPointsPerInterpolatingSegment(25) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-45.85526315789473, -104.59210526315789, 74.67105263157896)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-50.9078947368421, -90.06578947368418, 66.4605263157895)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-62.27631578947368, -78.06578947368419, 60.7763157894737)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-71.86705891666716, -58.04403581456746, 57.84679891116521)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-74.73084356325877, -48.67611043794342, 57.00664267528636)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-88.17105263157895, -35.75, 55.092105263157904)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-99.53947368421052, -35.75, 55.092105263157904)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-107.75, -43.96052631578948, 55.092105263157904)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-112.80263157894736, -59.118421052631575, 56.355263157894754)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-115.32894736842104, -73.01315789473684, 60.144736842105274)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-125.43421052631578, -83.74999999999999, 60.7763157894737)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-132.3815789473684, -91.96052631578947, 63.934210526315795)) | |
| curveNode.AddControlPoint(vtk.vtkVector3d(-137.43421052631578, -103.96052631578947, 67.72368421052633)) | |
| fieldOfView = [40.0, 40.0] | |
| outputSpacing = [0.5, 0.5, 1.0] | |
| straighteningTransformNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTransformNode", "Straightening transform") | |
| generalizedReformatLogic.ComputeStraighteningTransform(straighteningTransformNode, curveNode, fieldOfView, outputSpacing[2]) | |
| straightenedVolume = slicer.modules.volumes.logic().CloneVolume(volumeNode, volumeNode.GetName() + " straightened") | |
| generalizedReformatLogic.StraightenVolume(straightenedVolume, volumeNode, outputSpacing, straighteningTransformNode) | |
| panoramicVolume = slicer.modules.volumes.logic().CloneVolume(straightenedVolume, straightenedVolume.GetName() + " panoramic") | |
| generalizedReformatLogic.ProjectVolume(panoramicVolume, straightenedVolume) | |
| slicer.util.setSliceViewerLayers(background=straightenedVolume, fit=True, rotateToVolumePlane=True) | |
| print("Test finished") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment