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 TE-dependence and -independence models to components.
get_coeffs(data, X[, mask, 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, t2s_full, tes, combmode, ref_img, reindex=False, mmixN=None, full_sel=True)[source]

Fit TE-dependence and -independence models to components.

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 [x E]) array_like) – Boolean mask array
  • t2s ((S [x T]) array_like) – Limited T2* map or timeseries.
  • t2s_full ((S [x T]) array_like) – Full T2* map or timeseries. For voxels with good signal in only one echo, which are zeros in the limited T2* map, this map uses the T2* estimate using the first two echoes.
  • 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
  • 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) pandas.DataFrame) – 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 by component
  • betas (numpy.ndarray)
  • mmix_new (numpy.ndarray)

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

Performs least-squares fit of X against data

Parameters:
  • data ((S [x E] x T) array_like) – Array where S is samples, E is echoes, and T is time
  • X ((T [x C]) array_like) – Array where T is time and C is predictor variables
  • mask ((S [x E]) array_like) – Boolean mask array
  • 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 E] 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) – Specifies 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 – Binarized array (values are 0 or 1) of clustered (and thresholded) img data

Return type:

numpy.ndarray