Tutorial stats 011422: Difference between revisions

From MEG Core
Jump to navigation Jump to search
Content added Content deleted
Line 7: Line 7:
=== Statistical Processing in AFNI ===
=== Statistical Processing in AFNI ===
#! /bin/bash
#! /bin/bash
# First things first: Good practice to convert .nii files to afni .HEAD .BRIK format: 3dcopy mydataset.nii myafnidataset
# First things first: Good practice to convert .nii files to afni .HEAD .BRIK format: 3dcopy mydataset.nii myafnidataset
# Here the data have been converted to common space (+tlrc) but if not can be done in afni with adwarp
# Here the data have been converted to common space (+tlrc) but if not can be done in afni with adwarp
# Example: One Sample T-test on alpha band log ratio of face power and shape power
# Example: One Sample T-test on alpha band log ratio of face power and shape power
# Why log-ratio? log(faces/shapes) = log(faces) - log(shapes) ; log attentuates outliers , normalizes distribution.
# Why log-ratio? log(faces/shapes) = log(faces) - log(shapes) ; log attentuates outliers , normalizes distribution.
# First make a list of subjects for test:
# First make a list of subjects for test:
ls *_7_13_*lograt*.HEAD > alpha_list
ls *_7_13_*lograt*.HEAD > alpha_list
# Then run one sample T-test
# Then run one sample T-test
3dttest++ -setA `cat alpha_list` -prefix alpha_ttest
3dttest++ -setA `cat alpha_list` -prefix alpha_ttest
# Optional: add effect size to output
# Optional: add effect size to output
3dMean -prefix alpha_mean `cat alpha_list`
3dMean -prefix alpha_mean `cat alpha_list`
3dMean -sd -prefix alpha_std `cat alpha_list`
3dMean -sd -prefix alpha_std `cat alpha_list`
3dcalc -prefix alpha_effectsize -a alpha_mean+tlrc -b alpha_std+tlrc -expr 'a/b'
3dcalc -prefix alpha_effectsize -a alpha_mean+tlrc -b alpha_std+tlrc -expr 'a/b'
3dbucket -prefix alpha_ttest_effectsize alpha_ttest+tlrc alpha_effectsize+tlrc
3dbucket -prefix alpha_ttest_effectsize alpha_ttest+tlrc alpha_effectsize+tlrc
3drefit -sublabel 2 "effectsize" alpha_ttest_effectsize+tlrc
3drefit -sublabel 2 "effectsize" alpha_ttest_effectsize+tlrc
# Could do a paired T-test between faces and shapes instead of log-ratio
# Could do a paired T-test between faces and shapes instead of log-ratio
ls *_7_13_*shape*.HEAD > alpha_shape_list
ls *_7_13_*shape*.HEAD > alpha_shape_list
ls *_7_13_*face*.HEAD > alpha_face_list
ls *_7_13_*face*.HEAD > alpha_face_list
3dttest++ -setA `cat alpha_face_list` -setB `cat alpha_shape_list` -paired -prefix alpha_paired_ttest
3dttest++ -setA `cat alpha_face_list` -setB `cat alpha_shape_list` -paired -prefix alpha_paired_ttest
# Can add covariates to T-tests.
# Can add covariates to T-tests.
# Can do mixed-effects ANOVAs and other fancier stuff
# Can do mixed-effects ANOVAs and other fancier stuff


== MNE Python ==
== MNE Python ==

Revision as of 14:46, 24 January 2022

!!UNDER CONSTRUCTION!!

Afni Prep

Install Afni on computer:

 https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/index.html

Statistical Processing in AFNI

 #! /bin/bash
 # First things first: Good practice to convert .nii files to afni .HEAD .BRIK format:  3dcopy mydataset.nii myafnidataset
 # Here the data have been converted to common space (+tlrc) but if not can be done in afni with adwarp
 
 # Example: One Sample T-test on alpha band log ratio of face power and shape power
 # Why log-ratio? log(faces/shapes) = log(faces) - log(shapes) ; log attentuates outliers , normalizes distribution. 
 # First make a list of subjects for test: 
 ls *_7_13_*lograt*.HEAD > alpha_list
 
 # Then run one sample T-test
 3dttest++ -setA `cat alpha_list` -prefix alpha_ttest
 
 # Optional: add effect size to output
 3dMean -prefix alpha_mean `cat alpha_list`
 3dMean -sd -prefix alpha_std `cat alpha_list`
 3dcalc -prefix alpha_effectsize -a alpha_mean+tlrc -b alpha_std+tlrc -expr 'a/b'
 3dbucket -prefix alpha_ttest_effectsize alpha_ttest+tlrc alpha_effectsize+tlrc
 3drefit -sublabel 2 "effectsize" alpha_ttest_effectsize+tlrc
 
 # Could do a paired T-test between faces and shapes instead of log-ratio
 ls *_7_13_*shape*.HEAD > alpha_shape_list
 ls *_7_13_*face*.HEAD > alpha_face_list
 3dttest++ -setA `cat alpha_face_list` -setB `cat alpha_shape_list` -paired -prefix alpha_paired_ttest
 
 # Can add covariates to T-tests. 
 # Can do mixed-effects ANOVAs and other fancier stuff

MNE Python

Install MNE Python

 conda install mamba -y
 mamba create -n tutorial_stats conda-forge::mne conda-forge:datalad -y
 conda activate tutorial_stats


Download the data

Will Update soon with appropriate paths etc.

 git clone ------- data repo
 cd ----
 datalad get ./*

Additional MEG Stats Links

 https://mne.tools/stable/auto_tutorials/stats-sensor-space/10_background_stats.html
 https://eelbrain.readthedocs.io/en/stable/getting_started.html
 https://neuroimage.usc.edu/brainstorm/Tutorials/Statistics
 https://www.fieldtriptoolbox.org/tutorial/eventrelatedstatistics/