Useful Code

From Brain Mapping Unit
Jump to navigationJump to search

Prantik's %DVARS script

Here are the scripts dvars.py and dvars_mo.py to generate "Petersen plots:" [[1]] and [[2]]

Here are the requirements

-python (you have it if you're on mac or linux, but an upgrade to 2.7.x from python.org is suggested)

-numpy (a version appropriate for your OS and python version, if you haven't installed numpy yet)

-NiBabel, at a command prompt, run  sudo easy_install nibabel

Then run the code as such:

1. RMS Delta Displacement plot:

python dvars_mo.py <rigid body motion parameter file>  i.e.     python dvars_mo.py motionXYZ.1D this will output a file called motionXYZ_dvars.1D

2. %DVARS:

python dvars.py <NIFTI dataset>  i.e      python dvars.py foobar.nii.gz this will output a file called foobar_dvars.1D

The input dataset should be at least roughly masked, but otherwise can be raw or preprocessed data. If data is preprocessed and the mean has been removed, run like this:

python dvars.py <preprocessed NIFTI dataset> <NIFTI dataset with non-zero means, 3D or 4D>

The numbers in the fMRI DVARS are in percent signal change, so they should be consistent across subjects and vary with the amount of motion subjects have. FYI, the baseline of DVARS will be higher with more thermal noise or continuous noise that you have, so for example, with people with a lot of cerebral pulsation from vasculature, the baseline DVARS% will be high.

Enjoy, and let me know if something breaks or if you need help.

Back To FMRI Page or Main Page

FMRI

Main Page