The use of different rangeshifters and accompanying beam data libraries in one plan

For different range shifters (i.e. no, 2cm, 3cm, and 5cm) our clinic has created BDL files for mcsquare that I would like to use in OpenTPS. The bdl field in DoseCalculationConfig takes one value right?

I wish to create a plan in OpenTPS with the same range shifter combination. In 2 beam directions, a range shifter is applied, in the other 2 no rangeshifter. Is it possible to make such a plan?

Hi Wens,

Do you mean that you have a different BDL for each range shifter? As far as I understand, typically all range shifters are included in the same BDL file. In this case, you can have a list of rangeShifters and add them to your plan like that:

# read the BDL
bdl = mcsquareIO.readBDL(DoseCalculationConfig().bdlFile)

# get rangeshifter 1
rs_1 = bdl.rangeShifters[0]

# get rangeshifter 2
rs_2 = bdl.rangeShifters[1]

# alternatively you can define the range shifter yourself if you do not have a BDL ready to read or it causes you problems. 
rs_1 = RangeShifter(material='Lexan', density=1.217, WET=40.3)
rs_1.ID = 'RS40'
rs_1.type = 'binary'

# same for rs_2

#add to your planDesign, for instance: 4 beams with rs_1 in beam1, no range shifter in beam2, rs_2 in beam3 and beam4
planDesign.rangeShifters = [rs_1,  None, rs_2, rs_2]

However, right now you can perform the beamlet calculation and plan optimisation but there is a small error in saving the DICOM RT plan that we are trying to fix, so you should comment the line where you use the function writeRTPlan(plan, output_path )

Yes I read on the mc square website “If multiple range shifters are used, it is possible to specify them all in one BDL file depending on the version of MCsquare.”

However, it is not clear to me how to combine them in 1 BDL file and I have only been provided seperate BDL files for each range shifter. Do you have documentation on how to combine it to a single BDL file? I would like to include a total of 3 rangeshifters.

Hi Wens,

To combine them in the same file, you just copy paste the information sequentially. For instance, I did a copy of the range shifter provided in the BDL used by default by OpenTPS (located at /openTPS/opentps/opentps_core/opentps/core/processing/doseCalculation/MCsquare/BDL/BDL_default_DN_RangeShifter.txt), see the attached image. Then you can use the range shifters as described in my previous message:

# get rangeshifter 1
rs_1 = bdl.rangeShifters[0]

# get rangeshifter 2
rs_2 = bdl.rangeShifters[1]

Let me know if that works!

Ana

Hi Ana,

Thank you for your very swift reply!
I have tried what you suggested. The following error message occurred.

 ERROR: File "Materials/Lexan111/Material_Properties.dat" is missing! 

I have a RS with material ID 66 (Lexan), the dose calculation works if only one RS, with ID 66 is provided in the BDL

For the same plan, without configuring a new range shifter in the plan object, but with an extra rangeshifter in the BDL (material ID 13), the error above occurs.

Perhaps I’m not understanding something correctly?
My BDL looks as follows (excluding the data about the double gaussian)

Range Shifter parameters
RS_ID = RS3cm # ID of the range shifter as defined in the plan
RS_type = binary # analog = variable thickness (sliding wedges, or water column); binary = different thickness materials that can be moved in or out
RS_material = 66 # MCsquare material ID
RS_density = 1.21 # physical density (in g/cm3)
RS_WET = 34.29 # water equivalent thickness (in mm)

Range Shifter parameters
RS_ID = RSnone # ID of the range shifter as defined in the plan
RS_type = binary # analog = variable thickness (sliding wedges, or water column); binary = different thickness materials that can be moved in or out
RS_material = 13 # MCsquare material ID
RS_density = 0.001 # physical density (in g/cm3)
RS_WET = 0.0 # water equivalent thickness (in mm)

Sorry for the inconvenience!

Kind regards,

Wens

Hi Wens,

Sorry, many of us were on holiday these days and we did not have time to look into it. Did you solve it? The error looks very weird to us, it should look for Lexan only and not Lexan111. Can you look at your material file and confirm that ID 66 corresponds to Lexan? Also, for my curiosity, why do you want to use a range shifter made of air?

Hi Ana,

Thank you for your reply. ID 66 indeed corresponds to lexan. The air was a place holder for no range shifter.

Some other part of opentps I also do not understand, after calculating dose deposition matrices, before optimisation.
When I try to load the beamlet, I get pickle error invalid loadkey ‘#’ when I use the load beamlet function.
I tried with numpy but I did not quite understand how the matrices are stored. The matrix looks very big, more than what I would expect in full CT dimensions in CSC/CSR or COO representation. Is there documentation on what is stored in these binary files for each scenario?

Kind regards,

Wens

Hi Wens,

It is normal that the beamlets matrices are very big, since they are 2D matrices with a number of columns equal to the number of beamlets, and each beamlet has as many voxels as your CT. So it is like the size of the CT (flatten into 1D array) times the number of beamlets. Indeed these matrices are also in sparse format, because there are many zero values, so we do it to save time.

We cannot answer to your pickle error unless you give us more information. Can you provide us the exact code you are tring to run? and the extension of the files you are trying to load? If you are still struggeling we could eventually do a short meeting with you.

Best,
Ana