Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RayStation 10B] Export patient as .dcm via scripting #3

Open
prerakmody opened this issue Jan 10, 2023 · 1 comment
Open

[RayStation 10B] Export patient as .dcm via scripting #3

prerakmody opened this issue Jan 10, 2023 · 1 comment

Comments

@prerakmody
Copy link

Hi,
Do you know if there is a way to export a RS patient (e.g. connect.get_current("Patient")) as DICOM files to a path? I am able to do so via the UI, but need a scriptable version. Recording the actions gives me an "Unscriptable Action" error.

image

I have looked at the following options

  • patient.ExportPatient --> does .rsback
  • db.BackupPatient --> does .rsbak
  • case.ScriptableDicomExport (not sure exactly how to use it)
@KaleyWhite
Copy link
Owner

Disclaimer: This may not be 100 percent correct since I no longer work at the clinic where I had access to RayStation. All of this is from memory and this repo.

The case.ScriptableDicomExport method is the only way I know of. Use the state tree (import statetree; statetree.runStateTree()) for more information, but this is my understanding of the parameters:

  • ExportFolderPath: Directory to export .dcm files to
  • Examinations: List of names of exams to export
  • BeamSets: List of IDs of beam sets to export. Each beam set is exported as an RTPLAN DICOM file.
  • PhysicalBeamSetDoseForBeamSets: List of IDs of beam sets for which to export dose. Each beam set dose is exported as an RTDOSE DICOM file.
  • PhysicalBeamDosesForBeamSets: List of IDs of beam sets whose beam doses to export. Each beam dose is exported as an RTDOSE DICOM file.
  • RtStructureSetsForExaminations: List of names of exams whose structure sets to export. Each structure set is exported as an RTSTRUCT DICOM file.
  • RtStructureSetsReferencedFromBeamSets: List of IDs of beam sets whose structure sets to export. Each beam set's structure set is exported as an RTSTRUCT DICOM file.
    To export all of these DICOM files for the open patient (connect.get_current('Patient')), you can do the following:
for case in patient.Cases:
    exam_names = [exam.Name for exam in case.Examinations]
    beam_set_ids = [beam_set.BeamSetIdentifier() for plan in case.TreatmentPlans for beam_set in plan.BeamSets]
    case.ScriptableDicomExport(ExportFolderPath='path/to/export/to', Examinations=exam_names, BeamSets=beam_set_ids, PhysicalBeamSetDoseForBeamSets=beam_set_ids, PhysicalBeamDosesForBeamSets=beam_set_ids, RtStructureSetsForExaminations=exam_names, RtStructureSetsReferencedFromBeamSets=beam_set_ids)

I have a few examples of ScriptableDicomExport in this repo.

RayStation is weird in that a single plan can have multiple beam sets. To my knowledge, no other TPS has the concept of a "beam set."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants