Skip to content

Commit 64393e9

Browse files
committed
debugged image type validation in siemens raw data files
1 parent dabff5a commit 64393e9

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

fileformats/medimage/raw/pet/siemens.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def image_type(self) -> str:
6363
f"Image type of {self} ({image_type!r}) does not match expected "
6464
f"({self.expected_image_type!r})"
6565
)
66-
return image_type
66+
return image_type
67+
assert isinstance(self._image_type_seq[-1], str)
68+
return self._image_type_seq[-1]
6769

6870
@mtime_cached_property
6971
def _image_type_seq(self) -> ty.List[str]:
@@ -130,29 +132,29 @@ def dicom_header_limits(self) -> ty.Tuple[int, int]: # type: ignore[override]
130132

131133

132134
class Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode(
133-
Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetListMode
135+
Vnd_Siemens_Biograph128Vision_Vr20b_LargePetRawData, PetListMode
134136
):
135137
expected_image_type = "PET_LISTMODE"
136138

137139

138140
class Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram(
139-
Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetSinogram
141+
Vnd_Siemens_Biograph128Vision_Vr20b_LargePetRawData, PetSinogram
140142
):
141143
"histogrammed projection data in a reconstruction-friendly format"
142144

143145
expected_image_type = "PET_SINO_DYNAMIC"
144146

145147

146148
class Vnd_Siemens_Biograph128Vision_Vr20b_PetCountRate(
147-
Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetCountRate
149+
Vnd_Siemens_Biograph128Vision_Vr20b_LargePetRawData, PetCountRate
148150
):
149151
"number of prompt/random/single events per unit time"
150152

151153
expected_image_type = "PET_COUNTRATE"
152154

153155

154156
class Vnd_Siemens_Biograph128Vision_Vr20b_PetNormalisation(
155-
Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData, PetNormalisation
157+
Vnd_Siemens_Biograph128Vision_Vr20b_LargePetRawData, PetNormalisation
156158
):
157159
"normalisation scan or the current cross calibration factor"
158160

scripts/debug_ptd_read.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from pathlib import Path
2-
from fileformats.medimage.raw import Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData
32

4-
ptd = Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData(
3+
# from fileformats.medimage.raw import Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData
4+
from fileformats.medimage.raw import Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode
5+
6+
ptd = Vnd_Siemens_Biograph128Vision_Vr20b_PetListMode(
57
Path(
68
"/Users/tclose/Data/tbp/PET_Raw_Data_0602/"
79
"PHYSICS_SUV_TEST_PVE_F18.PT.PET_Onco_(Adult).602.PET_LISTMODE.2023.07.27.08.49.11.676000.2.0.2761856.ptd"
@@ -10,4 +12,13 @@
1012

1113
mdata = ptd.metadata
1214

15+
# ptd = Vnd_Siemens_Biograph128Vision_Vr20b_PetRawData(
16+
# Path(
17+
# "/Users/tclose/Data/tbp/PET_Raw_Data_0602/"
18+
# "PHYSICS_SUV_TEST_PVE_F18.PT.PET_Onco_(Adult).602.PET_LISTMODE.2023.07.27.08.49.11.676000.2.0.2761856.ptd"
19+
# ).expanduser()
20+
# )
21+
22+
# mdata = ptd.metadata
23+
1324
assert mdata

0 commit comments

Comments
 (0)