nifreeze.data.pet.base module¶
PET data representation.
- nifreeze.data.pet.base.ARRAY_ATTRIBUTE_NDIM_ERROR_MSG = "PET '{attribute}' must be a 1D numpy array."¶
PET initialization array attribute ndim error message.
- nifreeze.data.pet.base.ARRAY_ATTRIBUTE_OBJECT_ERROR_MSG = "PET '{attribute}' must be a numeric homogeneous array-like object."¶
PET initialization array attribute object error message.
- nifreeze.data.pet.base.ATTRIBUTE_ABSENCE_ERROR_MSG = "PET '{attribute}' may not be None"¶
PET initialization array attribute absence error message.
- nifreeze.data.pet.base.ATTRIBUTE_VOLUME_DIMENSIONALITY_MISMATCH_ERROR_MSG = "PET '{attribute}' length does not match number of frames: expected {n_frames} values, found {attr_len}."¶
PET attribute shape mismatch error message.
- class nifreeze.data.pet.base.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.base.SCALAR_ATTRIBUTE_ERROR_MSG = "PET '{attribute}' must be a numeric or single-element sequence object."¶
PET initialization scalar attribute object error message.
- nifreeze.data.pet.base.TEMPORAL_ATTRIBUTE_INCONSISTENCY_ERROR_MSG = "PET 'total_duration' cannot be smaller than last 'midframe' value: found {total_duration} and {last_midframe}."¶
PET attribute inconsistency error message.
- nifreeze.data.pet.base.format_array_like(value: Any, attr: Attribute) ndarray[source]¶
Convert
valueto andarray.This function is intended for use as an attrs-style formatter.
- Parameters:
value (
Any) – The value to format.attr (
Attribute) – The attribute being initialized;attr.nameis used in the error message.
- Returns:
formatted – The formatted value.
- Return type:
:raises exc:TypeError: If the input cannot be converted to a float
ndarray. :raises exc:ValueError: If the value isNone.
- nifreeze.data.pet.base.format_scalar_like(value: Any, attr: Attribute) float[source]¶
Convert
valueto a scalar.- Accepts:
This function is intended for use as an attrs-style formatter.
- Parameters:
value (
Any) – The value to format.attr (
Attribute) – The attribute being initialized;attr.nameis used in the error message.
- Returns:
formatted – The formatted value.
- Return type:
:raises exc:TypeError: If the input cannot be converted to a scalar. :raises exc:ValueError: If the value is
None, is of typeboolor has not size/length 1.
- nifreeze.data.pet.base.validate_1d_array(inst: PET, attr: Attribute, value: Any) None[source]¶
Strict validator to ensure an attribute is a 1D NumPy array.
Enforces that
valuehas exactly one dimension (value.ndim == 1).This function is intended for use as an attrs-style validator.
- Parameters:
:raises exc:ValueError: If the value is not 1D.