bastula / dicompyler

Extensible radiation therapy research platform and viewer for DICOM and DICOM RT
http://www.dicompyler.com
268 stars 100 forks source link

Missing "SliceLocation" #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Some exported data sets (Pinnacle and Brainlab) did not include the 
SliceLocation Tag, leading to program crash on input. Here is my workaround:

In dicomgui, near line 226 (DirectorySearchThread):

                            image = {}
                            image['id'] = dp.GetSOPInstanceUID()
                            image['filename'] = files[n]

                            #BPT-March 2011
                            #SliceLocation is not always present, so have a workaround ready
                            if "SliceLocation" in dp.ds:
                                image['slicelocation'] = dp.ds.SliceLocation
                            elif "ImagePositionPatient" in dp.ds:
                                #Take a slicelocation from ImagePosition z value
                                image['slicelocation']=dp.ds.ImagePositionPatient[2]
                            else:
                                #put something in there anyway
                                #FIX THIS WITH A SEQUENCE NUMBER
                                image['slicelocation']=1

                            image['imagenumber'] = dp.ds.InstanceNumber

And then later, in GetPatientData:

        # Sort the images based on Slice Location
        if self.patient.has_key('images'):
            #Check to see if image has SliceLocation defined. If not, use z axis position
            #BPT-March 2011
            #SliceLocation is not always present, so have a workaround ready
            snumber=1
            for image in self.patient['images']:
                if "SliceLocation" in image:
                        image.SliceLocation= image.SliceLocation #do nothing
                elif "ImagePositionPatient" in image:
                    #Take a slicelocation from ImagePosition z value
                    image.SliceLocation=image.ImagePositionPatient[2]
                else:
                    #put something in there anyway
                    #FIX THIS WITH A SEQUENCE NUMBER
                    image.SliceLocation=snumber
                    snumber=snumber+1
            #
            #

Original issue reported on code.google.com by bton...@gmail.com on 3 Mar 2011 at 9:15

GoogleCodeExporter commented 9 years ago
Thank you for catching this. Is it possible for you to send anonymized example 
data for us to test, after you have gotten it to load? You can either sent it 
to us via Dropbox or by email.

Thanks,

Adit

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

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

Original comment by bastula on 8 Mar 2011 at 3:51

GoogleCodeExporter commented 9 years ago
I have committed a fix that should address this issue. I tested this with 
dataset in which I removed the SliceLocation tag and it worked correctly.

I did not add a case if the ImagePositionPatient tag does not exist, as that 
would be highly unlikely since it is a Type 1 required element for any DICOM 
image.

Original comment by bastula on 8 Mar 2011 at 4:04

GoogleCodeExporter commented 9 years ago
Issue 42 has been merged into this issue.

Original comment by bastula on 12 May 2011 at 11:31