nifreeze.data.pet module¶
PET data representation.
- class nifreeze.data.pet.PET(self, dataobj: 'np.ndarray' = None, affine: 'np.ndarray' = None, brainmask: 'np.ndarray' = None, motion_affines: 'np.ndarray' = None, datahdr: 'SpatialHeader' = None, filepath: 'Path' = NOTHING, midframe: 'np.ndarray | None' = None, total_duration: 'float | None' = None) None [source]¶
Bases:
BaseDataset
[ndarray
|None
]Data representation structure for PET data.
Method generated by attrs for class PET.
- lofo_split(index)[source]¶
Leave-one-frame-out (LOFO) for PET data.
- Parameters:
index (int) – Index of the PET frame to be left out in this fold.
- Returns:
(train_data, train_timings) (tuple) – Training data and corresponding timings, excluding the left-out frame.
(test_data, test_timing) (tuple) – Test data (one PET frame) and corresponding timing.
- nifreeze.data.pet.from_nii(filename: Path | str, brainmask_file: Path | str | None = None, motion_file: Path | str | None = None, frame_time: ndarray | list[float] | None = None, frame_duration: ndarray | list[float] | None = None) PET [source]¶
Load PET data from NIfTI, creating a PET object with appropriate metadata.
- Parameters:
filename (
os.pathlike
) – The NIfTI file.brainmask_file (
os.pathlike
, optional) – A brainmask NIfTI file. If provided, will be loaded and stored in the returned dataset.motion_file (
os.pathlike
) – A file containing head motion affine matrices (linear).frame_time (
numpy.ndarray
orlist
offloat
, optional) – The start times of each frame relative to the beginning of the acquisition. IfNone
, an error is raised (since BIDS requiresFrameTimesStart
).frame_duration (
numpy.ndarray
orlist
offloat
, optional) – The duration of each frame. IfNone
, it is derived by the difference of consecutive frame times, defaulting the last frame to match the second-last.
- Returns:
A PET object storing the data, metadata, and any optional mask.
- Return type:
- Raises:
RuntimeError – If
frame_time
is not provided (BIDS requires it).