cutright / DVH-Analytics

A DICOM Database Application for Radiation Oncology
Other
83 stars 30 forks source link

TPSs that work with DVHA #36

Open cutright opened 4 years ago

cutright commented 4 years ago

I just wanted to create a common location to document known TPS and versions that work with DVHA. If you've used DVHA and don't see your TPS and version on here, kindly add a comment. Below is a list off the top of my head.

DVHmonkey commented 4 years ago

Elekta Xio 4.34.02

The above version is about 10 years old.

For context, my facility is a particle beam therapy treatment centre. Our TPS is customized for particle beams (apparently back there were few TPSs that could handle particle beams). According to the medical physicists here, that customization meant that they couldn't export plans directly to DICOM; they created dummy photon beams with the same dose distributions and exported those.

Newer versions probably have updated DICOM export capabilities.

cutright commented 4 years ago

I plan to add Brachytherapy support by v0.8.0 (if it doesn't work already?). The previous web-based version worked, but I haven't tested since the wxPython rewrite.

cutright commented 4 years ago

The latest commit now supports brachytherapy plans from Eclipse 11 (or is it called Brachy Vision? Obviously I’m not a brachy guy).

cutright commented 4 years ago

Functionality needs to be added to ignore dose inside applicators/needles for brachytherapy.

albertelonjobs commented 4 years ago

What about the brachy plans on Oncentra? Could it be supported in the future?

cutright commented 4 years ago

Give it a shot. I tried it a couple years ago on a previous version and it worked OK. I only had to change one line of code to get Brachy Vision to work, so if it fails just send me terminal output.

cutright commented 4 years ago

On a related note... I'm certain there are some reasonably achievable add-ons to DVHA that brachy users would be interested in. I have a couple brachytherapy physicists in my clinic that are interested and plan to start using DVHA soon... but I am not clinically involved enough with HDR to know what sort of data is interesting.

Let me know what's missing?

albertelonjobs commented 4 years ago

I tried to import an Oncentra brachy plan. But the program was frozen. Here is the plan. It might be useful to use DVHA to evaluate a new plan by comparing with the historical plans in the database. But the difficulty of a plan depends not just on the distances between the CTV and the OARs. It also depends on the limitation of the applicator placement and relative position between the applicator, the target, and the OARs.

OncentraBrachyPlan.zip

cutright commented 4 years ago

I did not observe a freeze. I was able to import these files, although it's not acknowledging the PTV to calculate PTV distances. I realize there's no "PTV" here, but if I label it as one, it should to the extra calculations... which should be a work around until I add GTV and CTV distance calculation funtionality.

albertelonjobs commented 4 years ago

Right. There is no PTV, which is typical for brachytherapy because there is no setup uncertainties. What you see is what you get. This is one of the advantages of brachytherapy. I'm wondering if the system can be tricked by considering a brachy CTV as a PTV for external beams. I was able to import the files today too. I don't know what caused the freeze of the program. Anyway, it's working now. I'm very excited.

albertelonjobs commented 4 years ago

I tried to trick the system by defining the CTV as an alias of PTV. The plan, RT structure file, and the dose file have been imported with no error or warning messages. But the dose and the structure volume were all empty when I checked it in the database administrator.

yroussakis commented 4 years ago

Hello Dan, thanks for the DVHAnalytics project you share with us! I just came across it and tried to use it but was not able to load data from Monaco v. 5.11.03. I am sending you some simple phantom data that I created to see if their is an actual issue with the specific Monaco version or if it something else that I did wrong. I also have a print screen of the error message I got which will hopefully help.

Monaco5_11_03_data.zip

cutright commented 4 years ago

Thanks for sharing. Should be an easy fix. It brings up two issues:

I'll push a fix to a dev branch today. Based on your screen shot, I'm guessing you installed via pip?

yroussakis commented 4 years ago

Thanks for the prompt reply! Brilliant, looking forward for the fix then. Yes, I installed via pip.

cutright commented 4 years ago

The original issue is fixed, but I'm running into another issue with your files at the moment. I believe the issue stems from having to use the force flag in pydicom.read_file() for these Monaco files.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/dvha/models/import_dicom.py", line 1416, in import_target
    StudyImporter(*parameters)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/dvha/models/import_dicom.py", line 1124, in __init__
    self.run()
  File "/Users/ninja/PycharmProjects/DVH-Analytics/dvha/models/import_dicom.py", line 1186, in run
    dvh_row = parsed_data.get_dvh_row(roi_key)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/dvha/db/dicom_parser.py", line 417, in get_dvh_row
    callback=self.send_dvh_progress)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/dicompylercore/dvhcalc.py", line 75, in get_dvh
    callback)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/dicompylercore/dvhcalc.py", line 125, in calculate_dvh
    dd = dose.GetDoseData()
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/dicompylercore/dicomparser.py", line 768, in GetDoseData
    data['dosemax'] = float(self.ds.pixel_array.max())
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 1623, in pixel_array
    self.convert_pixel_data()
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 1332, in convert_pixel_data
    self._convert_pixel_data_without_handler()
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 1442, in _convert_pixel_data_without_handler
    raise last_exception
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 1422, in _convert_pixel_data_without_handler
    self._do_pixel_data_conversion(handler)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 1449, in _do_pixel_data_conversion
    arr = handler.get_pixeldata(self)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/pixel_data_handlers/numpy_handler.py", line 280, in get_pixeldata
    pixel_data = getattr(ds, px_keyword[0])
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 776, in __getattr__
    return self[tag].value
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/dataset.py", line 866, in __getitem__
    data_elem)
  File "/Users/ninja/PycharmProjects/DVH-Analytics/venv/lib/python3.6/site-packages/pydicom/filereader.py", line 964, in read_deferred_data_element
    raise IOError("Deferred read -- original filename not stored. "
OSError: Deferred read -- original filename not stored. Cannot re-open

Original issue based on the commit just mentioned in this thread.

Before:

from dvha.db.dicom_parser import DICOM_Parser
ds = DICOM_Parser('CATPHAN_PlanVMAT1.dcm', 'CATPHAN_StrctrSets.dcm', 'CATPHAN_PlanVMAT1_Dose.dcm')
ds.tps_software_version
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/ninja/PycharmProjects/DVH-Analytics/dvha/db/dicom_parser.py", line 648, in tps_software_version
    return ','.join(self.get_attribute('plan', 'SoftwareVersions'))
TypeError: can only join an iterable

After:

from dvha.db.dicom_parser import DICOM_Parser
ds = DICOM_Parser('CATPHAN_PlanVMAT1.dcm', 'CATPHAN_StrctrSets.dcm', 'CATPHAN_PlanVMAT1_Dose.dcm')
ds.tps_software_version
'5.11.03'
cutright commented 4 years ago

@bastula If I read my RT Dose with pydicom.read_file() rather than dicompylerParser(self.dose_file).ds, the issue is resolved.

Edit: sorry, I call this up top: from dicompylercore.dicomparser import DicomParser as dicompylerParser

bastula commented 4 years ago

@Cutright It's probably due the force tag that I set to true in dicompyler-core. If you pass a pydicom dataset instead of a filename, it will bypass that part afaik.

cutright commented 4 years ago

I also use the force tag. So there might be something else going on?

if self.dose_file:
    if self.dose_sum_file is None:
        # self.rt_data['dose'] = dicompylerParser(self.dose_file).ds
        # The above line may lead to OSError: Deferred read -- original filename not stored. Cannot re-open
        # switching back to pydicom.read_file()
        self.rt_data['dose'] = pydicom.read_file(self.dose_file, force=True)
    else:
        self.rt_data['dose'] = pydicom.read_file(self.dose_sum_file, force=True)
cutright commented 4 years ago

@yroussakis Can you give this a shot? pip install dvha==0.7.5.dev1 --upgrade

Just note that the figure export feature is still in development, I think all that's left with it is html export. The plan evaluation feature is not fully developed either. It has some GUI elements, but it is not functional.

cutright commented 4 years ago

@yroussakis Oh, I also wanted to ask if your plan was really a VMAT (as is labeled in the filename)? DVHA did not find a BeamLimitingDevicePositionSequence, so the MLC stats were not calculated. If they are VMAT beams, I need to look into this.

yroussakis commented 4 years ago

@cutright Yes, it is a VMAT plan (1 dual arc). I just updated as you suggested and it looks to have been imported OK! I will check the stats and compare with Monaco in order to confirm their are no issues that I did not initially spot. Thank you very much for this! Would you like me to generate any more data from Monaco that might be helpful to you?

cutright commented 4 years ago

Oh man... I forgot about Monaco's dual arcs! I'll have to poke around, my guess is there is just another DICOM sequence to iterate through. In the meantime, you won't be able to trend or model with MLC-based statistics. I'll see what I can do with the files you've already sent, and reach out it again once I think it's fixed.

yroussakis commented 4 years ago

OK, thank you very much!

bastula commented 4 years ago

I also use the force tag. So there might be something else going on?

if self.dose_file:
    if self.dose_sum_file is None:
        # self.rt_data['dose'] = dicompylerParser(self.dose_file).ds
        # The above line may lead to OSError: Deferred read -- original filename not stored. Cannot re-open
        # switching back to pydicom.read_file()
        self.rt_data['dose'] = pydicom.read_file(self.dose_file, force=True)
    else:
        self.rt_data['dose'] = pydicom.read_file(self.dose_sum_file, force=True)

Now I'm looking at it and in order to speed up processing of DICOM tags, it will defer the read. But if you want to extract dose max, you need to access the pixel array, which is at the end of the DICOM file. Are you using the latest version from source or 0.5.5?

cutright commented 4 years ago

0.5.5

bastula commented 4 years ago

Ok, I did some digging and this is the same old issue we always face. https://stackoverflow.com/a/44532544/74123

CMS/Elekta always exports DICOM files without a proper TransferSyntaxHeader. If you manually set the TransferSyntaxHeader, it works properly. pydicom maintainers feel that this belongs in user code. In our case, I think it belongs in dicompyler/DVHA but not dicompyler-core as I have fixed it in user code that some of my other projects that utilize dicompyler-core.

In your code, you can probably do the following before accessing the ds object:

try:
    ds.pixel_array
except AttributeError:
    from pydicom.uid import ImplicitVRLittleEndian
    ds.file_meta.TransferSyntaxUID = ImplicitVRLittleEndian

where ds is your dataset. Then assign that to your dictionary.

cutright commented 4 years ago

Oh man, this again?! Hahahaha. Thanks @bastula!

cutright commented 4 years ago

Good news for brachy users!

Prior to DVHA v0.8.3, DVH calculations used a max dose bin based on the maximum dose found in the dose grid. Turns out this caused massive memory usage for plans that had non-realistic doses (on the order of kGy). This affects some external beam plans in very few cases, but likely all brachytherapy plans. I just tested on 8 BrachyVision plans with much better import times.

If you observed any plans taking several minutes to import, this bug may have been the reason. DVHA v0.8.3 will come out later this week and let you set a cap on the histogram in Gy or %Rx (defaults are 500Gy or 300% Rx). Plans that suffered this issue dropped from 45min import time to <12 sec.

cutright commented 4 years ago

We can add CORVUS 6.3 to the list! No changes needed.

Although, it looks like DVHA uses DICOM-RT Plan's PatientSetupSequence[0].PatientPosition which wasn't populated by CORVUS. The import screen raised a red error with no text, but you can check the plan anyway. I got a non-HFS warning, but the DVHs appear to be correct since ImageOrientationPatient is HFS -> [1, 0, 0, 0, 1, 0] in these plans.

lharzee commented 4 years ago

Hi What about Precision 2.0 from Accuray? I try to tuse DVH Analytics to analyse some patients but i don't know import the RTDOSE files. I suppose that some tags are missing but i don't wich ones? Can yoz help me?

Thanks

cutright commented 4 years ago

Hi @lharzee , I have not been able to try on Precision yet. There's a pretty good chance it will work though, can you give me a little more information? You can't import only RT-Dose, did you try importing Dose, Plan and Structure at the same time?

lharzee commented 4 years ago

Hi

I have try again to import the data in your program. in fact, it depends on the version of Multiplan/Precision used. For the old patients, it doesn't work because some information in the RT Dose is missing. Sans titre Do you have a tool to correct this problem very quickly because I have a lot of old patients to study? For the recent version of Precision, it works perfectly.

Ludovic

cutright commented 4 years ago

OK, that's quite helpful actually. I've created a new issue here and pushed a v0.8.8dev branch with a potential fix. If you don't mind, post any other comments in the linked issue? And let me know if you have trouble switching branches.

cutright commented 3 years ago

We can add VariSeed 9.0 to the list, worked with no issues.