nifreeze.model.base module

Base infrastructure for nifreeze’s models.

class nifreeze.model.base.BaseModel(self, dataset, **kwargs)[source]

Bases: object

Defines the interface and default methods.

Implements the interface of dipy.reconst.base.ReconstModel. Instead of inheriting from the abstract base, this implementation follows type adaptation principles, as it is easier to maintain and to read (see https://www.youtube.com/watch?v=3MNVP9-hglc).

Base initialization.

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

Fit and predict the indicated index of the dataset (abstract signature).

If index is None, then the model is executed in single-fit mode meaning that it will be run only once in all the data available. Please note that all the predictions of this model will suffer from data leakage from the original volume.

Parameters:

index (int or None) – The index to predict. If None, no prediction will be executed.

class nifreeze.model.base.ExpectationModel(self, dataset, stat='median', **kwargs)[source]

Bases: BaseModel

A trivial model that returns an expectation map (for example, average).

Initialize a new model.

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

Return the expectation map.

Parameters:

index (int) – The volume index that is left-out in fitting, and then predicted.

class nifreeze.model.base.ModelFactory(self, /, *args, **kwargs)[source]

Bases: object

A factory for instantiating data models.

static init(model: str | None = None, **kwargs)[source]

Instantiate a diffusion model.

Parameters:

model (str) – Diffusion model. Options: "DTI", "DKI", "S0", "AverageDWI"

Returns:

model – A model object compliant with DIPY’s interface.

Return type:

ReconstModel

class nifreeze.model.base.TrivialModel(self, dataset, predicted=None, **kwargs)[source]

Bases: BaseModel

A trivial model that returns a given map always.

Implement object initialization.

fit_predict(*_, **kwargs)[source]

Return the reference map.