nifreeze.model.pet module

Models for nuclear imaging.

class nifreeze.model.pet.BSplinePETModel(self, dataset: nifreeze.data.pet.base.PET, n_ctrl: int = 3, order: int = 3, **kwargs)[source]

Bases: BasePETModel

A PET imaging realignment model based on B-Spline approximation.

Create the B-Spline interpolating matrix.

Parameters:
  • n_ctrl (int, optional) – Number of internal B-Spline control points that determine the flexibility of the temporal fit. Given a hold-out index, all frames except the held-out one are used in a least-squares fit against the B-spline basis. n_ctrl sets the number of degrees of freedom of that basis. Fewer control points produce a smoother approximation; more control points allow the curve to track finer temporal detail. Boundary knots (order + 1 at each end) are added automatically to ensure proper edge behavior.

  • order (int, optional) – Order of the B-Spline approximation.

fit_predict(index: int | None = None, **kwargs) ndarray | None[source]

Return the corrected volume using B-spline interpolation.

Predictions for times earlier than the configured start time will return the prediction for the start time.

class nifreeze.model.pet.BasePETModel(self, dataset: nifreeze.data.pet.base.PET, min_timepoints: int = 4, **kwargs)[source]

Bases: BaseModel, ABC

Interface and default methods for PET models.

Initialization.

Parameters:
  • dataset (PET) – Reference to a PET object.

  • min_timepoints (int, optional) – Minimum number of timepoints required to fit the model.

abstract fit_predict(index: int | None = None, **kwargs) ndarray | None[source]

Predict the corrected volume.

property is_fitted: bool
nifreeze.model.pet.DEFAULT_BSPLINE_N_CTRL = 3

Default number of B-Spline control points.

nifreeze.model.pet.DEFAULT_BSPLINE_ORDER = 3

Default B-Spline order.

nifreeze.model.pet.DEFAULT_TIMEPOINT_TOL = 0.01

Time frame tolerance in seconds.

nifreeze.model.pet.MIN_N_TIMEPOINTS = 4

Minimum number of timepoints for PET model fitting.

nifreeze.model.pet.MIN_TIMEPOINTS_ERROR_MSG = "'min_timepoints' must be a valid dataset size."

PET model fitting minimum fitting timepoint allowed values error.

nifreeze.model.pet.PET_MIDFRAME_ERROR_MSG = "Dataset MUST have a 'midframe'."

PET midframe error message.

nifreeze.model.pet.PET_OBJECT_ERROR_MSG = 'Dataset MUST be a PET object.'

PET object error message.