Skip to content

IntegrityError When Loading SEG File from NSCLC-Radiogenomics #370

@JoshuaSiraj

Description

@JoshuaSiraj

I get the following IntegrityError, when trying to load the following SEG from the NSCLC-Radiogenomics dataset. Error indicates that there are duplicate SOPInstanceUIDs. However, I went through the DICOM and found no duplicates. I've included the DICOM dump of the SEG aswell.

Version:
highdicom 0.26.0
pydicom 3.0.1

In [5]: ds = dcmread("/NSCLC-Radiogenomics/R01-003/SEG_Series-96510/1-1.dcm")

In [6]: seg = hd.seg.Segmentation.from_dataset(ds)
---------------------------------------------------------------------------
IntegrityError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 seg = hd.seg.Segmentation.from_dataset(ds)

File ~/bhklab/josh/med-imagetools/.pixi/envs/dev/lib/python3.12/site-packages/highdicom/seg/sop.py:2233, in Segmentation.from_dataset(cls, dataset, copy)
   2227             pixel_measures = PixelMeasuresSequence.from_sequence(
   2228                 pffg_item.PixelMeasuresSequence,
   2229                 copy=False,
   2230             )
   2231             pffg_item.PixelMeasuresSequence = pixel_measures
-> 2233 seg = super().from_dataset(seg, copy=False)
   2235 return cast(Self, seg)

File ~/bhklab/josh/med-imagetools/.pixi/envs/dev/lib/python3.12/site-packages/highdicom/image.py:1176, in _Image.from_dataset(cls, dataset, copy)
   1173 im.__class__ = cls
   1174 im = cast(Self, im)
-> 1176 im._build_luts()
   1177 return im

File ~/bhklab/josh/med-imagetools/.pixi/envs/dev/lib/python3.12/site-packages/highdicom/image.py:3307, in _Image._build_luts(self)
   3302 self._coordinate_system = get_image_coordinate_system(
   3303     self
   3304 )
   3306 if is_multiframe_image(self):
-> 3307     self._build_luts_multiframe()
   3308 else:
   3309     self._build_luts_single_frame()

File ~/bhklab/josh/med-imagetools/.pixi/envs/dev/lib/python3.12/site-packages/highdicom/image.py:3708, in _Image._build_luts_multiframe(self)
   3704                     shared_pixel_spacing = None
   3706 self._db_con = sqlite3.connect(":memory:")
-> 3708 self._create_ref_instance_table(referenced_uids)
   3710 # Construct the columns and values to put into a frame look-up table
   3711 # table within sqlite. There will be one row per frame in the
   3712 # image
   3713 col_defs = []  # SQL column definitions

File ~/bhklab/josh/med-imagetools/.pixi/envs/dev/lib/python3.12/site-packages/highdicom/image.py:4185, in _Image._create_ref_instance_table(self, referenced_uids)
   4177 with self._db_con:
   4178     self._db_con.execute(
   4179         "CREATE TABLE InstanceUIDs("
   4180         "StudyInstanceUID VARCHAR NOT NULL, "
   (...)   4183         ")"
   4184     )
-> 4185     self._db_con.executemany(
   4186         "INSERT INTO InstanceUIDs "
   4187         "(StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID) "
   4188         "VALUES(?, ?, ?)",
   4189         referenced_uids,
   4190     )

IntegrityError: UNIQUE constraint failed: InstanceUIDs.SOPInstanceUID

1-1.dcm.dcmdump.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions