Skip to content

Commit 0294eae

Browse files
SunderlandkylMikhail Polkovnikov
authored andcommitted
ENH: Add option to OrthovoltageDoseEngine to erase dose outside segment
1 parent 408b2ec commit 0294eae

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ExternalBeamPlanning/Widgets/Python/OrthovoltageDoseEngine.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from DoseEngines import AbstractScriptedDoseEngine
66
from DoseEngines import OrthovoltageDoseEngineUtil
77
from DoseEngines import EGSnrcUtil
8+
from SegmentEditorEffects import SegmentEditorMaskVolumeEffect
89

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

227+
self.scriptedEngine.addBeamParameterLineEdit(
228+
"Orthovoltage dose", "EraseOutsideSegment", "Erase outside segment:",
229+
"If specified, causes the dose volume to be erased outside of the segment with the specified name.", "")
230+
226231
#------------------------------------------------------------------------------
227232
#TODO: Add a path parameter type using the CTK path selector that saves the selections to Application Settings
228233
def savePathsInApplicationSettings(self, beamNode):
@@ -501,5 +506,22 @@ def calculateDoseUsingEngine(self, beamNode, resultDoseVolumeNode):
501506
logging.info( 'Result dose volume for beam ' + beamNode.GetName() + ' successfully loaded.\n'
502507
+ ' Dose range: ({:.4f}-{:.4f})'.format(accumulate.GetMin()[0],accumulate.GetMax()[0]) )
503508

509+
# Erase dose outside of the specified segment
510+
maskSegmentId = ""
511+
maskSegmentName = self.scriptedEngine.parameter(beamNode, "EraseOutsideSegment")
512+
segmentationNode = parentPlan.GetSegmentationNode()
513+
if segmentationNode is None or segmentationNode.GetSegmentation() is None:
514+
logging.error("Could not mask dose volume. Invalid segmentation.")
515+
elif maskSegmentName != "":
516+
maskSegmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(maskSegmentName)
517+
518+
if maskSegmentId != "":
519+
logging.info(f"Erasing dose outside of {maskSegmentName}[ID: {maskSegmentId}]")
520+
operationMode = "FILL_OUTSIDE"
521+
fillValues = [0]
522+
SegmentEditorMaskVolumeEffect.maskVolumeWithSegment(segmentationNode, maskSegmentId, operationMode, fillValues, resultDoseVolumeNode, resultDoseVolumeNode)
523+
else:
524+
logging.error("Could not mask dose volume. Invalid segment id.")
525+
504526
# Successful execution, no error message
505527
return ""

0 commit comments

Comments
 (0)