Result types¶
What the analysis methods hand back. These are read, not constructed:
BrainData.predict returns a Predict, BrainData.bootstrap a
BootstrapResult, a GLM contrast a ContrastResult, and the brain-space
functions a BrainSpaceConfig.
Data classes for neuroimaging analysis.
BrainData (masked voxel data), Adjacency (similarity/distance matrices),
DesignMatrix (regressors), the Roc analysis class, the
Simulator/SimulateGrid data simulators, and the frozen result records those
classes return (Predict, BootstrapResult, ContrastResult) plus the
brain-space configuration record (BrainSpaceConfig).
Classes:
| Name | Description |
|---|---|
Predict |
Frozen structural record for |
BootstrapResult |
Frozen record of one bootstrap statistic's estimate and uncertainty. |
ContrastResult |
Frozen record of the inferential outputs of one contrast. |
BrainSpaceConfig |
Immutable MNI template configuration. |
Classes¶
Predict
dataclass
¶
Predict(
spatial_scale: str,
scoring: Any = None,
classes: ndarray | None = None,
predictions: ndarray | None = None,
cv_folds: ndarray | None = None,
scores: ndarray | None = None,
estimator: Any = None,
weight_map: BrainData | None = None,
roi_labels: ndarray | None = None,
score_map: BrainData | None = None,
)
Frozen structural record for BrainData.predict decoding results.
spatial_scale is the discriminator: it decides which fields carry a
value and which stay None. Construction validates that combination, so
an empty or mixed-mode record cannot exist; the shapes within it are the
producer's responsibility. Field bindings cannot be rebound, but the
payloads they hold remain usable, and the record takes independent
ownership of every array, brain map, and estimator it stores.
Brain-space outputs are BrainData objects, not raw arrays, so
result.weight_map.plot() works directly (.data gives the array).
Non-spatial fields are numpy.
Populated by spatial_scale. 'whole_brain': predictions,
cv_folds, scores, estimator, weight_map. 'roi':
scores, roi_labels, score_map, weight_map.
'searchlight': score_map. classes accompanies any classifier;
scoring records the caller's scoring specification in every mode.
Why the all-data fit is the canonical map. The mean of per-fold
coef_ vectors corresponds to no actual fitted estimator (each fold saw
a different subset), and fits on overlapping training folds are not
independent uncertainty samples. The record therefore exposes one
coefficient map, from the estimator refitted on all observations after
cross-validation: cross-validation gives the honest score, the refit
gives the publishable map.
Attributes:
| Name | Type | Description |
|---|---|---|
spatial_scale |
str
|
|
scoring |
str | callable | None
|
The scoring specification the caller
passed. |
classes |
ndarray | None
|
Classifier class labels, |
predictions |
ndarray | None
|
Out-of-fold predictions, one per row,
|
cv_folds |
ndarray | None
|
Fold index per row, |
scores |
ndarray | None
|
Per-fold score — |
estimator |
Any
|
The all-data fitted sklearn estimator (whole-brain
only); use it to |
weight_map |
BrainData | None
|
Coefficients of the estimator refit on
all data, |
roi_labels |
ndarray | None
|
Atlas integer ids, |
score_map |
BrainData | None
|
|
mean_score |
float | ndarray
|
Mean of |
std_score |
float | ndarray
|
Standard deviation of |
Note
Encoding-model timeseries prediction (bd.predict(X=...)) returns a
BrainData directly rather than a Predict — the natural container
for a voxel timeseries.
Methods:
| Name | Description |
|---|---|
asdict |
Convert to dictionary. |
available |
Return names of the fields this result carries (excludes private). |
Attributes¶
mean_score
property
¶
Mean score across folds — a float for whole-brain, per parcel for ROI.
Methods:¶
asdict ¶
Convert to dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_none
|
bool
|
If True, include every field that does not apply to
this spatial scale, whose value is None. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of field names to values. |
BootstrapResult
dataclass
¶
BootstrapResult(
estimate: Payload,
standard_error: Payload,
ci_lower: Payload,
ci_upper: Payload,
samples: ndarray | None = None,
)
Bases: Generic[Payload]
Frozen record of one bootstrap statistic's estimate and uncertainty.
The single result structure every supported bootstrap statistic returns.
Its payload is whatever the producer works in: BrainData for the
BrainData facade, Adjacency for the Adjacency facade. The four
summary payloads share one data shape.
Field bindings cannot be rebound. The payloads stay usable, but the record takes independent ownership of each one, so mutating a returned payload never reaches the source object or a sibling payload.
The record deliberately exposes no replicate mean and no z, p, or
tail output: those need a separately defined bootstrap hypothesis test.
For a normal-approximation stand-in, users compute it themselves from
estimate and standard_error.
Attributes:
| Name | Type | Description |
|---|---|---|
estimate |
Payload
|
The statistic evaluated once on the original full sample — not the mean of the replicates. |
standard_error |
Payload
|
Elementwise standard deviation of the
bootstrap replicates, with |
ci_lower |
Payload
|
Lower bound of the central percentile interval at
the requested |
ci_upper |
Payload
|
Upper bound of that interval. The bounds are elementwise marginal: the nominal level applies separately to each voxel, feature, or test row, with no simultaneous-coverage claim. |
samples |
ndarray | None
|
Every replicate, bootstrap axis first,
when |
ContrastResult
dataclass
¶
ContrastResult(
effect: Payload,
variance: Payload,
standard_error: Payload,
statistic: Payload,
z_score: Payload,
p_value: Payload,
degrees_of_freedom: float | ndarray,
)
Bases: Generic[Payload]
Frozen record of the inferential outputs of one contrast.
The one result type inferential contrast methods return. Its payload is
whatever the producer works in: float or np.ndarray for a Glm,
BrainData for the BrainData facade.
Fields cannot be rebound. Array payloads stay mutable, but each result owns its arrays: they never alias the input contrast, a model's retained state, or another result.
Every statistic describes the directional hypothesis that effect is zero,
so p_value is one-sided; negating the contrast tests the other direction.
Attributes:
| Name | Type | Description |
|---|---|---|
effect |
Payload
|
The estimated linear combination of coefficients. |
variance |
Payload
|
The estimated variance of |
standard_error |
Payload
|
|
statistic |
Payload
|
The signed t-statistic for the null hypothesis
that |
z_score |
Payload
|
The signed normal-score equivalent of the directional p-value. |
p_value |
Payload
|
The one-sided upper-tail p-value. |
degrees_of_freedom |
float | ndarray
|
The residual degrees of freedom used for inference. |
BrainSpaceConfig
dataclass
¶
Immutable MNI template configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
template |
str
|
Template variant ( |
resolution |
int
|
Resolution in mm (1, 2, or 3). |
mask |
str
|
Path to the brain mask file. |
brain |
str
|
Path to the brain-extracted image. |
plot |
str
|
Path to the full T1 image used for plotting. |