pytomography.io.PET.prd
#
Submodules#
Package Contents#
Classes#
Enum that allows values outside of the its defined values. |
|
A basic datetime with nanosecond precision, always in UTC. |
|
A basic time of day with nanosecond precision. It is not timezone-aware and is meant |
|
Helper class that provides a standard way to create an ABC using |
|
All information about a coincidence event specified as identifiers or indices (i.e. discretized). |
|
Detector ID and location. Units are in mm |
|
Items describing the exam (incomplete) |
|
A sequence of time intervals (could be consecutive) |
|
Time interval in milliseconds since start of acquisition |
|
Abstract reader for the PrdExperiment protocol. |
|
Abstract writer for the PrdExperiment protocol. |
|
Binary writer for the PrdExperiment protocol. |
|
Binary writer for the PrdExperiment protocol. |
|
NDJson writer for the PrdExperiment protocol. |
|
NDJson writer for the PrdExperiment protocol. |
Functions#
|
|
|
Attributes#
- pytomography.io.PET.prd._parse_version(version)[source]#
- Parameters:
version (str) –
- Return type:
Tuple[int, Ellipsis]
- exception pytomography.io.PET.prd.ProtocolError[source]#
Bases:
Exception
Raised when the contract of a protocol is not respected.
- class pytomography.io.PET.prd.OutOfRangeEnum[source]#
Bases:
enum.Enum
Enum that allows values outside of the its defined values.
- class pytomography.io.PET.prd.DateTime(nanoseconds_from_epoch=0)[source]#
A basic datetime with nanosecond precision, always in UTC.
- Parameters:
nanoseconds_from_epoch (Union[int, numpy.datetime64]) –
- property numpy_value: numpy.datetime64#
- Return type:
numpy.datetime64
- class pytomography.io.PET.prd.Time(nanoseconds_since_midnight=0)[source]#
A basic time of day with nanosecond precision. It is not timezone-aware and is meant to represent a wall clock time.
- Parameters:
nanoseconds_since_midnight (Union[int, numpy.timedelta64]) –
- property numpy_value: numpy.timedelta64#
- Return type:
numpy.timedelta64
- _NANOSECONDS_PER_DAY#
- pytomography.io.PET.prd.structural_equal(a, b)[source]#
- Parameters:
a (object) –
b (object) –
- Return type:
bool
- class pytomography.io.PET.prd.UnionCase(value)[source]#
Bases:
abc.ABC
,Generic
[_T
]Helper class that provides a standard way to create an ABC using inheritance.
- Parameters:
value (_T) –
- index: int#
- tag: str#
- class pytomography.io.PET.prd.CoincidenceEvent(*, detector_1_id=0, detector_2_id=0, tof_idx=0, energy_1_idx=0, energy_2_idx=0)[source]#
All information about a coincidence event specified as identifiers or indices (i.e. discretized). TODO: this might take up too much space, so some/all of these could be combined in a single index if necessary.
- Parameters:
detector_1_id (pytomography.io.PET.prd.yardl_types.UInt32) –
detector_2_id (pytomography.io.PET.prd.yardl_types.UInt32) –
tof_idx (pytomography.io.PET.prd.yardl_types.UInt32) –
energy_1_idx (pytomography.io.PET.prd.yardl_types.UInt32) –
energy_2_idx (pytomography.io.PET.prd.yardl_types.UInt32) –
- detector_1_id: pytomography.io.PET.prd.yardl_types.UInt32#
- detector_2_id: pytomography.io.PET.prd.yardl_types.UInt32#
- tof_idx: pytomography.io.PET.prd.yardl_types.UInt32#
- energy_1_idx: pytomography.io.PET.prd.yardl_types.UInt32#
- energy_2_idx: pytomography.io.PET.prd.yardl_types.UInt32#
- class pytomography.io.PET.prd.Detector(*, id=0, x=0.0, y=0.0, z=0.0)[source]#
Detector ID and location. Units are in mm TODO: this is currently just a sample implementation with “point” detectors. We plan to have full shape information here.
- Parameters:
id (pytomography.io.PET.prd.yardl_types.UInt32) –
x (pytomography.io.PET.prd.yardl_types.Float32) –
y (pytomography.io.PET.prd.yardl_types.Float32) –
z (pytomography.io.PET.prd.yardl_types.Float32) –
- id: pytomography.io.PET.prd.yardl_types.UInt32#
- x: pytomography.io.PET.prd.yardl_types.Float32#
- y: pytomography.io.PET.prd.yardl_types.Float32#
- z: pytomography.io.PET.prd.yardl_types.Float32#
- class pytomography.io.PET.prd.ExamInformation(*, subject=None, institution=None, protocol=None, start_of_acquisition=None)[source]#
Items describing the exam (incomplete)
- Parameters:
subject (Optional[Subject]) –
institution (Optional[Institution]) –
protocol (Optional[str]) –
start_of_acquisition (Optional[pytomography.io.PET.prd.yardl_types.DateTime]) –
- institution: Institution#
- protocol: str | None#
- start_of_acquisition: pytomography.io.PET.prd.yardl_types.DateTime | None#
- class pytomography.io.PET.prd.Header(*, scanner=None, exam=None)[source]#
- Parameters:
scanner (Optional[ScannerInformation]) –
exam (Optional[ExamInformation]) –
- scanner: ScannerInformation#
- exam: ExamInformation | None#
- class pytomography.io.PET.prd.Institution(*, name='', address='')[source]#
- Parameters:
name (str) –
address (str) –
- name: str#
- address: str#
- class pytomography.io.PET.prd.ScannerInformation(*, model_name=None, detectors=None, tof_bin_edges=None, tof_resolution=0.0, energy_bin_edges=None, energy_resolution_at_511=0.0, listmode_time_block_duration=0)[source]#
- Parameters:
model_name (Optional[str]) –
detectors (Optional[list[Detector]]) –
tof_bin_edges (Optional[numpy.typing.NDArray[numpy.float32]]) –
tof_resolution (pytomography.io.PET.prd.yardl_types.Float32) –
energy_bin_edges (Optional[numpy.typing.NDArray[numpy.float32]]) –
energy_resolution_at_511 (pytomography.io.PET.prd.yardl_types.Float32) –
listmode_time_block_duration (pytomography.io.PET.prd.yardl_types.UInt32) –
- model_name: str | None#
- tof_bin_edges: numpy.typing.NDArray[numpy.float32]#
edge information for TOF bins in mm (given as from first to last edge, so there is one more edge than the number of bins) TODO: this currently assumes equal size for each TOF bin, but some scanners “stretch” TOF bins depending on length of LOR
- tof_resolution: pytomography.io.PET.prd.yardl_types.Float32#
TOF resolution in mm
- energy_bin_edges: numpy.typing.NDArray[numpy.float32]#
edge information for energy windows in keV (given as from first to last edge, so there is one more edge than the number of bins)
- energy_resolution_at_511: pytomography.io.PET.prd.yardl_types.Float32#
FWHM of photopeak for incoming gamma of 511 keV, expressed as a ratio w.r.t. 511
- listmode_time_block_duration: pytomography.io.PET.prd.yardl_types.UInt32#
duration of each time block in ms
- class pytomography.io.PET.prd.Subject(*, name=None, id='')[source]#
- Parameters:
name (Optional[str]) –
id (str) –
- name: str | None#
- id: str#
- class pytomography.io.PET.prd.TimeBlock(*, id=0, prompt_events=None, delayed_events=None)[source]#
- Parameters:
id (pytomography.io.PET.prd.yardl_types.UInt32) –
prompt_events (Optional[list[CoincidenceEvent]]) –
delayed_events (Optional[list[CoincidenceEvent]]) –
- id: pytomography.io.PET.prd.yardl_types.UInt32#
number of the block. Multiply with listmodeTimeBlockDuration to get time since startOfAcquisition
- prompt_events: list[CoincidenceEvent]#
list of prompts in this time block TODO might be better to use !array
- delayed_events: list[CoincidenceEvent] | None#
list of delayed coincidences in this time block
- class pytomography.io.PET.prd.TimeFrameInformation(*, time_frames=None)[source]#
A sequence of time intervals (could be consecutive)
- Parameters:
time_frames (Optional[list[TimeInterval]]) –
- time_frames: list[TimeInterval]#
- class pytomography.io.PET.prd.TimeInterval(*, start=0, stop=0)[source]#
Time interval in milliseconds since start of acquisition
- Parameters:
start (pytomography.io.PET.prd.yardl_types.UInt32) –
stop (pytomography.io.PET.prd.yardl_types.UInt32) –
- start: pytomography.io.PET.prd.yardl_types.UInt32#
- stop: pytomography.io.PET.prd.yardl_types.UInt32#
- class pytomography.io.PET.prd.PrdExperimentReaderBase[source]#
Bases:
abc.ABC
Abstract reader for the PrdExperiment protocol.
- schema#
- T#
- __exit__(exc_type, exc, traceback)[source]#
- Parameters:
exc_type (pytomography.io.PET.prd.types.typing.Optional[type[BaseException]]) –
exc (pytomography.io.PET.prd.types.typing.Optional[BaseException]) –
traceback (object) –
- Return type:
None
- read_time_blocks()[source]#
Ordinal 1
- Return type:
collections.abc.Iterable[pytomography.io.PET.prd.types.TimeBlock]
- copy_to(writer)[source]#
- Parameters:
writer (PrdExperimentWriterBase) –
- Return type:
None
- abstract _read_time_blocks()[source]#
- Return type:
collections.abc.Iterable[pytomography.io.PET.prd.types.TimeBlock]
- class pytomography.io.PET.prd.PrdExperimentWriterBase[source]#
Bases:
abc.ABC
Abstract writer for the PrdExperiment protocol.
- schema = '{"protocol":{"name":"PrdExperiment","sequence":[{"name":"header","type":"Prd.Header"},{"name":"ti...'#
- __exit__(exc_type, exc, traceback)[source]#
- Parameters:
exc_type (pytomography.io.PET.prd.types.typing.Optional[type[BaseException]]) –
exc (pytomography.io.PET.prd.types.typing.Optional[BaseException]) –
traceback (object) –
- Return type:
None
- write_header(value)[source]#
Ordinal 0
- Parameters:
value (pytomography.io.PET.prd.types.Header) –
- Return type:
None
- write_time_blocks(value)[source]#
Ordinal 1
- Parameters:
value (collections.abc.Iterable[pytomography.io.PET.prd.types.TimeBlock]) –
- Return type:
None
- abstract _write_header(value)[source]#
- Parameters:
value (pytomography.io.PET.prd.types.Header) –
- Return type:
None
- abstract _write_time_blocks(value)[source]#
- Parameters:
value (collections.abc.Iterable[pytomography.io.PET.prd.types.TimeBlock]) –
- Return type:
None
- class pytomography.io.PET.prd.BinaryPrdExperimentReader(stream)[source]#
Bases:
pytomography.io.PET.prd._binary.BinaryProtocolReader
,pytomography.io.PET.prd.protocols.PrdExperimentReaderBase
Binary writer for the PrdExperiment protocol.
- Parameters:
stream (pytomography.io.PET.prd.protocols.typing.Union[io.BufferedReader, io.BytesIO, pytomography.io.PET.prd.protocols.typing.BinaryIO, str]) –
- class pytomography.io.PET.prd.BinaryPrdExperimentWriter(stream)[source]#
Bases:
pytomography.io.PET.prd._binary.BinaryProtocolWriter
,pytomography.io.PET.prd.protocols.PrdExperimentWriterBase
Binary writer for the PrdExperiment protocol.
- Parameters:
stream (pytomography.io.PET.prd.protocols.typing.Union[pytomography.io.PET.prd.protocols.typing.BinaryIO, str]) –
- class pytomography.io.PET.prd.NDJsonPrdExperimentReader(stream)[source]#
Bases:
pytomography.io.PET.prd._ndjson.NDJsonProtocolReader
,pytomography.io.PET.prd.protocols.PrdExperimentReaderBase
NDJson writer for the PrdExperiment protocol.
- Parameters:
stream (pytomography.io.PET.prd.protocols.typing.Union[io.BufferedReader, pytomography.io.PET.prd.protocols.typing.TextIO, str]) –
- class pytomography.io.PET.prd.NDJsonPrdExperimentWriter(stream)[source]#
Bases:
pytomography.io.PET.prd._ndjson.NDJsonProtocolWriter
,pytomography.io.PET.prd.protocols.PrdExperimentWriterBase
NDJson writer for the PrdExperiment protocol.
- Parameters:
stream (pytomography.io.PET.prd.protocols.typing.Union[pytomography.io.PET.prd.protocols.typing.TextIO, str]) –