SPM: Difference between revisions

From CCN Wiki
Jump to navigation Jump to search
Line 3: Line 3:
=== Anatomical data ===
=== Anatomical data ===
The MPRAGE file from the CTRC scanner is supplied as a gzipped file with a sequential filename (e.g., ''501-MPRAGE.nii.gz''). This file should be unzipped, renamed to MPRAGE.nii, and moved to a subfolder named ''MPRAGE''
The MPRAGE file from the CTRC scanner is supplied as a gzipped file with a sequential filename (e.g., ''501-MPRAGE.nii.gz''). This file should be unzipped, renamed to MPRAGE.nii, and moved to a subfolder named ''MPRAGE''
==== Manually Setting the Origin ====
No idea why, but sometimes the anatomical data will be out of frame because the origin (the reference 0-point in 3D space) is set to the wrong location. This is the fMRI equivalent of taking a portrait with the camera aimed at the subject's knees. This will potentially screw things up.
The directions for fixing this problem can be found by googling "spm set origin", but here's what Google says to do. Seriously, Google is a better RA than some people.
* To change the origin of an image:
* open the image with SPM Display.
* move the crosshair position so that it roughly points to the anterior commissure (AC).
* click on the Set Origin button.
* click on the Reorient button and press done (your image is already selected). ...
* say No to Do you want to save the reorientation matrix?
=== Functional data ===
=== Functional data ===
The BOLD data from the CTRC scanner are supplied as a series of gzipped (.gz) files with sequential filenames (e.g., ''700-BOLD_data.nii.gz'', ''800-BOLD_data.nii.gz''). These files need to be unzipped and moved to separate intutively-named subfolders (e.g., ''Run_01'', ''Run_02'', ...). All functional data files should have the same name. Conventionally, we have gone with ''4D.nii'', but ''f.nii'' (to be consistent with the file names used by Freesurfer) is fine too.  
The BOLD data from the CTRC scanner are supplied as a series of gzipped (.gz) files with sequential filenames (e.g., ''700-BOLD_data.nii.gz'', ''800-BOLD_data.nii.gz''). These files need to be unzipped and moved to separate intutively-named subfolders (e.g., ''Run_01'', ''Run_02'', ...). All functional data files should have the same name. Conventionally, we have gone with ''4D.nii'', but ''f.nii'' (to be consistent with the file names used by Freesurfer) is fine too.  

Revision as of 17:02, 8 November 2017

Data Organization

The fMRI data for each participant is stored in a single folder named after the participant's Participant ID. In this folder is stored the participant's Functional (BOLD) and Anatomical (MPRAGE) data.

Anatomical data

The MPRAGE file from the CTRC scanner is supplied as a gzipped file with a sequential filename (e.g., 501-MPRAGE.nii.gz). This file should be unzipped, renamed to MPRAGE.nii, and moved to a subfolder named MPRAGE

Manually Setting the Origin

No idea why, but sometimes the anatomical data will be out of frame because the origin (the reference 0-point in 3D space) is set to the wrong location. This is the fMRI equivalent of taking a portrait with the camera aimed at the subject's knees. This will potentially screw things up.

The directions for fixing this problem can be found by googling "spm set origin", but here's what Google says to do. Seriously, Google is a better RA than some people.

  • To change the origin of an image:
  • open the image with SPM Display.
  • move the crosshair position so that it roughly points to the anterior commissure (AC).
  • click on the Set Origin button.
  • click on the Reorient button and press done (your image is already selected). ...
  • say No to Do you want to save the reorientation matrix?

Functional data

The BOLD data from the CTRC scanner are supplied as a series of gzipped (.gz) files with sequential filenames (e.g., 700-BOLD_data.nii.gz, 800-BOLD_data.nii.gz). These files need to be unzipped and moved to separate intutively-named subfolders (e.g., Run_01, Run_02, ...). All functional data files should have the same name. Conventionally, we have gone with 4D.nii, but f.nii (to be consistent with the file names used by Freesurfer) is fine too.

When finished, your subject folder should be organized something like this (e.g., for subject 101):

  • 0101/
    • MPRAGE/
      • MPRAGE.nii
    • Run_01/
      • 4D.nii
    • Run_02/
      • 4D.nii
    • Run_03/
      • 4D.nii

etc.

Extracting Event Onsets from MATLAB Data Files

Analyses of fMRI (as opposed to rs-MRI) are built on regressions of observed time-series data on predicted time-series data. The predicted time-series are derived from the onsets of different types of events of interests (e.g., at what points in time was the participant experiencing Condition A and/or Condition B?).

If the event onsets can be assumed to be constant across participants, an onsets file (either in plaintext or .mat format) can be created from the known experimental paradigm. If the event onsets are variable across participants, or if one wants to be extremely precise about stimulus timing, these event onsets can be derived from each participant's MATLAB data file generated during the experiment.

A MATLAB function, TSExtractor has been written, and can be found in the UBFS Scripts/Matlab/ folder. If a copy of this file is in your MATLAB path, you can use the TSExtractor function to generate SPM onsets files from these experiment data files.

  1. If TSExtractor.m is not already in your MATLAB path, open a terminal window and copy it there:
    cp ~/ubfs/cpmcnorg/Scripts/Matlab/TSExtractor.m ~/Documents/MATLAB/
  2. Start MATLAB, and read the TSExtractor help for an explanation and sample usage:
    >>help TSExtractor
  3. In MATLAB, navigate to the directory containing the .mat files containing the experiment data from which you wish to extract the event onsets
    • It is not strictly necessary to navigate to this directory, however if your files are located in a different directory, you will be required to provide an additional parameter to TSExtractor indicating where the files are to be found. Otherwise, the function simply assumes that these files are found in your current directory.
  4. Execute TSExtractor on each of the .mat files. E.g.,
    >> d=datenum('19-Nov-2015');
    >> TSExtractor('prefix', 'LDT_', 'subject', 1000, 'run', 1, 'date', d);

These files should be stored in an onsets/ directory within each participant's folder:

  • 0101
    • MPRAGE/
      • MPRAGE.nii
    • onsets
      • subject_101_run_1_condition_0.txt
      • subject_101_run_1_condition_1.txt
      • subject_101_run_1_condition_2.txt
      • subject_101_run_2_condition_0.txt
      • subject_101_run_2_condition_1.txt
      • subject_101_run_2_condition_2.txt
    • Run_01/
      • 4D.nii

... etc.