nifreeze.data.pet package¶
PET data representation¶
This submodule implements data structures and I/O utilities for PET data.
Data Representation.
The PET class requires a dataobj that can
be an array-like object.
The class instantiation requires midframe
and total_duration value data to be
provided.
Both these values are computed from the frame start time (FrameTimesStart in
BIDS terms).
The from_nii() function takes a temporal file
parameter, which is expected to be a JSON file containing the frame start time.
Ultimately, the midframe and total duration values are computed by the
compute_temporal_markers() method.
- class nifreeze.data.pet.PET(self, dataobj: 'np.ndarray' = None, affine: 'np.ndarray' = None, brainmask: 'np.ndarray | None' = None, motion_affines: 'np.ndarray | None' = None, datahdr: 'nb.Nifti1Header | None' = None, filepath: 'Path' = NOTHING, midframe: 'Any' = None, total_duration: 'Any' = None) None[source]¶
Bases:
BaseDataset[ndarray]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.
- midframe: np.ndarray¶
A (N,) numpy array specifying the midpoint timing of each sample or frame.
- set_transform(index: int, affine: ndarray, order: int = 3) None[source]¶
Set an affine, and update data object and gradients.
- nifreeze.data.pet.from_nii(filename: Path | str, temporal_file: Path | str, brainmask_file: Path | str | None = None) PET[source]¶
Load PET data from NIfTI, creating a PET object with appropriate metadata.
- Parameters:
filename (
os.pathlike) – The NIfTI file.temporal_file (
os.pathlike) – A JSON file containing temporal data. It must at least containFrameTimesStartdata.brainmask_file (
os.pathlike, optional) – A brainmask NIfTI file. If provided, will be loaded and stored in the returned dataset.
- Returns:
A PET object storing the data, metadata, and any optional mask.
- Return type:
- Raises:
RuntimeError – If
FrameTimesStartis not provided (BIDS requires it).