File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -3980,10 +3980,14 @@ def _include_sequence(seq):
39803980 instance_sequence = (
39813981 ref_series .ReferencedSOPSequence
39823982 )
3983- else :
3983+ elif 'ReferencedInstanceSequence' in ref_series :
39843984 instance_sequence = (
39853985 ref_series .ReferencedInstanceSequence
39863986 )
3987+ else :
3988+ # This is invalid according to the standard, but
3989+ # has been observed in some data
3990+ instance_sequence = []
39873991
39883992 for ref_ins in instance_sequence :
39893993 instance_data .append (
Original file line number Diff line number Diff line change @@ -1439,3 +1439,17 @@ def test_imread_from_dicom_bytes_io_lazy():
14391439 # Two reads to ensure opening/closing is handled
14401440 im .get_frame (1 )
14411441 im .get_frame (2 )
1442+
1443+
1444+ def test_imread_missing_referenced_instances ():
1445+ # Test for the case where a ReferencedSeriesSequence is present but does
1446+ # not list instances. This is not valid by the standard but is observed and
1447+ # we should be tolerant to it
1448+ dcm = get_testdata_file ('eCT_Supplemental.dcm' , read = True )
1449+
1450+ # Add ReferencedSeriesSequence without any referenced instances
1451+ ref_series = pydicom .Dataset ()
1452+ ref_series .SeriesInstanceUID = UID ()
1453+ dcm .ReferencedSeriesSequence = [ref_series ]
1454+
1455+ Image .from_dataset (dcm , copy = False )
You can’t perform that action at this time.
0 commit comments