You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Run a mass-univariate regression across voxels. Three types of regressions can be run:
884
-
1) Standard OLS (default)
885
-
2) Robust OLS (heteroscedasticty and/or auto-correlation robust errors), i.e. OLS with "sandwich estimators"
886
-
3) ARMA (auto-regressive and moving-average lags = 1 by default; experimental)
885
+
defregress(self, noise_model="ols", **kwargs):
886
+
"""Runs a mass-univariate GLM analyses using the `Design_Matrix` supplied to `.X`
887
887
888
-
For more information see the help for nltools.stats.regress
888
+
This is a wrapper around [`nilearn.glm.first_level.FirstLevelModel`](https://nilearn.github.io/stable/modules/generated/nilearn.glm.first_level.FirstLevelModel.html#nilearn.glm.first_level.FirstLevelModel) which you can reference for additional information about what `**kwargs` are supported.
889
889
890
-
ARMA notes: This experimental mode is similar to AFNI's 3dREMLFit but without spatial smoothing of voxel auto-correlation estimates. It can be **very computationally intensive** so parallelization is used by default to try to speed things up. Speed is limited because a unique ARMA model is fit to *each voxel* (like AFNI/FSL), but unlike SPM, which assumes the same AR parameters (~0.2) at each voxel. While coefficient results are typically very similar to OLS, std-errors and so t-stats, dfs and and p-vals can differ greatly depending on how much auto-correlation is explaining the response in a voxel
891
-
relative to other regressors in the design matrix.
890
+
However, we override some defaults:
891
+
- no smoothing (use `.smooth()`)
892
+
- no scaling (use `.scale()`
893
+
- no drift model (should already be in the `Design_Matrix` set to `.X`)
894
+
- OLS noise model (use `noise_model = 'ar1'` to switch but takes more time)
892
895
893
896
Args:
894
-
mode (str): kind of model to fit; must be one of 'ols' (default), 'robust', or 'arma'
895
-
kwargs (dict): keyword arguments to nltools.stats.regress
897
+
noise_model (str, optional): temporal variance model. Defaults to "ols"
896
898
897
-
Returns:
898
-
out: dictionary of regression statistics in Brain_Data instances
899
-
{'beta','t','p','df','residual'}
900
899
900
+
Returns:
901
+
ResultsContainer: with keys for each convolved column of `.X` and values as `Brain_Data` objects of the GLM statistics
901
902
"""
903
+
# Avoid circular import
904
+
from .resultsimportResultsContainer
902
905
903
906
ifnotisinstance(self.X, pd.DataFrame):
904
907
raiseValueError("Make sure self.X is a pandas DataFrame.")
raiseValueError("self.X does not match the correct size of self.data")
911
914
912
-
b, se, t, p, df, res=regression(self.X, self.data, mode=mode, **kwargs)
913
-
914
-
# Prevent copy of all data in self multiple times; instead start with an empty instance and copy only needed attributes from self, and use this as a template for other outputs
915
-
b_out=self.__class__()
916
-
b_out.mask=deepcopy(self.mask)
917
-
b_out.nifti_masker=deepcopy(self.nifti_masker)
918
-
919
-
# Use this as template for other outputs before setting data
"""A genericcontainer that dynamically creates attributes from a dictionary of string: Nifti1Image entries, where each attribute is a Brain_Data instance initialized from the corresponding Nifti image.
8
+
9
+
Args:
10
+
images_dict (Dict[str, nib.Nifti1Image]): Dictionary mapping attribute names to Nifti images.
0 commit comments