base
base
¶
Base classes for model fitting algorithms.
This module provides the abstract base class for all fitting algorithms.
Fitters operate on FittableModel instances — models with all
independent variables already bound so only free parameters remain.
The BaseFitter.fit_image() concrete method handles mask extraction,
chunking, GPU transfer, and ParameterMap assembly. Subclasses only need
to implement fit_batch().
BaseFitter
¶
Bases: ABC
Abstract base class for model fitting algorithms.
Subclasses implement fit_batch() for the core optimization.
fit_image() is a concrete method that handles image-level
boilerplate (masking, chunking, GPU, ParameterMap assembly).
fit_batch
abstractmethod
¶
Core fitting algorithm for a batch of voxels.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model with all independent variables bound.
TYPE:
|
observed_batch
|
Observed data, shape
TYPE:
|
bounds_override
|
Per-parameter bound overrides.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
params
|
Fitted parameters, shape
TYPE:
|
r2
|
R-squared values, shape
TYPE:
|
converged
|
Convergence flags, shape
TYPE:
|
fit_image
¶
Fit model to entire image volume.
Concrete method that handles mask extraction, chunking,
GPU transfer, and ParameterMap assembly. Calls fit_batch()
per chunk.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model with all independent variables bound.
TYPE:
|
data
|
Image data, shape
TYPE:
|
mask
|
Boolean mask of voxels to fit, shape
TYPE:
|
bounds_override
|
Per-parameter bound overrides.
TYPE:
|
progress_callback
|
Progress callback (0.0 to 1.0).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, ParameterMap]
|
Mapping of parameter names to ParameterMap objects. |