nifreeze.data.pet.utils module¶
Utilities for handling PET temporal and activity attributes.
- nifreeze.data.pet.utils.compute_temporal_markers(frame_time: ndarray) Tuple[ndarray, float][source]¶
Compute the frame temporal markers from the frame time values.
Computes the midframe times and the total duration following the principles detailed below.
Let \(K\) be the number of frames and \(t_{k}\) be the \(k\)-th (start) frame time. For each frame \(k\), the frame duration \(d_{k}\) is defined as the difference between consecutive frame times:
\[d_{k} = t_{k+1} - t_{k}\]If necessary, the last frame duration is set to the value of the second to last frame to match the appropriate dimensionality in this implementation.
Per-frame midpoints \(m_{k}\) are computed as:
\[m_{k} = t_{k} + \frac{d_k}{2}\]The total duration \(D\) of the acquisition is a scalar computed as the sum of the frame durations:
\[D = \sum_{k=1}^{K} d_{k}\]or, equivalently, the difference between the last frame start and its duration once the frame times have been time-origin shifted:
\[D = t_{K} - d_{K}\]Frame times are time-origin shifted (i.e. the earliest time is zeroed out) if not already done at the beginning of the process for the sake of simplicity.
- nifreeze.data.pet.utils.compute_uptake_statistic(data: ~numpy.ndarray, stat_func: ~collections.abc.Callable[[...], ~numpy.ndarray] = <function sum>)[source]¶
Compute a statistic over all voxels for each frame on a PET sequence.
Assumes the last dimension corresponds to the number of frames in the sequence.
- Parameters:
data (
ndarray) – PET data.stat_func (
Callable, optional) – Function to apply over voxels (e.g.,numpy.sum(),numpy.mean(),numpy.std())
- Returns:
1D array of statistic values for each frame.
- Return type: