the analysis pipeline of freesurfer 2013 · pipelines 5/1/2013 3 bi/cns 184 the primate visual...

64
NeuronEcon Cluster

Upload: others

Post on 24-Mar-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

NeuronEcon Cluster

Page 2: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

• How to login?• How to transfer files?• How to open a terminal window• Simple commands in linux• Where should we store our stuff on the cluster?• Setting up environment for free surfer (.bashrc)• Setting up matlab (keyboard)

Page 3: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Pipelines

5/1/2013 3Bi/CNS 184 The Primate Visual System, Shay Ohayon (c)

The Primate Visual SystemBi/CNS 184

Page 4: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Two Main Pipelines

• Anatomical Pipeline

RAW Structural Data Useful things for VISUALIZATIONUseful things for VISUALIZATIONAnalysis 

Pipeline:Data SmoothingSegmentation

Surface Reconstruction…

Page 5: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Surface Reconstruction• The boundary between white and gray matter is used to define a surface

• The surface can be inflated/flattened for improve visualization

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 5

Page 6: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Two Main Pipelines

• Functioanl Pipeline

RAW Functional Data Useful things for INFERENCE

Useful things for INFERENCE

Analysis Pipeline:

Slice Timing CorrectionUn‐distortion

Motion CorrectionData SmoothingModel Design

Parameter Estimation 

Page 7: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Things shared by both pipelines

• RAW data is originally saved in a file format called “DICOM”

• Each DICOM file contains a single slice– Since you acquire volumes, and each volume contains many slices, you end up with MANY files

• A first step shared by both pipelines is to convert DICOMs to something more accessable. 

Page 8: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Unpacking

• Unpacking is the process of converting the huge amounts of dicoms into a smaller set of files, each containing a volume or a set of volumes

Page 9: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Know your file types

• MGH (Massachusetts General Hospital)• Used to store high resolution structural images• http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/MghFormat

• XXX.mgz is a compressed variant of MGH

• NII (a.k.a. NIFTI)– Used to store data with different meanings. Imaging data, statistical values, etc.

– Can contain time series (4D data)– XXX.nii.gz (a compress version of nii)

Page 10: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Unpacking

• The command line interface to unpacking is unpacksdcmdir

• You can read more about it here:• http://surfer.nmr.mgh.harvard.edu/fswiki/unpacksdcmdir

Page 11: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Unpack GUI

• An alternative for using the command line.• cd to /space/cns184/2013/code• Run matlab• Run the script called fMRI

Page 12: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Unpack GUI

• Highlight the dicom folder and then click “Unpack”

• It will unpack to– /space/cns184/2013/data/<your name>/cooked/…

Page 13: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Analyzing takes time…

• Be patient• You can check the status of some of the heavy computations by querying the cluster about jobs. Type “qstat” in the command line.

Page 14: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Unpacking Outputs

• After unpacking is done, the following folders will be created in the output folder:

• /bold/XXX/f.nii– This is where the FUNCTIONALS are stored– XXX is the RUN number

• /mri/orig/XXX/mprage.nii– This is where the structural scans are stored

• /fieldmap/XXX– Information about how to undistort the EPI images

Page 15: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Quick visualization of the data

• Free surfer offers a tool called tkmedit which allows you to visualize anatomical data – We will also use this tool later on to overlay the statistical maps

• For example:– Tkmedit –f …../mri/orig/002/mprage.nii

• Another small utility for displaying data is called xd– xd mprage.nii

Page 16: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

The Functional Pipeline

RAW Functional Data Useful things for INFERENCE

Useful things for INFERENCE

Analysis Pipeline:

Slice‐timing correctionMotion Correction

Un‐distortionData SmoothingModel Design

Parameter Estimation 

Page 17: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Slice Timing Problem

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 17

Time

Ideal World

Time

Real World

Page 18: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Slice Timing Correction

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 18

5

Time

3 7 2

Page 19: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Motion

• Within‐Modality Registration• Unless subject is anesthetized we expect small motion of the head during the scan.

• Most analysis packages try to compensate for these small motions and realign the volumes to a single reference frame such that all voxels(in time) correspond to the same physical point

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 19

Page 20: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Rigid Body Motion• Rigid body transformation can be represented by a rotation followed by a translation

• 3D rotation can be decomposed to a rotation about X, followed by a rotation about Y, followed by a rotation about Z

• The 3D motion, therefore, can be described by 6 parameters 

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 20

Page 21: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Motion Correction

• There is a tool that can correct for small motions (mc‐afni2). It will output a new series of volumes (called fmc.nii), such that all of them are properly aligned.

• In addition, it will also output the values of the detected motion, as possible regressorsthat can be used in the GLM fit.– The registration values will be stored under mcextreg

Page 22: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Motion correction for a single run:

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 22

Page 23: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Motion Correction

• Small movements can be corrected automatically. 

• What about large motion? Or aligning recorded sessions from multiple days?

Page 24: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Multi Modal Registration

• Match between the two:

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 24

Page 25: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Manual Registrationtkregister2 ‐‐targ static.mgz \

‐‐mov movable.mgz \‐‐reg reg.reg ‐‐regheader

Page 26: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Next step in the pipeline…

Page 27: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

EPI Distortion

5/1/2013 27Bi/CNS 184 The Primate Visual System, Shay Ohayon (c)

Page 28: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Un‐distortion

• EPI is sensitive to small magnetic field in homogeneities 

• Distortions arise in the direction in which acquisition time between adjacent point is the greatest (i.e., phase encoding direction, which is typically along the y axis)

• Distortions along the x direction are negligible because the acquisition time between adjacent points is much less

• Correcting distortions in EPI, therefore, is reduced a 1D problem.

5/1/2013 28Bi/CNS 184 The Primate Visual System, Shay Ohayon (c)

Page 29: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Undistorting EPIs

• EPI undistortion can be done with a tool called epidewarp.fsl

• This tool is a part of a different software package to analyze MR data which is called FSL

• The output of this tool will be a new set of functional volumes. The name of those will be fmcu– (to indicate that they were motion corrected and undistorted)

Page 30: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Next step in the pipeline…

Page 31: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Spatial Smoothing

• Spatial smoothing is typically done by applying a Gaussian filter on the volume. 

• This filter will “spread” (smear) the intensity at each voxel over nearby voxels.

• The width of the filter determines how strong the effect will be. It is usually expressed in millimeters as FWHM (Full width half maximum)

Page 32: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Why smooth the data?

• Using a filter that matches the frequency of the signal will maximize signal to noise.

• If voxels were completely uncorrelated, this will only harm the data

• However, voxels do have strong spatial correlation (anatomy is smooth)

• Furthermore, when doing analysis with several subjects, mismatch in anatomy can lead to not exactly same voxels activity

Page 33: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

How much to smooth?

• Smoothing should match the expected  spatial correlation of the data. 

• A rule of thumb is to use something like 1.5‐2 times the voxel size. – In humans, where voxels are 3mm, a typical FWHM will be about 5mm

– In monkeys, where voxels are 1mm, we typically use 2mm 

• In any case, you always want to look at the unsmoothed data, in addition to the smooth one.

Page 34: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

How to smooth?

• You can use a tool called “mri_fwhm” that is part of the free surfer software package.

Page 35: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Next step in the pipeline…

Page 36: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Spatial Normalization – The Average Brain

• MNI brain (Montreal Neurological Institute)– MNI250 / MNI305 / ICBM152– “colin27” or “T1” in SPM

• Talairach and Tournou

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 36

Page 37: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Brain Coordinate System• CA‐CP line (horizontal plane)

– This line passes through the superior edge of the anterior commissureand the inferior edge of the posterior commissure. It follows a path essentially parallel to the hypothalamic region. 

• VCA line (vertical frontal plane)– Vertically traversing the posterior margin of the anterior commissure.

• Midline (Sagital plane)

5/1/2013 37Bi/CNS 184 The Primate Visual System, Shay Ohayon (c)

Page 38: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

5/1/2013 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) 38

Page 39: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Intermediate summary

• We started from f.nii, which was the raw signal• We then generated:

– fmc.nii (motion corrected, aligned version of the data)

– fmcu.nii (above + undistorted)– fmcus.nii (above + smoothed)

• We typically only analyze the last two types.

Page 40: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

The easy way for preprocessing

Page 41: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

FuncPreProc

• This is a small GUI utility that will perform many of the steps mentioned above automatically.

Page 42: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Next step in the pipeline…

• The functional inference preparation step is done with a tool called mkanalysis‐sess– mkanalysis‐sess has many parameters that can be set. Some are mandatory, some are optional. Read more here: http://surfer.nmr.mgh.harvard.edu/fswiki/mkanalysis‐sess.new

Page 43: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Next step in the pipeline…

• mkanalysis‐sess assumes certain files are located under certain folders

Page 44: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

The annoying steps:

1. Setup an “analysis” folderSuppose your subject data resides in …/data/subject1Then create …/data/subject1/analyses/anal1

• You can create a folder using the mkdircommand

Page 45: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

2. Create the following file:…/data/subject1/analyses/anal1/dfWhich contains a single line (obviously, replace the … with the full path name):…/data/

Page 46: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

3. Create the following file:…/data/subject1/analyses/anal1/sfWhich contains a single linesubject1

Page 47: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

4. Create the following file:…/data/subject1/subjectnameWhich contains a single linesubject1

Page 48: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

5. Create the paradigm design file and store it under: …/data/subject1/analyses/anal1/paradigmfile

The paradigm file is a text file and has the following format:[Time ConditionNumber Duration Description]

For example:0.0      1       2.0     faces2.0      1       2.0     faces4.0      2       3.0     non‐faces7.0      2       3.0     non‐faces

Page 49: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

6. Distribute the paradigmfile to each one of the run folders. i.e.cp paradigmfile …/data/bold/004cp paradigmfile …/data/bold/007…

Page 50: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

7. Create the run list file that will tell mkanalysis‐sess which runs to take from the /bold folder

For example:003004005007

Page 51: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Putting it all together:#! /bin/csh ‐f

set AnalysisName = "anal1"set ParadigmDesignFile = "paradigmfile"set TR = 3set NumberOfConditions = 7set GammaFit = "0 8"set GammaExp = "0.3"set RunListFile = "runfile"set FuncStem = "fmcu.nii"set MaskStem = "brain_fmc.nii"

mkanalysis‐sess \‐analysis $AnalysisName \‐native         \‐event‐related  \‐paradigm  $ParadigmDesignFile \‐TR $TR \‐nconditions $NumberOfConditions \‐gammafit $GammaFit\‐gammaexp $GammaExp \‐polyfit 2 \‐mcextreg \‐acfbins 10 \‐fsd bold \‐runlistfile $RunListFile \‐funcstem $FuncStem \‐mask $MaskStem \‐fwhm 0 \‐refeventdur $TR \‐force

Page 52: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

The Gamma Fit:

• Describes the HRF. There are different HRFs for monkeys and humans. Furthermore, when monkeys are giving a contrast agent to enhance BOLD activity (called MION), you need to use different values as well.

• Use the following parameters:– GammaFit = "0 8“– GammaExp = "0.3“– TimeWindow = 80   

Page 53: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

MION

• VERY IMPORTANT!!!• Expect a reduction in the BOLD signal when a brain region is activated. 

Page 54: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Summary

• mkanalysis‐sess did not analyze anything. It just setup stuff for the heavy lifting computations that will follow.

• The actual GLM fit is done by running a tool called “selxavg3‐sess”

#! /bin/csh ‐f

setenv SUBJECTS_DIR "/space/cns184/2013/groups/project1/data"

selxavg3‐sess ‐analysis anal1 ‐sf sf ‐df df ‐no‐con‐ok ‐no‐preproc

Page 55: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Running things on a separate machine

• make a file called “runglm” and place this code inside:

• Then write “qsub runglm”

#! /bin/csh ‐f

setenv SUBJECTS_DIR "/space/cns184/2011/groups/project1/data"

selxavg3‐sess ‐analysis anal1 ‐sf sf ‐df df ‐no‐con‐ok ‐no‐preproc

Page 56: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

What has this computed?

• Under …/bold/anal1 many files will be generated, but the most important ones are “beta.nii”, and “rvar.nii” which contains all the betas and residuals needed to compute contrasts:

12

~T

J rank XT T

c d tc X X c

Page 57: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

How do you compute contrasts?

• Use a tool called “mkcontrast‐sess”mkcontrast‐sess –analysis anal1 –contrast faces_objects –a 1 –a 2 –a 3 –c 4 –c 5

You will need to re‐run the selxavg3‐sess again to actually compute the contrast.

Page 58: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

What did this generate?

• /bold/anal1/faces_objects/sig.nii– This volume contains ‐log10(p‐value)

• /bold/anal1/faces_objects/t.nii– This volume contains the T statistics

Page 59: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

How can we visualize p‐values?

• xd sig.nii is not very helpful. You want to display this overlaid on top of the anatomical volume!

• xd …/bold/MOCOVOL/mocovol.nii ‐P sig.nii

• This will display the motion template volume overlaid with the p‐values

Page 60: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

The alternative to the linux scripts…

• GUI Wrapper that I wrote that does everything for you (and more…)

Page 61: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184
Page 62: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Advanced Stuff…

• Reading volumes in matlab– Use “MRIread” function

• Converting data types/format– Use “mriconvert”

Page 63: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Scripts in linux

• Sometimes it is useful to generate small scripts that run the required tools one after the other.

• Here is a short example of a linux script:#! /bin/csh ‐f

echo Hello Worldset X=5echo $Xcd /space/cns184

Page 64: The Analysis Pipeline of FreeSurfer 2013 · Pipelines 5/1/2013 3 Bi/CNS 184 The Primate Visual System, Shay Ohayon (c) The Primate Visual System Bi/CNS 184

Running a script

• Make sure that the file has the executable permission set correctly.– You can find which permissions a file or a directory have by writing “ls –la”

– To turn on the executable flag, use the chmodcommand. “chmod 775 Filename”, for example, will modify the permissions such that you will be able to run it.