How do you change the slice thickness?
Thick slab reconstruction and maximum/minimum intensity volume projections
This way does not work anymore…
How do you change the slice thickness?
This way does not work anymore…
I was trying to understand Slab Reconstruction by following New feature: Thick slab reconstruction from slice controllers and views and the code snipper provided above. I am not sure how to proceed as I am still learning the ins and outs of 3D Slicer. Below are what I tried and found.
The code snippet from the script repository doesn’t work for me either. The thickness value (top right corner of axis view) nor the spacings between the two red lines (in the coronal and sagittal views) change.
When checking the SlabNumberOfSlices and SlabSliceSpacingFraction using reslice.GetSlabNumberOfSlices() and reslice.GetSlabSliceSpacingFraction(), the previous set values have reverted back to the original values.
>>> # Code snippet from script respository
>>> sliceNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSliceNodeRed")
>>> appLogic = slicer.app.applicationLogic()
>>> sliceLogic = appLogic.GetSliceLogic(sliceNode)
>>> sliceLayerLogic = sliceLogic.GetBackgroundLayer()
>>> reslice = sliceLayerLogic.GetReslice()
>>> reslice.SetSlabModeToMean()
>>> reslice.GetSlabNumberOfSlices() # PRE - checking
1
>>> reslice.GetSlabSliceSpacingFraction() # PRE - checking
0.30000001192093007
>>> reslice.SetSlabNumberOfSlices(10) # mean of 10 slices will computed
>>> reslice.SetSlabSliceSpacingFraction(0.3) # spacing between each slice is 0.3 pixel (total 10 * 0.3 = 3 pixel neighborhood)
>>>
>>>
>>>
>>> reslice.GetSlabNumberOfSlices() # POST - checking to make sure the property changed
10
>>> reslice.GetSlabSliceSpacingFraction() # POST - checking to make sure the property changed
0.3
>>> sliceNode.Modified()
>>>
>>>
>>>
>>> reslice.GetSlabNumberOfSlices() # Reverted back after running Modified()
1
>>> reslice.GetSlabSliceSpacingFraction() # Reverted back after running Modified()
0.30000001192093007
However, this code snippet below worked and I can see the thickness value (top-right of axis view) and the spacing between the two red lines increase.
>>> sliceNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSliceNodeRed")
>>> sliceNode.SetSlabReconstructionType(slicer.vtkMRMLSliceNode().GetSlabReconstructionType())
>>> sliceNode.SetSlabReconstructionThickness(10)
>>> sliceNode.GetSlabReconstructionThickness()
10.0
reslice.Update(), and reslice.update() but the view did not update.vtkmodules.vtkImagingCore.vtkImageReslice objects.void vtkMRMLSliceLogic::UpdateSliceNode but am not sure how to call it from the Python API.# `sw_vers` output
ProductName: macOS
ProductVersion: 26.4.1
BuildVersion: 25E253
# `Slicer --version` output
Slicer 5.10.0
@ddii is correct that the example no longer works. The reason and solution are laid out in 2D MIP (maximum intensity projection) not works in Slicer 5.6.1.