Thick slab reconstruction and maximum/minimum intensity volume projections

How do you change the slice thickness?

Thick slab reconstruction and maximum/minimum intensity volume projections

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.

Reproducing the Code Snippet

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

What Kind of Worked

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

Troubleshooting Attempts

  • 3D Slicer uses MVC architecture pattern (src) and the code snippet was changing the logic (controller) and the viewer is not updated. Thus, I have tried running reslice.Update(), and reslice.update() but the view did not update.
  • I tried looking into the API documentation but cannot find any information on the update methods for vtkmodules.vtkImagingCore.vtkImageReslice objects.
  • Thus, I looked into the Doxygen-style documentation and found void vtkMRMLSliceLogic::UpdateSliceNode but am not sure how to call it from the Python API.
  • I tried digging further into this thread but it neither helped me understand how the Slab Reconstruction works nor provided any hints to where to find the Python API.

Environment

# `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.