pombreda / dicompyler

Automatically exported from code.google.com/p/dicompyler
0 stars 0 forks source link

RTDOSE file with no image crashes #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Some exported Brainlab RTDOSE files contain only DVH info, not a dose "image". 
This will cause DicomParser.GetImageData to crash.

Workaround:

    def GetImageData(self, window = None, level = None):
        """Return the image data from a DICOM file."""
        data = {}
        #BPT March 2011. Not every ds has an image
        if "PixelData" in self.ds:
            data['position'] = self.ds.ImagePositionPatient
            data['orientation'] = self.ds.ImageOrientationPatient
            data['pixelspacing'] = self.ds.PixelSpacing
            data['rows'] = self.ds.Rows
            data['columns'] = self.ds.Columns
            if 'PatientPosition' in self.ds:
                data['patientposition'] = self.ds.PatientPosition

This allows the data to load, but it does not compute the DVH. I'm not sure how 
prevalent this case will be, so I have no suggested further action at this time.

Probably most of these types of issues with "imperfect" data sets will vanish 
when an exception handler is implemented.

Original issue reported on code.google.com by bton...@gmail.com on 4 Mar 2011 at 8:10

GoogleCodeExporter commented 9 years ago
Thanks for reporting this bug.

Can you send an anonymized version of a DICOM file that has this issue?

I'm confused by you saying it has no "dose image". Do you mean that it doesn't 
have 3D dose data (which is called with pixel_array by pydicom using the RTdose 
file). It's unclear to me why GetImageData would be crashing if the dose data 
were missing (rather than e.g. GetDoseData). 

It would be great if you could package your fixes up as hg patches. 
Instructions are on the Helping wiki page 
http://code.google.com/p/dicompyler/wiki/Helping

Thanks again.
Roy

Original comment by roy.coding@gmail.com on 4 Mar 2011 at 9:08

GoogleCodeExporter commented 9 years ago
GetDoseData calls GetImageData
Off for the weekend, but will look at the hg patch instructions.

Original comment by bton...@gmail.com on 4 Mar 2011 at 9:28

GoogleCodeExporter commented 9 years ago
GetDoseData calls GetImageData, but GetImageData itself doesn't seem to do 
anything with the dose data, whereas GetDoseData does (calling pixel_array). So 
I'm surprised if GetImageData is the function causing the crash.

Original comment by roy.coding@gmail.com on 4 Mar 2011 at 10:19

GoogleCodeExporter commented 9 years ago
For whatever reason, the particular output from Brainlab put the PixelData in 
one file, and the DVH in another. I don't know how general this is, so I'm 
going to export more files and see what happens.

GetDoseData uses GetImageData to retrieve the 3D dose data -- the "PixelData" 
part of the file.  When GetDoseData tries to import the PixelData from the 
RTDOSE file which has no pixel data, it generates an exception for the first 
missing attribute (happens to be ImagePositionPatient"). 

The posted workaround leaves "data" as null, which still isn't right (it's in 
the other file)--but until I see if this is a general feature of Brainlab 
exports it's not worth worrying about.

Original comment by bton...@gmail.com on 7 Mar 2011 at 8:00

GoogleCodeExporter commented 9 years ago
DICOM allows you to put the dose grid and DVH data in separate files or 
together in one file. It is up to the vendor to decide which they will support. 
I was not aware of any vendor currently separating the files, but dicompyler 
ideally should support both cases.

I need to look into this more, but there may need to be a slight reworking of 
the internal code so that dicompyler knows that if it receives a RT Dose file, 
it may only contain DVH data and not contain a dose grid. Currently it handles 
the inverse situation: RT Dose with a dose grid w/o DVH data. I should also 
mention that it also supports RT Dose with a dose grid and DVH data.

To recap: 3 possibilities for RT Dose:
- RT Dose with only 3D Dose Grid (currently supported, DVH will be 
independently calculated by dicompyler in a future release)
- RT Dose with only DVH data (currently unsupported)
- RT Dose with 3D Dose Grid and DVH data (currently supported)

There is actually a 4th scenario, where the each slice of the dose grid is a 
separate file, but please see Issue 14 for more information about that.

Regarding GetImageData and GetDoseData, both the PixelArray probably will not 
be present, as well as any tags regarding the dose grid (image). So technically 
both methods will fail.

Regarding the exception handler, it is in the pipeline and should catch a lot 
of these type of errors.

Original comment by bastula on 7 Mar 2011 at 10:01

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 9aebd7522a8a.

Original comment by bastula on 11 May 2012 at 8:59