tedana.model.fit

Fit models.

Functions

computefeats2(data, mmix, mask[, normalize]) Converts data to component space using mmix
fitmodels_direct(catd, mmix, mask, t2s, …) Fit models directly.
get_coeffs(data, mask, X[, add_const]) Performs least-squares fit of X against data
gscontrol_raw(catd, optcom, n_echos, ref_img) Removes global signal from individual echo catd and optcom time series
spatclust(img, min_cluster_size[, …]) Spatially clusters img
computefeats2(data, mmix, mask, normalize=True)[source]

Converts data to component space using mmix

Parameters:
  • data ((S x T) array_like) – Input data
  • mmix ((T x C) array_like) – Mixing matrix for converting input data to component space, where C is components and T is the same as in data
  • mask ((S,) array-like) – Boolean mask array
  • normalize (bool, optional) – Whether to z-score output. Default: True
Returns:

data_Z – Data in component space

Return type:

(S x C) numpy.ndarray

fitmodels_direct(catd, mmix, mask, t2s, t2sG, tes, combmode, ref_img, fout=None, reindex=False, mmixN=None, full_sel=True)[source]

Fit models directly.

Parameters:
  • catd ((S x E x T) array_like) – Input data, where S is samples, E is echos, and T is time
  • mmix ((T x C) array_like) – Mixing matrix for converting input data to component space, where C is components and T is the same as in catd
  • mask ((S,) array_like) – Boolean mask array
  • t2s ((S,) array_like) –
  • t2sG ((S,) array_like) –
  • tes (list) – List of echo times associated with catd, in milliseconds
  • combmode ({'t2s', 'ste'} str) – How optimal combination of echos should be made, where ‘t2s’ indicates using the method of Posse 1999 and ‘ste’ indicates using the method of Poser 2006
  • ref_img (str or img_like) – Reference image to dictate how outputs are saved to disk
  • fout (bool) – Whether to output per-component TE-dependence maps. Default: None
  • reindex (bool, optional) – Default: False
  • mmixN (array_like, optional) – Default: None
  • full_sel (bool, optional) – Whether to perform selection of components based on Rho/Kappa scores. Default: True
Returns:

  • seldict (dict)
  • comptab ((N x 5) numpy.ndarray) – Array with columns denoting (1) index of component, (2) Kappa score of component, (3) Rho score of component, (4) variance explained by component, and (5) normalized variance explained bycomponent
  • betas (numpy.ndarray)
  • mmix_new (numpy.ndarray)

get_coeffs(data, mask, X, add_const=False)[source]

Performs least-squares fit of X against data

Parameters:
  • data ((S x T) array-like) – Array where S is samples and T is time
  • mask ((S,) array-like) – Boolean mask array
  • X ((T x C) array-like) – Array where T is time and C is predictor variables
  • add_const (bool, optional) – Add intercept column to X before fitting. Default: False
Returns:

betas – Array of S sample betas for C predictors

Return type:

(S x C) numpy.ndarray

gscontrol_raw(catd, optcom, n_echos, ref_img, dtrank=4)[source]

Removes global signal from individual echo catd and optcom time series

This function uses the spatial global signal estimation approach to to removal global signal out of individual echo time series datasets. The spatial global signal is estimated from the optimally combined data after detrending with a Legendre polynomial basis of order = 0 and degree = dtrank.

Parameters:
  • catd ((S x E x T) array_like) – Input functional data
  • optcom ((S x T) array_like) – Optimally-combined functional data (i.e., the output of make_optcom)
  • n_echos (int) – Number of echos in data. Should be the same as E dimension of catd
  • ref_img (str or img_like) – Reference image to dictate how outputs are saved to disk
  • dtrank (int, optional) – Specfies degree of Legendre polynomial basis function for estimating spatial global signal. Default: 4
Returns:

  • dm_catd ((S x E x T) array_like) – Input catd with global signal removed from time series
  • dm_optcom ((S x T) array_like) – Input optcom with global signal removed from time series

spatclust(img, min_cluster_size, threshold=None, index=None, mask=None)[source]

Spatially clusters img

Parameters:
  • img (str or img_like) – Image file or object to be clustered
  • min_cluster_size (int) – Minimum cluster size (in voxels)
  • threshold (float, optional) – Whether to threshold img before clustering
  • index (array_like, optional) – Whether to extract volumes from img for clustering
  • mask ((S,) array_like, optional) – Boolean array for masking resultant data array
Returns:

clustered – Boolean array of clustered (and thresholded) img data

Return type:

numpy.ndarray