nifreeze.estimator module¶
Orchestrates model and registration in volume-to-volume artifact estimation.
- class nifreeze.estimator.Estimator(self, model: 'BaseModel | str', strategy: 'str' = 'random', prev: 'Estimator | Filter | None' = None, model_kwargs: 'dict | None' = None, single_fit: 'bool' = False, start_index: 'int' = 0, stop_index: 'int | None' = None, **kwargs)[source]¶
Bases:
objectOrchestrates components for a single estimation step.
The estimator traverses the 4D sequence with a Leave-One-Volume-Out (LOVO) strategy: for each target volume it fits the model on the remaining volumes, predicts the held-out volume, and registers the observed volume to that prediction. Held-out independence is what makes the estimated transform valid (see
fit_predict()).- Parameters:
model (
BaseModelorstr) – The model (or model name) used to generate the registration target.strategy (
str, optional) – Name of the iterator used to traverse the 4D sequence.prev (
Estimator,Filter, optional) – A previous estimator/filter whose output initializes this one (cascade).model_kwargs (
dict, optional) – Extra keyword arguments passed through to the model at construction.single_fit (
bool, optional) – Run the model in single-fit mode: fit once on all volumes up front (viamodel.fit_predict(None)) and lock that fit instead of refitting per held-out volume. Prediction is no longer unbiased.start_index (
int, optional) – First volume index to process.stop_index (
int, optional) – One-past-last volume index to process (None= to the end).
- run(dataset: DatasetT, **kwargs) Self[source]¶
Trigger execution of the workflow this estimator belongs.
- Parameters:
dataset (
BaseDataset) – The input dataset this estimator operates on.clip (
str, optional) – Clip the intensity of"sample","predicted","both"(default) or"none"of the images before registration.clip_windows (
dict, optional) – Intensity windows by volume index. A volume’s window is estimated from the volume the first time it is registered, and then reused for its prediction and by every later estimator of the chain.debug_dir (
os.pathlike, optional) – Keep the registration working files of each estimator of the chain in a folder ofdebug_dir(instead of a temporary directory), with analigned_<index>.niitrace per volume: the registered sample with its affine corrected by the estimated transform, which a viewer shows on top ofpredicted_<index>.nii.instant_update (
bool, optional) – Whether models train on the realigned view of the dataset (default): right after a volume is registered, the model sees it resampled once, from the original volume, with the estimate (and, for DWI, its rotated b-vector). The dataset itself is never modified; registration and export keep using the original volumes. It applies to models given by name and to model instances built on this dataset (seeset_dataset()), except the trivial model, whose reference never moves.realigned (
dict, optional) – Realigned views by dataset, shared by the estimators of a chain.
- Returns:
The estimator, after fitting.
- Return type:
- class nifreeze.estimator.Filter(self, /, *args, **kwargs)[source]¶
Bases:
objectAlters an input data object (e.g., downsampling).
- run(dataset: DatasetT, **kwargs) DatasetT[source]¶
Trigger execution of the designated filter.
- Parameters:
dataset (
BaseDataset) – The input dataset this estimator operates on.- Returns:
dataset – The dataset, after filtering.
- Return type: