|
5 | 5 | from DoseEngines import AbstractScriptedDoseEngine
|
6 | 6 | from DoseEngines import OrthovoltageDoseEngineUtil
|
7 | 7 | from DoseEngines import EGSnrcUtil
|
| 8 | +from SegmentEditorEffects import SegmentEditorMaskVolumeEffect |
8 | 9 |
|
9 | 10 | #------------------------------------------------------------------------------
|
10 | 11 | #
|
@@ -223,6 +224,10 @@ def defineBeamParameters(self):
|
223 | 224 | "Z in the BEAMnrc run where the phase space source was scored (cm).\n\
|
224 | 225 | Only needed if DBS is enabled.", 20)
|
225 | 226 |
|
| 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 | + |
226 | 231 | #------------------------------------------------------------------------------
|
227 | 232 | #TODO: Add a path parameter type using the CTK path selector that saves the selections to Application Settings
|
228 | 233 | def savePathsInApplicationSettings(self, beamNode):
|
@@ -501,5 +506,22 @@ def calculateDoseUsingEngine(self, beamNode, resultDoseVolumeNode):
|
501 | 506 | logging.info( 'Result dose volume for beam ' + beamNode.GetName() + ' successfully loaded.\n'
|
502 | 507 | + ' Dose range: ({:.4f}-{:.4f})'.format(accumulate.GetMin()[0],accumulate.GetMax()[0]) )
|
503 | 508 |
|
| 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 | + |
504 | 526 | # Successful execution, no error message
|
505 | 527 | return ""
|
0 commit comments