Classes

Contents

Classes#

Test statistics#

class SPM0D[source]#

Statistical parametric map (SPM) object.

Main attributes

fn_name

name of the spm1d.stats function

STAT

test statistic type: 'T', 'F', 'T2' or 'X2'

z

test statistic value

df

degrees of freedom; when a covariance model is estimated these are the Satterthwaite effective degrees of freedom.

dim

data dimensionality (0)

residuals

model residuals

Model attributes

design

experimental design object

fit

fitted model object

contrast

contrast vector or matrix

ANOVA and regression attributes

name

effect name (ANOVA only)

ss, sse, ms, mse

(F statistics only) effect and error sums of squares and mean squares

r

(regress only) correlation coefficient

Indicator attributes

isanova, isregress, ismultivariate, ismultigroup, iswilks, isinference

inference(alpha=0.05, method='param', **kwargs)[source]#

Statistical inference on a 0D test statistic.

Parameters:

  • alpha — Type I error rate (default 0.05)

  • method — 'param' (parametric, default) or 'perm' (permutation)

  • dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)

  • nperm — (method=’perm’ only) number of permutations. Default: all unique permutations if at most 10000 and 10000 random permutations otherwise. -1: all unique permutations.

  • two_tailed — DEPRECATED. Use dirn=0 and dirn=1 for True and False, respectively.

  • iterations — DEPRECATED (use nperm)

  • force_iterations — DEPRECATED (use nperm)

Returns:

  • SPMi0D object

Example:

>>> spmi = spm1d.stats.ttest2( yA, yB ).inference( 0.05 )
property STAT#

"T", "F", "T2" (Hotelling’s T2) or "X2" (chi-squared).

Type:

Test statistic type

property contrast#

ContrastT for t statistics or ContrastF for F statistics.

Type:

Tested contrast

property df#

Degrees of freedom as a two-tuple (df1, df2). df1 is 1 for t statistics. Inference results with a non-sphericity or unequal-variance correction hold corrected values (uncorrected values: df_adjusted).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Dependent variable dimensionality; 0 for scalar data.

effect_size(from_model=False, **kwargs)#

Standardized effect size for this contrast.

Descriptive effect size computed before inference and ignoring the ROI.

  • T contrasts: Cohen’s d and Hedges’ g.

  • F contrasts: partial eta squared v0*F/(v0*F + v1) plus eta squared and omega squared where sums of squares are available.

  • Hotelling’s T2: Mahalanobis distance D between the compared means (multivariate Cohen’s d) and multivariate partial eta squared T2 / (T2 + df_e).

  • Wilks’ lambda (MANOVA, MANCOVA, CCA): multivariate partial eta squared 1 - lambda^(1/s) with s from Rao’s approximation. Lambda is stored as wilks.

Parameters:

  • from_model — if True, use the fitted-model standardizer instead of the classical one (default False)

Returns:

  • EffectSize object with the measure name, standardizer and values

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> es  = spm.effect_size()
>>> print( es.name, es.d.shape )
Cohen's d (101,)
Note:

  • Paired tests are fitted as one-sample tests on the differences. d is therefore standardized by the SD of the differences (d_z) and exceeds d_av when the two conditions are correlated.

  • Effect size confidence intervals are not supported.

property formula#

(Results of spm1d.stats.formula only) Formula string.

get_estimated_contrast_and_se()#

(T statistics only) Estimated contrast and its standard error.

The estimated contrast is the contrast applied to the fitted model coefficients (c @ b): mean minus datum (one-sample test), mean paired difference (paired test), difference of group means (two-sample test) or slope (regression). The standard error is that of the t statistic under its covariance model so that t = estimated_contrast / se.

Confidence intervals (Confidence intervals) are built from these two quantities.

Returns:

  • estimated_contrast — float for 0D data or (Q,) array for 1D data

  • se — its standard error with the same shape

Example:

>>> spm = spm1d.stats.ttest2( yA, yB )
>>> cb, se = spm.get_estimated_contrast_and_se()
property isanova#

True for a univariate F statistic (ANOVA, ANCOVA or regression F) and False for t, Hotelling’s T2 and the multivariate F of Wilks’ lambda.

isinference = False#

True for an inference result (SPMi1D or SPMi0D) and False for a test statistic (SPM1D or SPM0D).

property ismultigroup#

True for designs comparing two or more independent groups (ttest2, anova1 and two- and three-way designs). test_eqvar applies to these designs.

property ismultivariate#

True for a vector-valued dependent variable (Hotelling’s, MANOVA, MANCOVA, CCA).

property isregress#

True for a regress result.

property iswilks#

True when the F statistic is Rao’s F of Wilks’ lambda (MANOVA, MANCOVA, CCA).

property ms#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Effect mean square

property mse#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Error mean square

property name#

Effect or comparison name (e.g., “Main A”, “contrast 0” or post hoc label “A0 - A1”).

normality_test(alpha=0.05) — DEPRECATED#

Deprecated name of test_normality().

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

plot_design(**kwdargs)#

Plot the design matrix of this statistic (see spm1d.plot.plot_spm_design()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, seed=0 )
>>> spm  = spm1d.stats.anova1( y, A )
>>> h = spm.plot_design()
property residuals#

(J,) array (0D) or (J,Q) array (1D).

Type:

Fitted model residuals

save_h5(fpath, with_args=False)#

Save to an HDF5 file (read with spm1d.io.load()).

Parameters:

  • fpath — HDF5 file path

  • with_args — if True, also save procedure input arguments (default False)

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> spm.save_h5( 'ttest2.h5' )
>>> loaded = spm1d.io.load( 'ttest2.h5' )
property ss#

(ANOVA F statistics only) Effect sum of squares.

property sse#

(ANOVA F statistics only) Error sum of squares.

test_eqvar()#

Test of equal error variance across between-subject groups.

  • Between-subject designs, Bartlett’s test.

  • Mixed designs: Box’s M test of the within-subject covariance matrices of between-subject groups.

  • Designs without between-subject groups are unsupported and raise an SPM1DError.

Returns:

  • EqVarResults0D or EqVarResults1D object.

Example:
>>> spm = spm1d.stats.anova1(y, A)
>>> print( spm.test_eqvar() )
Note:

  • The test uses the SPM data.

  • Bartlett’s test generalizes the two-sample F test of variances (spm1d.stats.eqvartest) to any number of cells.

  • 1D data: statistic continuum thresholded using random field theory.

test_normality(alpha=0.05)#

Test residual normality.

Saturated designs: reduced-model residuals (without subject-condition interactions) are tested instead.

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • SPMi0D or SPMi1D object of the D’Agostino-Pearson K2 statistic.

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> print( spm.test_normality().h0reject )
False
test_sphericity()#

(Repeated-measures designs only) Mauchly’s sphericity test.

Returns:

  • SphericityResults0D or SphericityResults1D object. Mixed designs: within-cell covariance pooled across between-subject groups.

Example:
>>> spm = spm1d.stats.anova1rm(y, A, S)
>>> print( spm.test_sphericity() )
Note:

  • For 1D sphericity tests there should be at least 8 subjects.

write_to_h5group(group, with_args=False)#

Write to an open HDF5 group.

Parameters:

  • group — open h5py group

  • with_args — write input arguments if True (default False)

Returns:

  • None (read with SPM0D._from_h5group)

Example:
>>> import h5py
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, seed=0 )
>>> spm  = spm1d.stats.anova1( y, A )
>>> with h5py.File( 'anova1.h5', 'w' ) as f:
...     spm.write_to_h5group( f.create_group( 'spm' ) )
property z#

float (0D) or (Q,) array (1D). Masked array for ROI analyses.

Type:

Test statistic

design#

Design object (design matrix, contrasts and factors) from which the statistic was computed.

fn_name#

Name of the spm1d.stats function that produced the result ("ttest2", "anova1", …). "formula" for formula results.

fit#

Fitted model with parameter estimates, residuals and variance estimates.

roi#

Region of interest (a boolean (Q,) array) if present, otherwise None (whole domain).

r#

Correlation coefficient (regress results only).

class SPM1D[source]#

Statistical parametric map (SPM) object.

Main attributes

fn_name

name of the spm1d.stats function

STAT

test statistic type. It is 'T' (t), 'F', 'T2' (Hotelling’s T²) or 'X2' (χ²)

z

test statistic continuum as a (Q,) array

df

degrees of freedom. For a t statistic the first value is always 1 and the second value is the error degrees of freedom. When a covariance model is estimated these are the Satterthwaite effective degrees of freedom. They are then generally not whole numbers.

dim

data dimensionality (1)

residuals

model residuals as a (J,Q) array. The smoothness (1D) and normality tests are computed from them

Model attributes

design

experimental design including the design matrix, factors and contrasts

fit

fitted model including parameter estimates (fit.b), residuals (fit.e), sums of squares and fit.wilks for multivariate procedures

contrast

the contrast vector or matrix that defines the tested effect

ANOVA and regression attributes

name

effect name (e.g., 'Main A') for ANOVA effects, otherwise None

ss, sse, ms, mse

(F statistics only) effect and error sums of squares and mean squares

r

(regress only) correlation coefficient

Indicator attributes

isanova, isregress, ismultivariate, ismultigroup, iswilks, isinference

True for ANOVA procedures, regression, multivariate procedures, designs with more than one group, Wilks’ Λ statistics (reported as Rao’s F) and inference objects respectively

1D attributes

Q

number of domain nodes

roi

region of interest as a boolean (Q,) array if present, otherwise None for the whole domain

fwhm

estimated smoothness expressed as a full width at half maximum (FWHM). It is estimated from the model residuals

lkc

Lipschitz–Killing curvature. This is an alternative expression of the smoothness and domain size

resels

resolution element counts. These are the number of separate domain segments and the domain length divided by the FWHM

inference(alpha=0.05, method='rft', roi=None, **kwargs)[source]#

Statistical inference on a 1D test statistic.

Parameters:

  • alpha — Type I error rate (default 0.05)

  • method — inference method: 'rft' (default), 'perm', 'fdr', 'bonf' or 'uncorr'

  • roi — boolean region of interest array (default None: whole domain)

  • dirn — inference direction: 0 (two-tailed), +1 or -1 (one-tailed)

  • nperm — (method=’perm’ only) number of permutations. Default: all unique permutations if at most 10000 and 10000 random permutations otherwise. -1: all unique permutations.

  • circular — True for circular domains

  • withBonf — (method=’rft’ only) if True (default), cap RFT probabilities at Bonferroni values

  • cluster_metric — (method=’perm’ only) 'MaxClusterExtent' (default), 'MaxClusterHeight' or 'MaxClusterIntegral'

  • approach — (method=’fdr’ only) 'bh' (Benjamini-Hochberg, default) or 'by' (Benjamini-Yekutieli)

  • two_tailed — DEPRECATED. Use dirn=0 and dirn=1 for True and False, respectively.

  • iterations — DEPRECATED (use nperm)

  • force_iterations — DEPRECATED (use nperm)

Returns:

  • SPMi1D object

Example:

>>> spmi = spm1d.stats.ttest2( yA, yB ).inference( 0.05 )
>>> spmi = spm1d.stats.ttest2( yA, yB ).inference( 0.05, method='perm', nperm=1000, dirn=1 )
property Q#

Number of domain nodes (length of z).

property STAT#

"T", "F", "T2" (Hotelling’s T2) or "X2" (chi-squared).

Type:

Test statistic type

property contrast#

ContrastT for t statistics or ContrastF for F statistics.

Type:

Tested contrast

property df#

Degrees of freedom as a two-tuple (df1, df2). df1 is 1 for t statistics. Inference results with a non-sphericity or unequal-variance correction hold corrected values (uncorrected values: df_adjusted).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Dimensionality of the dependent variable. 0 for scalar data and 1 for continuum (1D) data.

effect_size(from_model=False, **kwargs)#

Standardized effect size for this contrast.

Descriptive effect size computed before inference and ignoring the ROI.

  • T contrasts: Cohen’s d and Hedges’ g.

  • F contrasts: partial eta squared v0*F/(v0*F + v1) plus eta squared and omega squared where sums of squares are available.

  • Hotelling’s T2: Mahalanobis distance D between the compared means (multivariate Cohen’s d) and multivariate partial eta squared T2 / (T2 + df_e).

  • Wilks’ lambda (MANOVA, MANCOVA, CCA): multivariate partial eta squared 1 - lambda^(1/s) with s from Rao’s approximation. Lambda is stored as wilks.

Parameters:

  • from_model — if True, use the fitted-model standardizer instead of the classical one (default False)

Returns:

  • EffectSize object with the measure name, standardizer and values

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> es  = spm.effect_size()
>>> print( es.name, es.d.shape )
Cohen's d (101,)
Note:

  • Paired tests are fitted as one-sample tests on the differences. d is therefore standardized by the SD of the differences (d_z) and exceeds d_av when the two conditions are correlated.

  • Effect size confidence intervals are not supported.

property formula#

(Results of spm1d.stats.formula only) Formula string.

property fwhm#

Estimated residual smoothness as the full width at half maximum of a Gaussian kernel.

get_estimated_contrast_and_se()#

(T statistics only) Estimated contrast and its standard error.

The estimated contrast is the contrast applied to the fitted model coefficients (c @ b): mean minus datum (one-sample test), mean paired difference (paired test), difference of group means (two-sample test) or slope (regression). The standard error is that of the t statistic under its covariance model so that t = estimated_contrast / se.

Confidence intervals (Confidence intervals) are built from these two quantities.

Returns:

  • estimated_contrast — float for 0D data or (Q,) array for 1D data

  • se — its standard error with the same shape

Example:

>>> spm = spm1d.stats.ttest2( yA, yB )
>>> cb, se = spm.get_estimated_contrast_and_se()
property isanova#

True for a univariate F statistic (ANOVA, ANCOVA or regression F) and False for t, Hotelling’s T2 and the multivariate F of Wilks’ lambda.

isinference = False#

True for an inference result (SPMi1D or SPMi0D) and False for a test statistic (SPM1D or SPM0D).

property ismultigroup#

True for designs comparing two or more independent groups (ttest2, anova1 and two- and three-way designs). test_eqvar applies to these designs.

property ismultivariate#

True for a vector-valued dependent variable (Hotelling’s, MANOVA, MANCOVA, CCA).

property isregress#

True for a regress result.

property iswilks#

True when the F statistic is Rao’s F of Wilks’ lambda (MANOVA, MANCOVA, CCA).

property lkc#

Estimated residual Lipschitz-Killing curvature (smoothness measure for RFT inference described in Smoothness estimation).

property ms#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Effect mean square

property mse#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Error mean square

property name#

Effect or comparison name (e.g., “Main A”, “contrast 0” or post hoc label “A0 - A1”).

normality_test(alpha=0.05) — DEPRECATED#

Deprecated name of test_normality().

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

plot(**kwdargs)#

Plot test statistic continuum (see spm1d.plot.plot_spm()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm  = spm1d.stats.ttest2( y0, y1 )
>>> line = spm.plot( color='r' )
plot_design(**kwdargs)#

Plot the design matrix and contrast (see spm1d.plot.plot_spm_design()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> spm = spm1d.stats.anova1( y, A )
>>> h = spm.plot_design()
plot_effect(**kwdargs)#

Plot ANOVA effect data and clusters (see spm1d.plot.plot_effect()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> h = spm[0].plot_effect()
property resels#

Resolution element counts (resels0, resels1).

property residuals#

(J,) array (0D) or (J,Q) array (1D).

Type:

Fitted model residuals

save_h5(fpath, with_args=False)#

Save to an HDF5 file (read with spm1d.io.load()).

Parameters:

  • fpath — HDF5 file path

  • with_args — if True, also save procedure input arguments (default False)

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> spm.save_h5( 'ttest2.h5' )
>>> loaded = spm1d.io.load( 'ttest2.h5' )
property ss#

(ANOVA F statistics only) Effect sum of squares.

property sse#

(ANOVA F statistics only) Error sum of squares.

test_eqvar()#

Test of equal error variance across between-subject groups.

  • Between-subject designs, Bartlett’s test.

  • Mixed designs: Box’s M test of the within-subject covariance matrices of between-subject groups.

  • Designs without between-subject groups are unsupported and raise an SPM1DError.

Returns:

  • EqVarResults0D or EqVarResults1D object.

Example:
>>> spm = spm1d.stats.anova1(y, A)
>>> print( spm.test_eqvar() )
Note:

  • The test uses the SPM data.

  • Bartlett’s test generalizes the two-sample F test of variances (spm1d.stats.eqvartest) to any number of cells.

  • 1D data: statistic continuum thresholded using random field theory.

test_normality(alpha=0.05)#

Test residual normality.

Saturated designs: reduced-model residuals (without subject-condition interactions) are tested instead.

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • SPMi0D or SPMi1D object of the D’Agostino-Pearson K2 statistic.

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> print( spm.test_normality().h0reject )
False
test_sphericity()#

(Repeated-measures designs only) Mauchly’s sphericity test.

Returns:

  • SphericityResults0D or SphericityResults1D object. Mixed designs: within-cell covariance pooled across between-subject groups.

Example:
>>> spm = spm1d.stats.anova1rm(y, A, S)
>>> print( spm.test_sphericity() )
Note:

  • For 1D sphericity tests there should be at least 8 subjects.

write_to_h5group(group, with_args=False)#

Write to an open HDF5 group.

Parameters:

  • group — open h5py group

  • with_args — write input arguments if True (default False)

Returns:

  • None (read with SPM1D._from_h5group)

Example:
>>> import h5py
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> with h5py.File( 'ttest2.h5', 'w' ) as f:
...     spm.write_to_h5group( f.create_group( 'spm' ) )
property z#

float (0D) or (Q,) array (1D). Masked array for ROI analyses.

Type:

Test statistic

design#

Design object (design matrix, contrasts and factors) from which the statistic was computed.

fn_name#

Name of the spm1d.stats function that produced the result ("ttest2", "anova1", …). "formula" for formula results.

fit#

Fitted model with parameter estimates, residuals and variance estimates.

roi#

Region of interest (a boolean (Q,) array) if present, otherwise None (whole domain).

r#

Correlation coefficient (regress results only).

class SPMList[source]#

List of SPM objects (one per effect). Accessible by index or name (e.g., “Main A”).

inference(alpha=0.05, method=None, **kwargs)[source]#

Inference on all effects.

Parameters:

  • Arguments of inference (see SPM1D and SPM0D)

Returns:

  • SPMiList object

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> print( spmi.get_h0reject_values() )
(False, False, False)
property STAT#

Effect statistic type (F).

property contrasts#

Design contrasts (ContrastF objects) in list order.

property design#

Design object shared by all effects.

property dfe#

Error degrees of freedom of the first effect.

property dim#

Dependent variable dimensionality (0 or 1).

property effect_labels#

Effect labels in list order.

property effect_labels_short#

Short labels (A, B, A:B) in list order if available, otherwise None.

effect_size(from_model=False, **kwargs)#

Standardized effect size of all effects.

Parameters:

  • from_model — as for effect_size of a single result (default False)

Returns:

  • List of EffectSize objects in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> ess = spm.effect_size()
>>> print( len( ess ), ess[0].name )
3 partial eta squared
property fit#

Fitted model shared by all effects.

property fn_name#

Name of the spm1d.stats function.

property formula#

(Lists produced by spm1d.stats.formula only) Formula string.

get_df_values()#

Degrees of freedom of all effects.

Returns:

  • List of (df1, df2) tuples in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B, cov_model='iid' )
>>> print( spm.get_df_values() )
[(1, 24), (2, 24), (2, 24)]
get_effect_labels()#

Effect labels (same as effect_labels).

Returns:

  • Tuple of labels in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( spm.get_effect_labels() )
('Main A', 'Main B', 'Interaction A:B')
get_f_values()#

Test statistics of all effects.

Returns:

  • Tuple of statistics (z) in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( [z.shape for z in spm.get_f_values()] )
[(101,), (101,), (101,)]
isparametric = True#

True for parametric inference (rft or param).

property mse#

float (0D) or (Q,) array (1D).

Type:

Fitted model error mean square

name = 'SPM list'#

"SPM list" or "SPM inference list".

Type:

List type as printed

property ncontrasts#

Number of contrasts (same as neffects).

property neffects#

Number of effects (list length).

property nfactors#

Number of experimental factors (excluding the subject factor).

normality_test(alpha=0.05) — DEPRECATED#

Deprecated name of test_normality().

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

plot(plot_threshold_label=True, plot_p_values=True, autoset_ylim=True)#

Plot each effect in its own panel of a new figure.

Parameters:

  • plot_threshold_label — if True (default), label inferred effect threshold lines

  • plot_p_values — if True (default), write cluster p values

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> h = spmi.plot()
plot_cluster_bars(**kwdargs)#

One row of cluster bars per effect (see spm1d.plot.plot_cluster_bars()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> ax   = spmi.plot_cluster_bars()
plot_cluster_patches(**kwdargs)#

One color of cluster bands per effect (see spm1d.plot.plot_cluster_patches()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> h = spmi.plot_cluster_patches()
plot_effects(**kwdargs)#

One panel per effect with its clusters (see spm1d.plot.plot_effects()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> h = spmi.plot_effects()
print_summary()#

Print a summary with one line per effect.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B, cov_model='iid' )
>>> spm.print_summary()
SPMList
    STAT     : F
    fn_name  : anova2
    nfactors : 2
    neffects : 3
Effects
    A     z = (101,) array       df = (1, 24)
    B     z = (101,) array       df = (2, 24)
    A:B   z = (101,) array       df = (2, 24)
set_effect_labels(labels)#

Override design effect labels.

Parameters:

  • labels — one label per effect in list order

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> spm.set_effect_labels( ['Group', 'Speed', 'Group x Speed'] )
>>> print( spm.effect_labels )
('Group', 'Speed', 'Group x Speed')
property sse#

float (0D) or (Q,) array (1D).

Type:

Fitted model error sum of squares

test_eqvar()#

Test of equal error variance across between-subject groups.

Returns:

  • EqVarResults0D or EqVarResults1D object

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( type( spm.test_eqvar() ).__name__ )
EqVarResults1D
test_normality(alpha=0.05)#

Model residual normality test (one test for all effects).

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • SPMi0D or SPMi1D object of the D’Agostino-Pearson K2 statistic

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( spm.test_normality().h0reject )
False
test_sphericity()#

Mauchly’s sphericity test (one result per within-subject effect).

Returns:

  • SphericityResultsList keyed by effect name

Example:
>>> import spm1d
>>> y, A, B, SUBJ = spm1d.rng.anova2rm( nlevels=(2, 3), nsubj=8, Q=1, seed=0 )
>>> spm = spm1d.stats.anova2rm( y, A, B, SUBJ )
>>> print( type( spm.test_sphericity() ).__name__ )
SphericityResultsList
write_to_h5group(group, with_args=False)#

Write to an open HDF5 group.

Parameters:

  • group — open h5py group

  • with_args — write input arguments if True (default False)

Returns:

  • None

Example:
>>> import h5py
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> with h5py.File( 'anova2.h5', 'w' ) as f:
...     spm.write_to_h5group( f.create_group( 'spm' ) )

Inference results#

class SPMi0D[source]#

SPM inference object.

Inference attributes (in addition to all SPM0D attributes except inference)

method

inference method: 'param' or 'perm'

isparametric

True for parametric methods and False otherwise

alpha

Type I error rate

dirn

inference direction: 0 (two-tailed), 1 or -1 (one-tailed)

zc

critical threshold

h0reject

True if z exceeds zc (in the tested direction)

p

probability value

Z

(Permutation inference only) permutation distribution of the test statistic

write_to_h5group(group, with_args=False)[source]#

Write to an open HDF5 group including inference results.

Parameters:

  • group — open h5py group

  • with_args — write input arguments if True (default False)

Returns:

  • None (read with SPMi0D._from_h5group)

Example:
>>> import h5py
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> with h5py.File( 'ttest2.h5', 'w' ) as f:
...     spmi.write_to_h5group( f.create_group( 'spmi' ) )
property STAT#

"T", "F", "T2" (Hotelling’s T2) or "X2" (chi-squared).

Type:

Test statistic type

property Z#

(Permutation inference only) Test statistic permutation distribution as a (nperm,) array.

property Z2#

(1D permutation inference only) Cluster metric permutation distribution as a (nperm,) array.

property alpha#

Type I error rate.

property contrast#

ContrastT for t statistics or ContrastF for F statistics.

Type:

Tested contrast

delete_perms()#

Remove permutation distributions Z and Z2.

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05, method='perm', nperm=200 )
>>> spmi.delete_perms()
>>> print( spmi.Z )
None
property df#

Degrees of freedom as a two-tuple (df1, df2). df1 is 1 for t statistics. Inference results with a non-sphericity or unequal-variance correction hold corrected values (uncorrected values: df_adjusted).

property df_adjusted#

Inference degrees of freedom (adjusted for non-sphericity or unequal variance).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Dependent variable dimensionality; 0 for scalar data.

property dirn#

0 (two-tailed), 1 (positive) or -1 (negative).

Type:

Tested direction

effect_size(from_model=False, **kwargs)#

Standardized effect size for this contrast.

Descriptive effect size computed before inference and ignoring the ROI.

  • T contrasts: Cohen’s d and Hedges’ g.

  • F contrasts: partial eta squared v0*F/(v0*F + v1) plus eta squared and omega squared where sums of squares are available.

  • Hotelling’s T2: Mahalanobis distance D between the compared means (multivariate Cohen’s d) and multivariate partial eta squared T2 / (T2 + df_e).

  • Wilks’ lambda (MANOVA, MANCOVA, CCA): multivariate partial eta squared 1 - lambda^(1/s) with s from Rao’s approximation. Lambda is stored as wilks.

Parameters:

  • from_model — if True, use the fitted-model standardizer instead of the classical one (default False)

Returns:

  • EffectSize object with the measure name, standardizer and values

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> es  = spm.effect_size()
>>> print( es.name, es.d.shape )
Cohen's d (101,)
Note:

  • Paired tests are fitted as one-sample tests on the differences. d is therefore standardized by the SD of the differences (d_z) and exceeds d_av when the two conditions are correlated.

  • Effect size confidence intervals are not supported.

property formula#

(Results of spm1d.stats.formula only) Formula string.

get_estimated_contrast_and_se()#

(T statistics only) Estimated contrast and its standard error.

The estimated contrast is the contrast applied to the fitted model coefficients (c @ b): mean minus datum (one-sample test), mean paired difference (paired test), difference of group means (two-sample test) or slope (regression). The standard error is that of the t statistic under its covariance model so that t = estimated_contrast / se.

Confidence intervals (Confidence intervals) are built from these two quantities.

Returns:

  • estimated_contrast — float for 0D data or (Q,) array for 1D data

  • se — its standard error with the same shape

Example:

>>> spm = spm1d.stats.ttest2( yA, yB )
>>> cb, se = spm.get_estimated_contrast_and_se()
property h0reject#

True if the test statistic exceeds zc.

property isanova#

True for a univariate F statistic (ANOVA, ANCOVA or regression F) and False for t, Hotelling’s T2 and the multivariate F of Wilks’ lambda.

isinference = True#

Always True.

property ismultigroup#

True for designs comparing two or more independent groups (ttest2, anova1 and two- and three-way designs). test_eqvar applies to these designs.

property ismultivariate#

True for a vector-valued dependent variable (Hotelling’s, MANOVA, MANCOVA, CCA).

property isparametric#

True for parametric inference.

property isregress#

True for a regress result.

property iswilks#

True when the F statistic is Rao’s F of Wilks’ lambda (MANOVA, MANCOVA, CCA).

property method#

"rft", "perm", "bonf", "uncorr" or "fdr" (1D) and "param" or "perm" (0D).

Type:

Inference method

property ms#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Effect mean square

property mse#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Error mean square

property name#

Effect or comparison name (e.g., “Main A”, “contrast 0” or post hoc label “A0 - A1”).

normality_test(alpha=0.05) — DEPRECATED#

Deprecated name of test_normality().

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

property p#

(0D results only) p value. Deprecated name of p_cluster for 1D results.

plot_design(**kwdargs)#

Plot the design matrix of this statistic (see spm1d.plot.plot_spm_design()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, seed=0 )
>>> spm  = spm1d.stats.anova1( y, A )
>>> h = spm.plot_design()
posthoc(*args, **kwargs)#

Pairwise comparisons of factor levels inferred at this result’s alpha.

For multi-factor designs use SPMiList.posthoc.

Labels such as “A0 - A1” denote first minus second.

Comparisons inherit the omnibus inference settings.

Parameters:

  • correction — (Univariate results only) 'bonf' (default) or 'scheffe'

Returns:

  • SPMPostHocList (or SPMPostHocListMV) of inferred comparisons

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> Fi  = spm1d.stats.anova1( y, A, ).inference( 0.05 )
>>> phi = Fi.posthoc()
>>> print( len( phi ), phi[0].name )
3 A0 - A1
Note:

  • SPM1DPostHocError is raised for glm and formula results, for methods “uncorr”, “bonf”, “fdr” and “perm”, for post hoc comparisons, for one-way designs with two levels and when the omnibus null hypothesis is not rejected.

print_zc_comparison(*others, labels=None)#

Print critical heights zc of this and other inference results.

Parameters:

  • others — inference results or lists of inference results

  • labels — row labels (default None)

Returns:

  • None

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> Fi = spm1d.stats.anova1( y, A ).inference( 0.05 )
>>> ti = spm1d.stats.ttest2( y[A==2], y[A==0] ).inference( 0.05 )
>>> Fi.print_zc_comparison( ti, labels=['ANOVA', 'ttest2: A2 - A0'] )
analysis         STAT  df               FWHM     resels  zc
---------------  ----  ---------------  -------  ------  ------
ANOVA            F     (1.971, 20.395)  20.7814  4.8120  7.4168
ttest2: A2 - A0  T     (1, 13.444)      19.9770  5.0058  3.5029
...
property residuals#

(J,) array (0D) or (J,Q) array (1D).

Type:

Fitted model residuals

save_h5(fpath, with_args=False)#

Save to an HDF5 file (read with spm1d.io.load()).

Parameters:

  • fpath — HDF5 file path

  • with_args — if True, also save procedure input arguments (default False)

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> spm.save_h5( 'ttest2.h5' )
>>> loaded = spm1d.io.load( 'ttest2.h5' )
property ss#

(ANOVA F statistics only) Effect sum of squares.

property sse#

(ANOVA F statistics only) Error sum of squares.

test_eqvar()#

Test of equal error variance across between-subject groups.

  • Between-subject designs, Bartlett’s test.

  • Mixed designs: Box’s M test of the within-subject covariance matrices of between-subject groups.

  • Designs without between-subject groups are unsupported and raise an SPM1DError.

Returns:

  • EqVarResults0D or EqVarResults1D object.

Example:
>>> spm = spm1d.stats.anova1(y, A)
>>> print( spm.test_eqvar() )
Note:

  • The test uses the SPM data.

  • Bartlett’s test generalizes the two-sample F test of variances (spm1d.stats.eqvartest) to any number of cells.

  • 1D data: statistic continuum thresholded using random field theory.

test_normality(alpha=0.05)#

Test residual normality.

Saturated designs: reduced-model residuals (without subject-condition interactions) are tested instead.

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • SPMi0D or SPMi1D object of the D’Agostino-Pearson K2 statistic.

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> print( spm.test_normality().h0reject )
False
test_sphericity()#

(Repeated-measures designs only) Mauchly’s sphericity test.

Returns:

  • SphericityResults0D or SphericityResults1D object. Mixed designs: within-cell covariance pooled across between-subject groups.

Example:
>>> spm = spm1d.stats.anova1rm(y, A, S)
>>> print( spm.test_sphericity() )
Note:

  • For 1D sphericity tests there should be at least 8 subjects.

property z#

float (0D) or (Q,) array (1D). Masked array for ROI analyses.

Type:

Test statistic

property zc#

Critical test statistic value (negative for dirn=-1).

property zstar — DEPRECATED#

Deprecated name of zc.

design#

Design object (design matrix, contrasts and factors) from which the statistic was computed.

fn_name#

Name of the spm1d.stats function that produced the result ("ttest2", "anova1", …). "formula" for formula results.

fit#

Fitted model with parameter estimates, residuals and variance estimates.

roi#

Region of interest (a boolean (Q,) array) if present, otherwise None (whole domain).

r#

Correlation coefficient (regress results only).

class SPMi1D[source]#

SPM inference object.

Inference attributes (in addition to all SPM1D attributes except inference)

method

inference method: 'rft', 'perm', 'fdr', 'bonf' or 'uncorr'

isparametric

True for parametric methods and False otherwise

alpha

Type I error rate

dirn

inference direction: 0 (two-tailed), 1 or -1 (one-tailed)

zc

critical threshold

zmax

test statistic continuum maximum in the tested direction

h0reject

True if zmax exceeds zc

p_zmax

continuum-level probability

p_set

(Random field theory only) set-level probability

p_cluster

cluster-level probabilities if present, otherwise None

p_point

point-level probabilities

clusters

list of suprathreshold clusters

nclusters

number of suprathreshold clusters

Z

(Permutation inference only) permutation distribution of the test statistic

Z2

(Permutation inference only) permutation distribution of the cluster metric

property clusters#

List of suprathreshold ClusterWithInference objects in domain order (see Clusters).

property nclusters#

Number of suprathreshold clusters.

property p — DEPRECATED#

Deprecated name of p_cluster.

property p_cluster#

Cluster-level p values in clusters order.

property p_set#

(RFT inference only) Set-level p value.

property p_zmax#

Field maximum (zmax) p value.

property p_point#

Point-level p values.

RFT point-level p values are accurate only for small p values (see the “Reporting p values” theory page).

plot(**kwdargs)[source]#

Plot the statistic, critical threshold and clusters (see spm1d.plot.plot_spmi()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> h = spmi.plot()
plot_barh(**kwdargs)[source]#

Attach a cluster bar strip to an axes (see spm1d.plot.plot_cluster_barh()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> h = spmi.plot_barh()
plot_cluster_bars(**kwdargs)[source]#

Plot clusters as bars (see spm1d.plot.plot_cluster_bars()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> ax   = spmi.plot_cluster_bars()
plot_cluster_patches(**kwdargs)[source]#

Plot clusters as vertical bands (see spm1d.plot.plot_cluster_patches()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> h = spmi.plot_cluster_patches()
plot_p_values(**kwdargs)[source]#

Write cluster p values (see spm1d.plot.plot_spmi_p_values()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> h = spmi.plot()
>>> h = spmi.plot_p_values()
plot_threshold_label(**kwdargs)[source]#

Write the critical threshold and alpha beside the threshold line (see spm1d.plot.plot_spmi_threshold_label()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> h = spmi.plot()
>>> h = spmi.plot_threshold_label()
write_to_h5group(group, with_args=False)[source]#

Write to an open HDF5 group including inference results.

Parameters:

  • group — open h5py group

  • with_args — write input arguments if True (default False)

Returns:

  • None (read with SPMi1D._from_h5group)

Example:
>>> import h5py
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05 )
>>> with h5py.File( 'ttest2.h5', 'w' ) as f:
...     spmi.write_to_h5group( f.create_group( 'spmi' ) )
property zmax#

Field extreme in the tested direction.

property Q#

Number of domain nodes (length of z).

property STAT#

"T", "F", "T2" (Hotelling’s T2) or "X2" (chi-squared).

Type:

Test statistic type

property Z#

(Permutation inference only) Test statistic permutation distribution as a (nperm,) array.

property Z2#

(1D permutation inference only) Cluster metric permutation distribution as a (nperm,) array.

property alpha#

Type I error rate.

property contrast#

ContrastT for t statistics or ContrastF for F statistics.

Type:

Tested contrast

delete_perms()#

Remove permutation distributions Z and Z2.

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.ttest2( y0, y1 ).inference( 0.05, method='perm', nperm=200 )
>>> spmi.delete_perms()
>>> print( spmi.Z )
None
property df#

Degrees of freedom as a two-tuple (df1, df2). df1 is 1 for t statistics. Inference results with a non-sphericity or unequal-variance correction hold corrected values (uncorrected values: df_adjusted).

property df_adjusted#

Inference degrees of freedom (adjusted for non-sphericity or unequal variance).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Dimensionality of the dependent variable. 0 for scalar data and 1 for continuum (1D) data.

property dirn#

0 (two-tailed), 1 (positive) or -1 (negative).

Type:

Tested direction

effect_size(from_model=False, **kwargs)#

Standardized effect size for this contrast.

Descriptive effect size computed before inference and ignoring the ROI.

  • T contrasts: Cohen’s d and Hedges’ g.

  • F contrasts: partial eta squared v0*F/(v0*F + v1) plus eta squared and omega squared where sums of squares are available.

  • Hotelling’s T2: Mahalanobis distance D between the compared means (multivariate Cohen’s d) and multivariate partial eta squared T2 / (T2 + df_e).

  • Wilks’ lambda (MANOVA, MANCOVA, CCA): multivariate partial eta squared 1 - lambda^(1/s) with s from Rao’s approximation. Lambda is stored as wilks.

Parameters:

  • from_model — if True, use the fitted-model standardizer instead of the classical one (default False)

Returns:

  • EffectSize object with the measure name, standardizer and values

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> es  = spm.effect_size()
>>> print( es.name, es.d.shape )
Cohen's d (101,)
Note:

  • Paired tests are fitted as one-sample tests on the differences. d is therefore standardized by the SD of the differences (d_z) and exceeds d_av when the two conditions are correlated.

  • Effect size confidence intervals are not supported.

property formula#

(Results of spm1d.stats.formula only) Formula string.

property fwhm#

Estimated residual smoothness as the full width at half maximum of a Gaussian kernel.

get_estimated_contrast_and_se()#

(T statistics only) Estimated contrast and its standard error.

The estimated contrast is the contrast applied to the fitted model coefficients (c @ b): mean minus datum (one-sample test), mean paired difference (paired test), difference of group means (two-sample test) or slope (regression). The standard error is that of the t statistic under its covariance model so that t = estimated_contrast / se.

Confidence intervals (Confidence intervals) are built from these two quantities.

Returns:

  • estimated_contrast — float for 0D data or (Q,) array for 1D data

  • se — its standard error with the same shape

Example:

>>> spm = spm1d.stats.ttest2( yA, yB )
>>> cb, se = spm.get_estimated_contrast_and_se()
property h0reject#

True if the test statistic exceeds zc.

property isanova#

True for a univariate F statistic (ANOVA, ANCOVA or regression F) and False for t, Hotelling’s T2 and the multivariate F of Wilks’ lambda.

isinference = True#

Always True.

property ismultigroup#

True for designs comparing two or more independent groups (ttest2, anova1 and two- and three-way designs). test_eqvar applies to these designs.

property ismultivariate#

True for a vector-valued dependent variable (Hotelling’s, MANOVA, MANCOVA, CCA).

property isparametric#

True for parametric inference.

property isregress#

True for a regress result.

property iswilks#

True when the F statistic is Rao’s F of Wilks’ lambda (MANOVA, MANCOVA, CCA).

property lkc#

Estimated residual Lipschitz-Killing curvature (smoothness measure for RFT inference described in Smoothness estimation).

property method#

"rft", "perm", "bonf", "uncorr" or "fdr" (1D) and "param" or "perm" (0D).

Type:

Inference method

property ms#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Effect mean square

property mse#

float (0D) or (Q,) array (1D).

Type:

(ANOVA F statistics only) Error mean square

property name#

Effect or comparison name (e.g., “Main A”, “contrast 0” or post hoc label “A0 - A1”).

normality_test(alpha=0.05) — DEPRECATED#

Deprecated name of test_normality().

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

plot_design(**kwdargs)#

Plot the design matrix and contrast (see spm1d.plot.plot_spm_design()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> spm = spm1d.stats.anova1( y, A )
>>> h = spm.plot_design()
plot_effect(**kwdargs)#

Plot ANOVA effect data and clusters (see spm1d.plot.plot_effect()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> h = spm[0].plot_effect()
posthoc(*args, **kwargs)#

Pairwise comparisons of factor levels inferred at this result’s alpha.

For multi-factor designs use SPMiList.posthoc.

Labels such as “A0 - A1” denote first minus second.

Comparisons inherit the omnibus inference settings.

Parameters:

  • correction — (Univariate results only) 'bonf' (default) or 'scheffe'

Returns:

  • SPMPostHocList (or SPMPostHocListMV) of inferred comparisons

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> Fi  = spm1d.stats.anova1( y, A, ).inference( 0.05 )
>>> phi = Fi.posthoc()
>>> print( len( phi ), phi[0].name )
3 A0 - A1
Note:

  • SPM1DPostHocError is raised for glm and formula results, for methods “uncorr”, “bonf”, “fdr” and “perm”, for post hoc comparisons, for one-way designs with two levels and when the omnibus null hypothesis is not rejected.

print_zc_comparison(*others, labels=None)#

Print critical heights zc of this and other inference results.

Parameters:

  • others — inference results or lists of inference results

  • labels — row labels (default None)

Returns:

  • None

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> Fi = spm1d.stats.anova1( y, A ).inference( 0.05 )
>>> ti = spm1d.stats.ttest2( y[A==2], y[A==0] ).inference( 0.05 )
>>> Fi.print_zc_comparison( ti, labels=['ANOVA', 'ttest2: A2 - A0'] )
analysis         STAT  df               FWHM     resels  zc
---------------  ----  ---------------  -------  ------  ------
ANOVA            F     (1.971, 20.395)  20.7814  4.8120  7.4168
ttest2: A2 - A0  T     (1, 13.444)      19.9770  5.0058  3.5029
...
property resels#

Resolution element counts (resels0, resels1).

property residuals#

(J,) array (0D) or (J,Q) array (1D).

Type:

Fitted model residuals

save_h5(fpath, with_args=False)#

Save to an HDF5 file (read with spm1d.io.load()).

Parameters:

  • fpath — HDF5 file path

  • with_args — if True, also save procedure input arguments (default False)

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> spm.save_h5( 'ttest2.h5' )
>>> loaded = spm1d.io.load( 'ttest2.h5' )
property ss#

(ANOVA F statistics only) Effect sum of squares.

property sse#

(ANOVA F statistics only) Error sum of squares.

test_eqvar()#

Test of equal error variance across between-subject groups.

  • Between-subject designs, Bartlett’s test.

  • Mixed designs: Box’s M test of the within-subject covariance matrices of between-subject groups.

  • Designs without between-subject groups are unsupported and raise an SPM1DError.

Returns:

  • EqVarResults0D or EqVarResults1D object.

Example:
>>> spm = spm1d.stats.anova1(y, A)
>>> print( spm.test_eqvar() )
Note:

  • The test uses the SPM data.

  • Bartlett’s test generalizes the two-sample F test of variances (spm1d.stats.eqvartest) to any number of cells.

  • 1D data: statistic continuum thresholded using random field theory.

test_normality(alpha=0.05)#

Test residual normality.

Saturated designs: reduced-model residuals (without subject-condition interactions) are tested instead.

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • SPMi0D or SPMi1D object of the D’Agostino-Pearson K2 statistic.

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.ttest2( y0, y1 )
>>> print( spm.test_normality().h0reject )
False
test_sphericity()#

(Repeated-measures designs only) Mauchly’s sphericity test.

Returns:

  • SphericityResults0D or SphericityResults1D object. Mixed designs: within-cell covariance pooled across between-subject groups.

Example:
>>> spm = spm1d.stats.anova1rm(y, A, S)
>>> print( spm.test_sphericity() )
Note:

  • For 1D sphericity tests there should be at least 8 subjects.

property z#

float (0D) or (Q,) array (1D). Masked array for ROI analyses.

Type:

Test statistic

property zc#

Critical test statistic value (negative for dirn=-1).

property zstar — DEPRECATED#

Deprecated name of zc.

design#

Design object (design matrix, contrasts and factors) from which the statistic was computed.

fn_name#

Name of the spm1d.stats function that produced the result ("ttest2", "anova1", …). "formula" for formula results.

fit#

Fitted model with parameter estimates, residuals and variance estimates.

roi#

Region of interest (a boolean (Q,) array) if present, otherwise None (whole domain).

r#

Correlation coefficient (regress results only).

class SPMiList[source]#

List of SPM inference objects (one per effect).

name = 'SPM inference list'#

List type as printed.

delete_perms()[source]#

Remove permutation distributions Z and Z2 from all effects.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B, cov_model='iid' ).inference( 0.05, method='perm', nperm=200 )
>>> spmi.delete_perms()
get_h0reject_values()[source]#

Null hypothesis rejection decisions of all effects.

Returns:

  • Tuple of booleans in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> print( spmi.get_h0reject_values() )
(False, False, False)
get_p_values()[source]#

P values of all effects.

Returns:

  • Tuple in list order (cluster-level p values for 1D data)

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> print( spmi.get_p_values() )
(None, None, None)
get_zc_values()[source]#

Critical thresholds of all effects.

Returns:

  • Tuple of zc values in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B, cov_model='iid' ).inference( 0.05 )
>>> print( [round( zc, 3 ) for zc in spmi.get_zc_values()] )
[9.934, 6.996, 6.996]
get_zstar_values() — DEPRECATED[source]#

Deprecated v0.4 name of get_zc_values().

Returns:

property h0reject#

True if the null hypothesis is rejected for at least one effect.

posthoc(*args, **kwargs)[source]#

Pairwise comparisons of the levels of one factor.

Subject and nested factors cannot be compared.

Parameters:

  • factor — factor name (e.g., 'A', 'B')

  • correction — (Univariate results only) 'bonf' (default) or 'scheffe'

Returns:

  • SPMPostHocList (or SPMPostHocListMV) of inferred comparisons

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=8, Q=1, mu=[[0, 0, 3], [0, 0, 3]], seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B, cov_model='iid' ).inference( 0.05 )
>>> phi  = spmi.posthoc( 'B' )
>>> print( len( phi ), phi[0].name )
3 B0 - B1
print_table()[source]#

(0D results only) Print a classical ANOVA table.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=1, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B, cov_model='iid' ).inference( 0.05 )
>>> spmi.print_table()
Source      DF       SS       MS        F        P
A        1.000    0.387    0.387    0.625    0.437
B        2.000    3.988    1.994    3.223    0.058
A:B      2.000    0.422    0.211    0.341    0.714
Error   ...
property STAT#

Effect statistic type (F).

property contrasts#

Design contrasts (ContrastF objects) in list order.

property design#

Design object shared by all effects.

property dfe#

Error degrees of freedom of the first effect.

property dim#

Dependent variable dimensionality (0 or 1).

property effect_labels#

Effect labels in list order.

property effect_labels_short#

Short labels (A, B, A:B) in list order if available, otherwise None.

effect_size(from_model=False, **kwargs)#

Standardized effect size of all effects.

Parameters:

  • from_model — as for effect_size of a single result (default False)

Returns:

  • List of EffectSize objects in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> ess = spm.effect_size()
>>> print( len( ess ), ess[0].name )
3 partial eta squared
property fit#

Fitted model shared by all effects.

property fn_name#

Name of the spm1d.stats function.

property formula#

(Lists produced by spm1d.stats.formula only) Formula string.

get_df_values()#

Degrees of freedom of all effects.

Returns:

  • List of (df1, df2) tuples in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B, cov_model='iid' )
>>> print( spm.get_df_values() )
[(1, 24), (2, 24), (2, 24)]
get_effect_labels()#

Effect labels (same as effect_labels).

Returns:

  • Tuple of labels in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( spm.get_effect_labels() )
('Main A', 'Main B', 'Interaction A:B')
get_f_values()#

Test statistics of all effects.

Returns:

  • Tuple of statistics (z) in list order

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( [z.shape for z in spm.get_f_values()] )
[(101,), (101,), (101,)]
isparametric = True#

True for parametric inference (rft or param).

property mse#

float (0D) or (Q,) array (1D).

Type:

Fitted model error mean square

property ncontrasts#

Number of contrasts (same as neffects).

property neffects#

Number of effects (list length).

property nfactors#

Number of experimental factors (excluding the subject factor).

normality_test(alpha=0.05) — DEPRECATED#

Deprecated name of test_normality().

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

plot(plot_threshold_label=True, plot_p_values=True, autoset_ylim=True)#

Plot each effect in its own panel of a new figure.

Parameters:

  • plot_threshold_label — if True (default), label inferred effect threshold lines

  • plot_p_values — if True (default), write cluster p values

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> h = spmi.plot()
plot_cluster_bars(**kwdargs)#

One row of cluster bars per effect (see spm1d.plot.plot_cluster_bars()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> ax   = spmi.plot_cluster_bars()
plot_cluster_patches(**kwdargs)#

One color of cluster bands per effect (see spm1d.plot.plot_cluster_patches()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> h = spmi.plot_cluster_patches()
plot_effects(**kwdargs)#

One panel per effect with its clusters (see spm1d.plot.plot_effects()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spmi = spm1d.stats.anova2( y, A, B ).inference( 0.05 )
>>> h = spmi.plot_effects()
print_summary()#

Print a summary with one line per effect.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B, cov_model='iid' )
>>> spm.print_summary()
SPMList
    STAT     : F
    fn_name  : anova2
    nfactors : 2
    neffects : 3
Effects
    A     z = (101,) array       df = (1, 24)
    B     z = (101,) array       df = (2, 24)
    A:B   z = (101,) array       df = (2, 24)
set_effect_labels(labels)#

Override design effect labels.

Parameters:

  • labels — one label per effect in list order

Returns:

  • None

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> spm.set_effect_labels( ['Group', 'Speed', 'Group x Speed'] )
>>> print( spm.effect_labels )
('Group', 'Speed', 'Group x Speed')
property sse#

float (0D) or (Q,) array (1D).

Type:

Fitted model error sum of squares

test_eqvar()#

Test of equal error variance across between-subject groups.

Returns:

  • EqVarResults0D or EqVarResults1D object

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( type( spm.test_eqvar() ).__name__ )
EqVarResults1D
test_normality(alpha=0.05)#

Model residual normality test (one test for all effects).

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • SPMi0D or SPMi1D object of the D’Agostino-Pearson K2 statistic

Example:
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> print( spm.test_normality().h0reject )
False
test_sphericity()#

Mauchly’s sphericity test (one result per within-subject effect).

Returns:

  • SphericityResultsList keyed by effect name

Example:
>>> import spm1d
>>> y, A, B, SUBJ = spm1d.rng.anova2rm( nlevels=(2, 3), nsubj=8, Q=1, seed=0 )
>>> spm = spm1d.stats.anova2rm( y, A, B, SUBJ )
>>> print( type( spm.test_sphericity() ).__name__ )
SphericityResultsList
write_to_h5group(group, with_args=False)#

Write to an open HDF5 group.

Parameters:

  • group — open h5py group

  • with_args — write input arguments if True (default False)

Returns:

  • None

Example:
>>> import h5py
>>> import spm1d
>>> y, A, B = spm1d.rng.anova2( nlevels=(2, 3), nsubj=5, Q=101, fwhm=20, seed=0 )
>>> spm = spm1d.stats.anova2( y, A, B )
>>> with h5py.File( 'anova2.h5', 'w' ) as f:
...     spm.write_to_h5group( f.create_group( 'spm' ) )

SPM object attributes#

class EffectSize[source]#

Effect size object.

Attributes:
  • z — primary effect size measure: scalar (0D) or field (1D)

  • name — name of the z measure

  • standardizer — classical or model (see SPM.effect_size)

  • d, g — Cohen’s d and Hedges’ g (t contrasts only)

  • eta2p, eta2, omega2 — partial eta squared, eta squared and omega squared (F contrasts only)

  • D — Mahalanobis distance (Hotelling’s T2 only)

  • wilks — Wilks’ lambda (MANOVA, MANCOVA and CCA only)

  • df — degrees of freedom of the contrast

  • dim — data dimensionality (0 or 1)

d = None#

Cohen’s d (t contrasts only).

g = None#

Hedges’ g (t contrasts only).

eta2p = None#

Partial eta squared (F contrasts only).

eta2 = None#

Eta squared (ANOVA F contrasts only).

omega2 = None#

Omega squared (ANOVA F contrasts only).

D = None#

Mahalanobis distance (Hotelling’s T2 only).

wilks = None#

Wilks’ lambda (MANOVA, MANCOVA and CCA effects only).

z#

float (0D) or (Q,) array (1D). Measure name: name.

Type:

Effect size

name#

Name of the z measure (e.g., “Cohen’s d”).

standardizer#

"classical" (pooled sample SD) or "model" (fitted model error variance).

Type:

Standardizer

df#

Contrast degrees of freedom as (df1, df2).

dim#

Data dimensionality (0 or 1).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

plot(ax=None, **kwargs)[source]#

Plot the 1D effect size field z (see spm1d.plot.plot_effectsize()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> es = spm1d.stats.ttest2( y0, y1 ).effect_size()
>>> ax = es.plot()
class InferenceResults0D[source]#

Inference results for a 0D test statistic.

Attributes

method

inference method: 'param' or 'perm'

isparametric

True for parametric methods and False otherwise

STAT

test statistic type: 'T', 'F', 'T2' or 'X2'

z

test statistic value

df

degrees of freedom (None for permutation inference)

alpha

Type I error rate

dirn

inference direction: 0 (two-tailed), 1 or -1 (one-tailed)

zc

critical threshold as a positive value

zcs

signed critical threshold

h0reject

True if z exceeds zc in the tested direction

p

probability value

extras

method-specific parameters (e.g., nperm)

Z

(Permutation inference only) permutation distribution of the test statistic

property h0reject#

True if z exceeds zc in the tested direction.

isequal(other, verbose=False)[source]#

Equality with another inference result.

Parameters:

  • other — other inference result

  • verbose — if True, print the first unequal attribute name (default False)

Returns:

  • True if other holds identical inference results, otherwise False

Example:
>>> import spm1d
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.param( 'T', t.z, t.df )
>>> other = spm1d.prob.param( 'T', t.z, t.df )
>>> print( results.isequal( other ) )
True
delete_perms()#

Remove permutation distributions Z and Z2.

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> results.delete_perms()
static from_h5group(group)#

Read results from an open HDF5 group.

Parameters:

  • group — open h5py group

Returns:

  • InferenceResults0D or InferenceResults1D object

Example:
>>> import h5py
>>> import spm1d
>>> from spm1d.prob._results import InferenceResults1D
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> with h5py.File( 'results.h5', 'w' ) as f:
...     results.write_to_h5group( f.create_group( 'results' ) )
>>> with h5py.File( 'results.h5', 'r' ) as f:
...     loaded = InferenceResults1D.from_h5group( f['results'] )
>>> print( results.isequal( loaded ) )
True
write_to_h5group(group)#

Write results to an open HDF5 group.

Parameters:

  • group — open h5py group

Returns:

  • None

Example:
>>> import h5py
>>> import spm1d
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> with h5py.File( 'results.h5', 'w' ) as f:
...     results.write_to_h5group( f.create_group( 'results' ) )
property zcs#

-zc if dirn is -1, otherwise zc.

Type:

Signed critical threshold

class InferenceResults1D[source]#

Inference results for a 1D test statistic field.

Attributes

method

inference method: 'rft', 'perm', 'fdr', 'bonf' or 'uncorr'

isparametric

True for parametric methods and False otherwise

STAT

test statistic type: 'T', 'F', 'T2' or 'X2'

z

(Q,) test statistic field

df

degrees of freedom (None for permutation inference)

alpha

Type I error rate

dirn

inference direction: 0 (two-tailed), 1 or -1 (one-tailed)

zc

critical threshold as a positive value

zcs

signed critical threshold

h0reject

True if zmax exceeds zc

p_set

set-level probability (None for 'fdr', 'bonf' and 'uncorr')

p_cluster

cluster-level probabilities if present, otherwise None

p_point

point-level probabilities (None for 'rft')

clusters

list of suprathreshold clusters (see Clusters)

nclusters

number of suprathreshold clusters

hasclusters

True if there is at least one suprathreshold cluster

hasiclusters

True if the clusters have cluster-level probabilities

extras

method-specific parameters (e.g., nperm)

Z

(Permutation inference only) permutation distribution of the test statistic

Z2

(Permutation inference only) permutation distribution of the cluster metric

property h0reject#

True if zmax exceeds zc in the tested direction.

property hasclusters#

True if there is at least one suprathreshold cluster.

property hasiclusters#

True if clusters have cluster-level probabilities.

isequal(other, verbose=False)[source]#

Equality with another inference result.

Parameters:

  • other — other inference result

  • verbose — if True, print the first unequal attribute name (default False)

Returns:

  • True if other holds identical inference results, otherwise False

Example:
>>> import spm1d
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> other = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> print( results.isequal( other ) )
True
property nclusters#

Number of suprathreshold clusters.

property p_cluster#

Cluster-level probabilities if present, otherwise None.

property p_zmax#

P value of the test statistic extreme (zmax).

property zmax#

Test statistic field extreme in the tested direction.

delete_perms()#

Remove permutation distributions Z and Z2.

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> results.delete_perms()
static from_h5group(group)#

Read results from an open HDF5 group.

Parameters:

  • group — open h5py group

Returns:

  • InferenceResults0D or InferenceResults1D object

Example:
>>> import h5py
>>> import spm1d
>>> from spm1d.prob._results import InferenceResults1D
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> with h5py.File( 'results.h5', 'w' ) as f:
...     results.write_to_h5group( f.create_group( 'results' ) )
>>> with h5py.File( 'results.h5', 'r' ) as f:
...     loaded = InferenceResults1D.from_h5group( f['results'] )
>>> print( results.isequal( loaded ) )
True
write_to_h5group(group)#

Write results to an open HDF5 group.

Parameters:

  • group — open h5py group

Returns:

  • None

Example:
>>> import h5py
>>> import spm1d
>>> y0, y1  = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> t       = spm1d.stats.ttest2( y0, y1 )
>>> results = spm1d.prob.rft( 'T', t.z, t.df, t.fwhm, t.resels )
>>> with h5py.File( 'results.h5', 'w' ) as f:
...     results.write_to_h5group( f.create_group( 'results' ) )
property zcs#

-zc if dirn is -1, otherwise zc.

Type:

Signed critical threshold

class ClusterList[source]#

List of ClusterWithInference objects.

sort()[source]#

Clusters in domain order (unlike list.sort the list is unchanged).

Returns:

  • New ClusterList sorted by position

Example:
>>> import numpy as np
>>> import spm1d
>>> z = np.zeros( 101 )
>>> z[10:20], z[60:70] = 5, 5
>>> clusters = spm1d.geom.assemble_clusters( z, 3.5 )
>>> print( len( clusters.sort() ) )
2
class ClusterWithInference[source]#

Suprathreshold cluster with inference results.

property centroid#

Cluster centroid (x, z).

property endpoints#

Interpolated cluster start and end positions (x0, x1) in domain nodes.

property extent#

Cluster width x1 - x0 in domain nodes (1 for single-node clusters).

property height#

Least extreme cluster value (threshold when interpolated). Same as min.

property integral#

Area between the statistic and threshold.

iswrapped = False#

True for clusters wrapping around the ends of a circular domain.

property max#

Most extreme cluster statistic value (minimum for negative clusters).

metric = None#

Size measure the cluster-level p-value was computed from. Resel extent for rft, the value of the metric_type metric for perm and None for fdr.

metric_type = None#

Name of metric. This is "extent_resels" for rft, the permutation metric ("max", "extent" or "integral") for perm and None for fdr.

property min#

Least extreme cluster statistic value (threshold when interpolated).

property nnodes#

Number of cluster nodes (excluding interpolated end points).

p = None#

Cluster-level p-value. This is the probability that a null field would produce a cluster at least this large. None for fdr inference.

sign = None#

1 (z > zc) or -1 (z < -zc).

Type:

Cluster sign

z = None#

Test statistic values at cluster nodes including the two interpolated threshold end points.

class WrappedClusterWithInference[source]#

Wrapped cluster with inference results (same members as ClusterWithInference).

property centroid#

Cluster centroid (x, z).

property endpoints#

Interpolated cluster start and end positions (x0, x1) in domain nodes.

property extent#

Cluster width x1 - x0 in domain nodes (1 for single-node clusters).

property height#

Least extreme cluster value (threshold when interpolated). Same as min.

property integral#

Area between the statistic and threshold.

iswrapped = True#

True for clusters wrapping around the ends of a circular domain.

property max#

Most extreme cluster statistic value (minimum for negative clusters).

metric = None#

Size measure the cluster-level p-value was computed from. Resel extent for rft, the value of the metric_type metric for perm and None for fdr.

metric_type = None#

Name of metric. This is "extent_resels" for rft, the permutation metric ("max", "extent" or "integral") for perm and None for fdr.

property min#

Least extreme cluster statistic value (threshold when interpolated).

property nnodes#

Number of cluster nodes (excluding interpolated end points).

p = None#

Cluster-level p-value. This is the probability that a null field would produce a cluster at least this large. None for fdr inference.

sign = None#

1 (z > zc) or -1 (z < -zc).

Type:

Cluster sign

z = None#

Test statistic values at cluster nodes including the two interpolated threshold end points.

Post hoc results#

class SPMPostHocList[source]#

SPM.posthoc() result with one SPM per pairwise comparison.

The list is read-only.

name = 'SPM post hoc list'#

List type as printed.

property alpha_omnibus#

Omnibus test Type I error rate.

bonferroni(alpha=0.05)[source]#

Bonferroni-corrected alpha for this many comparisons.

Parameters:

  • alpha — Type I error rate (default 0.05)

Returns:

  • alpha / ncomparisons

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> print( round( phi.bonferroni(), 4 ) )
0.0167
property correction#

bonf or scheffe (omnibus for multivariate lists).

Type:

Threshold correction

property factor#

Factor whose levels are compared.

property labels#

Tuple of comparison labels in list order.

property ncomparisons#

Number of pairwise comparisons (list length).

property omnibus#

Omnibus F SPM of the compared factor.

plot_cluster_bars(**kwdargs)[source]#

One row of cluster bars per comparison (see spm1d.plot.plot_cluster_bars()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> ax  = phi.plot_cluster_bars()
plot_cluster_bars_colorsplit(**kwdargs)[source]#

One row of cluster bars per comparison (see spm1d.plot.plot_cluster_bars_colorsplit()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> ax  = phi.plot_cluster_bars_colorsplit()
plot_cluster_patches(**kwdargs)[source]#

One color of cluster bands per comparison (see spm1d.plot.plot_cluster_patches()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> h = phi.plot_cluster_patches()
print_summary()[source]#

Print the list header and one line per comparison.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> phi.print_summary()
SPM post hoc list  (factor A, correction bonf)
    df   = (1, 20.395)
    FWHM = 20.7814
    zc   = 3.7574
Comparisons (T):
    A0 - A1   zmax=1.279   h0reject=False
    A0 - A2   zmax=-5.561   h0reject=True
    A1 - A2   zmax=-5.683   h0reject=True
print_table()[source]#

Print comparisons as a table.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> phi.print_table()
SPM post hoc list:  factor A,  correction bonf
comparison        zc      t max    p_zmax    pc-adj   clusters  h0reject
A0 - A1        3.757      1.279    1.0000    0.0167          0  False
A0 - A2        3.757     -5.561    <0.001    0.0167          2  True
A1 - A2        3.757     -5.683    <0.001    0.0167          2  True
pc-adj = adjusted critical p-value
table()[source]#

Text table with one row per comparison.

p is the uncorrected p value and pc-adj is the adjusted critical p value.

Returns:

  • Table as a string

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> print( phi.table().splitlines()[0] )
SPM post hoc list:  factor A,  correction bonf
append(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

extend(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

insert(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

remove(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

pop(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

clear(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

sort(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

reverse(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

class SPMPostHocListMV[source]#

SPM.posthoc() result for multivariate inference results.

Items are component t tests or pairwise Hotelling’s T2 tests.

name = 'SPM multivariate post hoc list'#

List type as printed.

bonferroni(alpha=0.05)[source]#

Not available for multivariate post hoc lists.

Parameters:

  • alpha — ignored

Returns:

  • Nothing. Raises SPM1DPostHocError

property loadings#

Unit-length direction of maximal omnibus separation.

Not available for pairwise MANOVA lists (use phi[k].posthoc().loadings).

property zc#

Post hoc threshold on the T2 scale (component t tests use its square root).

property alpha_omnibus#

Omnibus test Type I error rate.

append(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

clear(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

property correction#

bonf or scheffe (omnibus for multivariate lists).

Type:

Threshold correction

extend(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

property factor#

Factor whose levels are compared.

insert(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

property labels#

Tuple of comparison labels in list order.

property ncomparisons#

Number of pairwise comparisons (list length).

property omnibus#

Omnibus F SPM of the compared factor.

plot_cluster_bars(**kwdargs)#

One row of cluster bars per comparison (see spm1d.plot.plot_cluster_bars()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> ax  = phi.plot_cluster_bars()
plot_cluster_bars_colorsplit(**kwdargs)#

One row of cluster bars per comparison (see spm1d.plot.plot_cluster_bars_colorsplit()).

Parameters:

Returns:

  • Axes

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> ax  = phi.plot_cluster_bars_colorsplit()
plot_cluster_patches(**kwdargs)#

One color of cluster bands per comparison (see spm1d.plot.plot_cluster_patches()).

Parameters:

Returns:

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> h = phi.plot_cluster_patches()
pop(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

print_summary()#

Print the list header and one line per comparison.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> phi.print_summary()
SPM post hoc list  (factor A, correction bonf)
    df   = (1, 20.395)
    FWHM = 20.7814
    zc   = 3.7574
Comparisons (T):
    A0 - A1   zmax=1.279   h0reject=False
    A0 - A2   zmax=-5.561   h0reject=True
    A1 - A2   zmax=-5.683   h0reject=True
print_table()#

Print comparisons as a table.

Returns:

  • None

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> phi.print_table()
SPM post hoc list:  factor A,  correction bonf
comparison        zc      t max    p_zmax    pc-adj   clusters  h0reject
A0 - A1        3.757      1.279    1.0000    0.0167          0  False
A0 - A2        3.757     -5.561    <0.001    0.0167          2  True
A1 - A2        3.757     -5.683    <0.001    0.0167          2  True
pc-adj = adjusted critical p-value
remove(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

reverse(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

sort(*args, **kwargs)#

Not available (read-only list). Raises SPM1DTypeError.

table()#

Text table with one row per comparison.

p is the uncorrected p value and pc-adj is the adjusted critical p value.

Returns:

  • Table as a string

Example:
>>> import spm1d
>>> y, A = spm1d.rng.anova1( nlevels=3, nsubj=8, Q=101, fwhm=20, mu=[0, 0, 2], seed=0 )
>>> phi = spm1d.stats.anova1( y, A ).inference( 0.05 ).posthoc()
>>> print( phi.table().splitlines()[0] )
SPM post hoc list:  factor A,  correction bonf

Diagnostics#

class EqVarResults0D[source]#

Equal-variance test result for 0D data.

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

effect = None#

Within-subject effect label (e.g., "A", "A:B").

STAT#

"X2" (chi-squared).

Type:

Test statistic type

z#

Chi-squared value.

df#

Degrees of freedom (1, df).

p#

p value.

class EqVarResults1D[source]#

Equal-variance test result for 1D data.

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

effect = None#

Within-subject effect label (e.g., "A", "A:B").

property p#

Field maximum p value (smallest p_point).

property zmax#

Maximum of the chi-squared field.

STAT#

"X2" (chi-squared).

Type:

Test statistic type

z#

Chi-squared field as a (Q,) array.

df#

Degrees of freedom (1, df).

p_point#

Point-level p values as a (Q,) array.

fwhm#

Estimated chi-squared field smoothness (full width at half maximum).

class SphericityResults0D[source]#

Mauchly’s sphericity test result for 0D data.

effect = None#

Within-subject effect label (e.g., "A", "A:B").

STAT#

"X2" (chi-squared).

Type:

Test statistic type

z#

Chi-squared value.

df#

Degrees of freedom (1, df).

p#

p value.

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

class SphericityResults1D[source]#

Mauchly’s sphericity test result for 1D data.

effect = None#

Within-subject effect label (e.g., "A", "A:B").

STAT#

"X2" (chi-squared).

Type:

Test statistic type

z#

Chi-squared field as a (Q,) array.

df#

Degrees of freedom (1, df).

p_point#

Point-level p values as a (Q,) array.

fwhm#

Estimated chi-squared field smoothness (full width at half maximum).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

property p#

Field maximum p value (smallest p_point).

property zmax#

Maximum of the chi-squared field.

class SphericityResultsList[source]#

List of sphericity results (one per within-subject effect) accessible by effect name.

effects#

Within-subject effect labels ("A", "B", "A:B") in list order.

property p#

List of effect p values in effects order.

Confidence intervals#

class CIOneSample1D[source]#

1D one-sample confidence interval.

Q = None#

Number of domain nodes.

alpha = None#

Type I error rate.

ci = None#

Interval (mean - hc, mean + hc). Two-tuple (0D) or (2,Q) array (1D).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Data dimensionality (0 or 1).

fwhm = None#

Estimated residual smoothness (full width at half maximum).

h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

mean = None#

float (0D) or (Q,) array (1D).

Type:

Sample mean or mean difference

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '1D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None, x=None, linecolor=None, facecolor=None, edgecolor=None, alpha=0.5, autoset_ylim=True)#

Plot the 1D interval (see spm1d.plot.plot_ci()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

  • x — (Q,) array of domain positions [default: 0, 1, …, Q-1]

  • linecolor — mean continuum color [default: text color]

  • facecolor — band fill color [default: faint gray]

  • edgecolor — band edge color [default: faint gray]

  • alpha — band transparency [default: 0.5]

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> ci = spm1d.stats.ci_onesample( y0 )
>>> ci.plot( facecolor='r' )
resels = None#

Resolution element counts (resels0, resels1).

zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CIPairedDifference1D[source]#

1D paired-difference confidence interval.

Q = None#

Number of domain nodes.

alpha = None#

Type I error rate.

ci = None#

Interval (mean - hc, mean + hc). Two-tuple (0D) or (2,Q) array (1D).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Data dimensionality (0 or 1).

fwhm = None#

Estimated residual smoothness (full width at half maximum).

h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

mean = None#

float (0D) or (Q,) array (1D).

Type:

Sample mean or mean difference

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '1D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None, x=None, linecolor=None, facecolor=None, edgecolor=None, alpha=0.5, autoset_ylim=True)#

Plot the 1D interval (see spm1d.plot.plot_ci()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

  • x — (Q,) array of domain positions [default: 0, 1, …, Q-1]

  • linecolor — mean continuum color [default: text color]

  • facecolor — band fill color [default: faint gray]

  • edgecolor — band edge color [default: faint gray]

  • alpha — band transparency [default: 0.5]

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> ci = spm1d.stats.ci_onesample( y0 )
>>> ci.plot( facecolor='r' )
resels = None#

Resolution element counts (resels0, resels1).

zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CITwoSampleDifference1D[source]#

1D two-sample difference confidence interval.

Q = None#

Number of domain nodes.

alpha = None#

Type I error rate.

ci = None#

Interval (mean - hc, mean + hc). Two-tuple (0D) or (2,Q) array (1D).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Data dimensionality (0 or 1).

fwhm = None#

Estimated residual smoothness (full width at half maximum).

h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

mean = None#

float (0D) or (Q,) array (1D).

Type:

Sample mean or mean difference

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '1D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None, x=None, linecolor=None, facecolor=None, edgecolor=None, alpha=0.5, autoset_ylim=True)#

Plot the 1D interval (see spm1d.plot.plot_ci()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

  • x — (Q,) array of domain positions [default: 0, 1, …, Q-1]

  • linecolor — mean continuum color [default: text color]

  • facecolor — band fill color [default: faint gray]

  • edgecolor — band edge color [default: faint gray]

  • alpha — band transparency [default: 0.5]

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> ci = spm1d.stats.ci_onesample( y0 )
>>> ci.plot( facecolor='r' )
resels = None#

Resolution element counts (resels0, resels1).

zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CIPairedSample1D[source]#

1D paired-sample confidence interval (datum="meanA").

Q = None#

Number of domain nodes.

alpha = None#

Type I error rate.

ciA = None#

Interval about meanA. Two-tuple (0D) or (2,Q) array (1D).

ciB = None#

Interval about meanB (mu='tailB' only, otherwise None).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Data dimensionality (0 or 1).

fwhm = None#

Estimated residual smoothness (full width at half maximum).

get_ciA(asstr=False, with_brackets=False)#

Interval about meanA.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciA as an array (string if asstr is True)

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> print( ci.get_ciA( asstr=True ) )
(-0.36473, 1.06872)
get_ciB(asstr=False, with_brackets=False)#

Interval about meanB if present, otherwise None.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciB as an array (string if asstr is True) or None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA', mu='tailB' )
>>> print( ci.get_ciB( asstr=True ) )
(-1.24250, -0.52578)
h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

meanA = None#

First sample mean (interval center).

meanB = None#

Second sample mean (criterion).

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '1D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None, x=None, linecolors=('k', 'r'), facecolors=('0.8', 'r'), edgecolors=('0.4', 'r'), color_criterion='r', alphas=(0.5, 0.5), autoset_ylim=True)#

Plot both 1D mean continua with the interval(s) (see spm1d.plot.plot_ci_multisample()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

  • x — (Q,) array of domain positions [default: 0, 1, …, Q-1]

  • linecolors — mean continuum colors [default: (‘k’, ‘r’)]

  • facecolors — band fill colors [default: (‘0.8’, ‘r’)]

  • edgecolors — band edge colors [default: (‘0.4’, ‘r’)]

  • color_criterion — criterion line color [default: ‘r’]

  • alphas — band transparencies [default: (0.5, 0.5)]

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> ci.plot()
resels = None#

Resolution element counts (resels0, resels1).

zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CITwoSample1D[source]#

1D two-sample confidence interval (datum="meanA").

Q = None#

Number of domain nodes.

alpha = None#

Type I error rate.

ciA = None#

Interval about meanA. Two-tuple (0D) or (2,Q) array (1D).

ciB = None#

Interval about meanB (mu='tailB' only, otherwise None).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 1#

Data dimensionality (0 or 1).

fwhm = None#

Estimated residual smoothness (full width at half maximum).

get_ciA(asstr=False, with_brackets=False)#

Interval about meanA.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciA as an array (string if asstr is True)

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> print( ci.get_ciA( asstr=True ) )
(-0.36473, 1.06872)
get_ciB(asstr=False, with_brackets=False)#

Interval about meanB if present, otherwise None.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciB as an array (string if asstr is True) or None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA', mu='tailB' )
>>> print( ci.get_ciB( asstr=True ) )
(-1.24250, -0.52578)
h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

meanA = None#

First sample mean (interval center).

meanB = None#

Second sample mean (criterion).

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '1D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None, x=None, linecolors=('k', 'r'), facecolors=('0.8', 'r'), edgecolors=('0.4', 'r'), color_criterion='r', alphas=(0.5, 0.5), autoset_ylim=True)#

Plot both 1D mean continua with the interval(s) (see spm1d.plot.plot_ci_multisample()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

  • x — (Q,) array of domain positions [default: 0, 1, …, Q-1]

  • linecolors — mean continuum colors [default: (‘k’, ‘r’)]

  • facecolors — band fill colors [default: (‘0.8’, ‘r’)]

  • edgecolors — band edge colors [default: (‘0.4’, ‘r’)]

  • color_criterion — criterion line color [default: ‘r’]

  • alphas — band transparencies [default: (0.5, 0.5)]

  • autoset_ylim — if True (default), set y limits to show all plotted elements

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, Q=101, fwhm=20, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> ci.plot()
resels = None#

Resolution element counts (resels0, resels1).

zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CIOneSample0D[source]#

0D one-sample confidence interval.

alpha = None#

Type I error rate.

ci = None#

Interval (mean - hc, mean + hc). Two-tuple (0D) or (2,Q) array (1D).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Data dimensionality (0 or 1).

h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

mean = None#

float (0D) or (Q,) array (1D).

Type:

Sample mean or mean difference

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '0D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None)#

Plot the 0D interval as the mean with an error bar (see spm1d.plot.plot_ci_0d()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_onesample( y0 )
>>> ci.plot()
zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CIPairedDifference0D[source]#

0D paired-difference confidence interval.

alpha = None#

Type I error rate.

ci = None#

Interval (mean - hc, mean + hc). Two-tuple (0D) or (2,Q) array (1D).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Data dimensionality (0 or 1).

h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

mean = None#

float (0D) or (Q,) array (1D).

Type:

Sample mean or mean difference

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '0D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None)#

Plot the 0D interval as the mean with an error bar (see spm1d.plot.plot_ci_0d()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_onesample( y0 )
>>> ci.plot()
zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CITwoSampleDifference0D[source]#

0D two-sample difference confidence interval.

alpha = None#

Type I error rate.

ci = None#

Interval (mean - hc, mean + hc). Two-tuple (0D) or (2,Q) array (1D).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Data dimensionality (0 or 1).

h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

mean = None#

float (0D) or (Q,) array (1D).

Type:

Sample mean or mean difference

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '0D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None)#

Plot the 0D interval as the mean with an error bar (see spm1d.plot.plot_ci_0d()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_onesample( y0 )
>>> ci.plot()
zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CIPairedSample0D[source]#

0D paired-sample confidence interval (datum="meanA").

alpha = None#

Type I error rate.

ciA = None#

Interval about meanA. Two-tuple (0D) or (2,Q) array (1D).

ciB = None#

Interval about meanB (mu='tailB' only, otherwise None).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Data dimensionality (0 or 1).

get_ciA(asstr=False, with_brackets=False)#

Interval about meanA.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciA as an array (string if asstr is True)

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> print( ci.get_ciA( asstr=True ) )
(-0.36473, 1.06872)
get_ciB(asstr=False, with_brackets=False)#

Interval about meanB if present, otherwise None.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciB as an array (string if asstr is True) or None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA', mu='tailB' )
>>> print( ci.get_ciB( asstr=True ) )
(-1.24250, -0.52578)
h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

meanA = None#

First sample mean (interval center).

meanB = None#

Second sample mean (criterion).

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '0D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None)#

Plot both 0D means with the interval(s) (see spm1d.plot.plot_ci_multisample_0d()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> ci.plot()
zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.

class CITwoSample0D[source]#

0D two-sample confidence interval (datum="meanA").

alpha = None#

Type I error rate.

ciA = None#

Interval about meanA. Two-tuple (0D) or (2,Q) array (1D).

ciB = None#

Interval about meanB (mu='tailB' only, otherwise None).

df = None#

t statistic degrees of freedom as (1, df).

property dfs#

Degrees of freedom df as a string such as "(1, 21)".

dim = 0#

Data dimensionality (0 or 1).

get_ciA(asstr=False, with_brackets=False)#

Interval about meanA.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciA as an array (string if asstr is True)

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> print( ci.get_ciA( asstr=True ) )
(-0.36473, 1.06872)
get_ciB(asstr=False, with_brackets=False)#

Interval about meanB if present, otherwise None.

Parameters:

  • asstr — if True, return a formatted string (default False)

  • with_brackets — if True, enclose the string in brackets (default False)

Returns:

  • ciB as an array (string if asstr is True) or None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA', mu='tailB' )
>>> print( ci.get_ciB( asstr=True ) )
(-1.24250, -0.52578)
h0reject = None#

True if the criterion lies outside the interval (None if there is no criterion).

hc = None#

float (0D) or (Q,) array (1D).

Type:

Interval half-height

property hstar — DEPRECATED#

Deprecated name of hc.

isparametric = True#

Always True (parametric intervals).

meanA = None#

First sample mean (interval center).

meanB = None#

Second sample mean (criterion).

mu = None#

Hypothesized value or criterion (mu) if present, otherwise None.

name = '0D Confidence Interval'#

"0D Confidence Interval" or "1D Confidence Interval".

Type:

Interval type as printed

plot(ax=None)#

Plot both 0D means with the interval(s) (see spm1d.plot.plot_ci_multisample_0d()).

Parameters:

  • ax — axes [default: matplotlib.pyplot.gca()]

Returns:

  • None

Example:
>>> import spm1d
>>> y0, y1 = spm1d.rng.ttest2( nsubj=8, seed=0 )
>>> ci = spm1d.stats.ci_twosample( y0, y1, datum='meanA' )
>>> ci.plot()
zc = None#

Critical t value for the interval height (RFT-corrected for 1D data).

property zstar — DEPRECATED#

Deprecated name of zc.