bayesian
bayesian
¶
Bayesian model fitting for osipy.
This module provides Bayesian inference for model fitting with uncertainty estimation via maximum a posteriori (MAP) estimation.
GPU/CPU agnostic using the xp array module pattern. NO scipy dependency - uses custom bounded optimization implementation.
BayesianFitter
¶
BayesianFitter(
n_samples=100,
prior_std=None,
noise_std=None,
chunk_size=None,
compute_uncertainty=False,
tolerance=1e-06,
)
Bases: BaseFitter
Bayesian fitter with uncertainty estimation.
Uses maximum a posteriori (MAP) estimation with Laplace approximation for posterior uncertainty estimation.
GPU/CPU is automatic via xp = get_array_module().
| PARAMETER | DESCRIPTION |
|---|---|
n_samples
|
Maximum number of MAP iterations.
TYPE:
|
prior_std
|
Per-parameter standard deviations for Gaussian priors,
shape
TYPE:
|
noise_std
|
Assumed noise standard deviation. If None, estimated from data.
TYPE:
|
chunk_size
|
Number of voxels per processing chunk.
TYPE:
|
compute_uncertainty
|
If True, add
TYPE:
|
tolerance
|
Convergence tolerance for relative cost change.
TYPE:
|
fit_batch
¶
Fit a batch of voxels using vectorized MAP estimation.
Same structure as LM fit_batch() but with a prior penalty
in the cost function.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model with independent variables bound.
TYPE:
|
observed_batch
|
Observed data, shape
TYPE:
|
bounds_override
|
Per-parameter bound overrides.
TYPE:
|
initial_params
|
Initial parameter values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
params
|
Fitted parameters, shape
TYPE:
|
r2
|
R-squared values, shape
TYPE:
|
converged
|
Convergence flags, shape
TYPE:
|
fit_image
¶
Fit model to image with optional uncertainty maps.
Calls super().fit_image() for MAP fitting, then adds
{param}_std ParameterMap objects via Laplace approximation
when compute_uncertainty is True.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Model with independent variables bound.
TYPE:
|
data
|
Image data, shape
TYPE:
|
mask
|
Boolean mask of voxels to fit.
TYPE:
|
bounds_override
|
Per-parameter bound overrides.
TYPE:
|
progress_callback
|
Progress callback.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, ParameterMap]
|
Parameter maps, plus |