diff --git a/fileformats/medimage/__init__.py b/fileformats/medimage/__init__.py index ef10886..7873030 100644 --- a/fileformats/medimage/__init__.py +++ b/fileformats/medimage/__init__.py @@ -36,9 +36,9 @@ PetSinogram, PetCountRate, PetNormalisation, - Vnd_Siemens_PetRawData, - Vnd_Siemens_PetListMode, - Vnd_Siemens_PetSinogram, - Vnd_Siemens_PetCountRate, - Vnd_Siemens_PetNormalisation, + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, + Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode, + Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram, + Vnd_Siemens_Biograph128Vision_Vr20b_PetCountRate, + Vnd_Siemens_Biograph128Vision_Vr20b_PetNormalisation, ) diff --git a/fileformats/medimage/dicom.py b/fileformats/medimage/dicom.py index 7231f3b..e57bd03 100644 --- a/fileformats/medimage/dicom.py +++ b/fileformats/medimage/dicom.py @@ -39,7 +39,6 @@ class DicomDir(DicomCollection, DirectoryContaining[Dicom]): class DicomSeries(DicomCollection, SetOf[Dicom]): - @classmethod def from_paths( cls, fspaths: ty.Iterable[Path], common_ok: bool = False @@ -47,7 +46,7 @@ def from_paths( dicoms, remaining = Dicom.from_paths(fspaths, common_ok=common_ok) series_dict = defaultdict(list) for dicom in dicoms: - series_dict[dicom["SeriesNumber"]].append(dicom) + series_dict[(str(dicom["StudyInstanceUID"]), str(dicom["SeriesNumber"]))].append(dicom) return set([cls(s) for s in series_dict.values()]), remaining @@ -55,12 +54,16 @@ def from_paths( def dicom_collection_read_metadata(collection: DicomCollection) -> ty.Dict[str, ty.Any]: # Collated DICOM headers across series collated = copy(collection.contents[0].metadata) - if len(collection.contents) > 1: - for key, val in collection.contents[1].metadata.items(): - if val != collated[key]: # Turn field into list - collated[key] = [collated[key], val] - for dicom in collection.contents[2:]: + for i, dicom in enumerate(collection.contents[1:], start=1): for key, val in dicom.metadata.items(): if val != collated[key]: + # Check whether the value is the same as the values in the previous + # images in the series + if ( + not isinstance(collated[key], list) + or isinstance(val, list) + and not isinstance(collated[key][0], list) + ): + collated[key] = [collated[key]] * i + [val] collated[key].append(val) return collated diff --git a/fileformats/medimage/raw/__init__.py b/fileformats/medimage/raw/__init__.py index 3a641e5..ac2e3b4 100644 --- a/fileformats/medimage/raw/__init__.py +++ b/fileformats/medimage/raw/__init__.py @@ -8,9 +8,9 @@ PetSinogram, PetCountRate, PetNormalisation, - Vnd_Siemens_PetRawData, - Vnd_Siemens_PetListMode, - Vnd_Siemens_PetSinogram, - Vnd_Siemens_PetCountRate, - Vnd_Siemens_PetNormalisation, + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, + Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode, + Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram, + Vnd_Siemens_Biograph128Vision_Vr20b_PetCountRate, + Vnd_Siemens_Biograph128Vision_Vr20b_PetNormalisation, ) diff --git a/fileformats/medimage/raw/pet/__init__.py b/fileformats/medimage/raw/pet/__init__.py index 316170d..14b8f70 100644 --- a/fileformats/medimage/raw/pet/__init__.py +++ b/fileformats/medimage/raw/pet/__init__.py @@ -6,9 +6,9 @@ PetNormalisation, ) from .siemens import ( - Vnd_Siemens_PetRawData, - Vnd_Siemens_PetListMode, - Vnd_Siemens_PetSinogram, - Vnd_Siemens_PetCountRate, - Vnd_Siemens_PetNormalisation, + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, + Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode, + Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram, + Vnd_Siemens_Biograph128Vision_Vr20b_PetCountRate, + Vnd_Siemens_Biograph128Vision_Vr20b_PetNormalisation, ) diff --git a/fileformats/medimage/raw/pet/siemens.py b/fileformats/medimage/raw/pet/siemens.py index 522feef..ee13e1d 100644 --- a/fileformats/medimage/raw/pet/siemens.py +++ b/fileformats/medimage/raw/pet/siemens.py @@ -7,30 +7,30 @@ ) -class Vnd_Siemens_BiographVisionVr20b_PetRawData(PetRawData): +class Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData(PetRawData): iana_mime = None ext = ".ptd" -class Vnd_Siemens_BiographVisionVr20b_PetListMode( - Vnd_Siemens_BiographVisionVr20b_PetRawData, PetListMode +class Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode( + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetListMode ): pass -class Vnd_Siemens_BiographVisionVr20b_PetSinogram( - Vnd_Siemens_BiographVisionVr20b_PetRawData, PetSinogram +class Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram( + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetSinogram ): "histogrammed projection data in a reconstruction-friendly format" -class Vnd_Siemens_BiographVisionVr20b_PetCountRate( - Vnd_Siemens_BiographVisionVr20b_PetRawData, PetCountRate +class Vnd_Siemens_Biograph128Vision_Vr20b_PetCountRate( + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetCountRate ): "number of prompt/random/single events per unit time" -class Vnd_Siemens_BiographVisionVr20b_PetNormalisation( - Vnd_Siemens_BiographVisionVr20b_PetRawData, PetNormalisation +class Vnd_Siemens_Biograph128Vision_Vr20b_PetNormalisation( + Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetNormalisation ): "normalisation scan or the current cross calibration factor"