Skip to content

Commit

Permalink
renamed siemens raw data to include full model name
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Nov 13, 2023
1 parent 13c5151 commit 4e5d91f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
10 changes: 5 additions & 5 deletions fileformats/medimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
17 changes: 10 additions & 7 deletions fileformats/medimage/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,31 @@ class DicomDir(DicomCollection, DirectoryContaining[Dicom]):


class DicomSeries(DicomCollection, SetOf[Dicom]):

@classmethod
def from_paths(
cls, fspaths: ty.Iterable[Path], common_ok: bool = False
) -> ty.Tuple[ty.Set[FileSet], ty.Set[Path]]:
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


@FileSet.read_metadata.register
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
10 changes: 5 additions & 5 deletions fileformats/medimage/raw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
10 changes: 5 additions & 5 deletions fileformats/medimage/raw/pet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
18 changes: 9 additions & 9 deletions fileformats/medimage/raw/pet/siemens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 4e5d91f

Please sign in to comment.