Skip to content

Commit

Permalink
PERF: Remove use of Scripted CLI and threshold directly in VRG module
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar authored and jcfr committed Jul 11, 2024
1 parent 35e075d commit 7be5d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 0 additions & 10 deletions AutoscoperM/AutoscoperM.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,16 +1264,6 @@ def generateVRGForCameras(
:param filename: filename of the VRG
"""
self.createPathsIfNotExists(outputDir)
# Apply a thresh of 0 to the volume to remove air from the volume
thresholdScalarVolume = slicer.modules.thresholdscalarvolume
parameters = {
"InputVolume": volumeNode.GetID(),
"OutputVolume": volumeNode.GetID(),
"ThresholdValue": 0,
"ThresholdType": "Below",
"Lower": 0,
}
slicer.cli.runSync(thresholdScalarVolume, None, parameters)

# write a temporary volume to disk
volumeFileName = "AutoscoperM_VRG_GEN_TEMP.mhd"
Expand Down
14 changes: 12 additions & 2 deletions VirtualRadiographGeneration/VirtualRadiographGeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@ def generateVRG(
:param height: Height of the output image
"""

# Remove air and low-density materials by applying a threshold to the volume image data
# In CT scans, air has a value of -1000 HU and other low-density materials like fat range from -60 to -120 HU
thresholder = vtk.vtkImageThreshold()
thresholder.ThresholdByLower(0)
thresholder.ReplaceInOn()
thresholder.SetInValue(0)
thresholder.SetInputData(volumeImageData)
thresholder.Update()
thresholdedImageData = thresholder.GetOutput()

# find the min and max scalar values
hist = vtk.vtkImageHistogramStatistics()
hist.SetInputData(volumeImageData)
hist.SetInputData(thresholdedImageData)
hist.Update()
minVal = hist.GetMinimum()
maxVal = hist.GetMaximum()
Expand All @@ -46,7 +56,7 @@ def generateVRG(

# create the volume mapper
volumeMapper = vtk.vtkGPUVolumeRayCastMapper()
volumeMapper.SetInputData(volumeImageData)
volumeMapper.SetInputData(thresholdedImageData)
volumeMapper.SetBlendModeToComposite()
volumeMapper.SetBlendModeToComposite()
volumeMapper.SetUseJittering(False)
Expand Down

0 comments on commit 7be5d19

Please sign in to comment.