Skip to content

SlicerRT allows calling CalculateDose without specific target that makes pyradplan crash #10

Description

@ferdymercury

Bug Description

In SlicerRT, one can use a isocenter defined by hand, and you do not need to specify a target contour / volume. Then if you calculateDose, pyradplan crashes with:

ValueError: need at least one array to concatenate
"/opt/Slicer-5.13.0-2026-06-30-linux-amd64/slicer.org/Extensions-34833/SlicerRT/lib/Slicer-5.13/qt-scripted-modules/DoseEngines/pyRadPlanEngine.py" : clone: Failed to call mandatory calculateDoseUsingEngine method! If it is implemented, please see python output for errors.
"/opt/Slicer-5.13.0-2026-06-30-linux-amd64/slicer.org/Extensions-34833/SlicerRT/lib/Slicer-5.13/qt-scripted-modules/DoseEngines/pyRadPlanEngine.py" : Calling calculateDoseUsingEngine from Python dose engine
Traceback (most recent call last):
  File "/opt/Slicer-5.13.0-2026-06-30-linux-amd64/slicer.org/Extensions-34833/SlicerRT/lib/Slicer-5.13/qt-scripted-modules/DoseEngines/pyRadPlanEngine.py", line 80, in calculateDoseUsingEngine
    stf = generate_stf(ct, cst, pln)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Slicer-5.13.0-2026-06-30-linux-amd64/lib/Python/lib/python3.12/site-packages/pyRadPlan/stf/_generate_stf.py", line 24, in generate_stf
    return validate_stf(stfgen.generate(ct, cst))
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Slicer-5.13.0-2026-06-30-linux-amd64/lib/Python/lib/python3.12/site-packages/pyRadPlan/stf/generators/_base.py", line 82, in generate
    self._initialize_patient_geometry()
  File "/opt/Slicer-5.13.0-2026-06-30-linux-amd64/lib/Python/lib/python3.12/site-packages/pyRadPlan/stf/generators/_base.py", line 123, in _initialize_patient_geometry
    self._target_mask = self._cst.target_union_mask()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Slicer-5.13.0-2026-06-30-linux-amd64/lib/Python/lib/python3.12/site-packages/pyRadPlan/cst/_cst.py", line 175, in target_union_mask
    target_indices = self.target_union_voxels(order="numpy")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Slicer-5.13.0-2026-06-30-linux-amd64/lib/Python/lib/python3.12/site-packages/pyRadPlan/cst/_cst.py", line 170, in target_union_voxels
    return np.unique(np.concatenate(target_indices))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to Reproduce

  • Import Protons_01.zip into SlicerRT
  • go to external beams module,
  • click on Ion Plan
  • then select active RT plan,
  • use CT grid as dose output new volume
  • click on Calculate Dose --> no output is given.

Expected Behavior

Ideally, pyradplan should just print a warning that target_mask is empty and continue the calculation since it shouldn't be mandatory.

Actual Behavior

No output dose, silent crash of pyradplan.

Environment

Slicer 5.13.0 nightly from Jul-30-2026

Additional Context

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions