Skip to content

Commit

Permalink
ENH: Add option to OrthovoltageDoseEngine to erase dose outside segment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunderlandkyl authored and Mikhail Polkovnikov committed Aug 10, 2022
1 parent 408b2ec commit 0294eae
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ExternalBeamPlanning/Widgets/Python/OrthovoltageDoseEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from DoseEngines import AbstractScriptedDoseEngine
from DoseEngines import OrthovoltageDoseEngineUtil
from DoseEngines import EGSnrcUtil
from SegmentEditorEffects import SegmentEditorMaskVolumeEffect

#------------------------------------------------------------------------------
#
Expand Down Expand Up @@ -223,6 +224,10 @@ def defineBeamParameters(self):
"Z in the BEAMnrc run where the phase space source was scored (cm).\n\
Only needed if DBS is enabled.", 20)

self.scriptedEngine.addBeamParameterLineEdit(
"Orthovoltage dose", "EraseOutsideSegment", "Erase outside segment:",
"If specified, causes the dose volume to be erased outside of the segment with the specified name.", "")

#------------------------------------------------------------------------------
#TODO: Add a path parameter type using the CTK path selector that saves the selections to Application Settings
def savePathsInApplicationSettings(self, beamNode):
Expand Down Expand Up @@ -501,5 +506,22 @@ def calculateDoseUsingEngine(self, beamNode, resultDoseVolumeNode):
logging.info( 'Result dose volume for beam ' + beamNode.GetName() + ' successfully loaded.\n'
+ ' Dose range: ({:.4f}-{:.4f})'.format(accumulate.GetMin()[0],accumulate.GetMax()[0]) )

# Erase dose outside of the specified segment
maskSegmentId = ""
maskSegmentName = self.scriptedEngine.parameter(beamNode, "EraseOutsideSegment")
segmentationNode = parentPlan.GetSegmentationNode()
if segmentationNode is None or segmentationNode.GetSegmentation() is None:
logging.error("Could not mask dose volume. Invalid segmentation.")
elif maskSegmentName != "":
maskSegmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(maskSegmentName)

if maskSegmentId != "":
logging.info(f"Erasing dose outside of {maskSegmentName}[ID: {maskSegmentId}]")
operationMode = "FILL_OUTSIDE"
fillValues = [0]
SegmentEditorMaskVolumeEffect.maskVolumeWithSegment(segmentationNode, maskSegmentId, operationMode, fillValues, resultDoseVolumeNode, resultDoseVolumeNode)
else:
logging.error("Could not mask dose volume. Invalid segment id.")

# Successful execution, no error message
return ""

0 comments on commit 0294eae

Please sign in to comment.