Phillips lab

From CNI Wiki
Jump to navigation Jump to search

Attentive Reading Study

Data Analysis Notes

Log on for the DHLC Lab

Lab Macs:

   Data is in LC, shortcut is on Desktop
   Subject Data is in nmp-data

Lab Linux:

   DHLC user password is on a note above the screen
   Data is in Documents, shortcut is on Desktop
   Subject Data is in nmp-data

Data Locations on DHLC Lab computers

   Mac: /Volumes/lc/nmp-data (shortcut on Desktop)
   Linux: Documents/nmp-data (shortcut on Desktop)

Eye-tracking data:

   nmp-data/nmp-subjects/s##/behavior/lit[1-2]xxxxxxx.csv

Freesurfer output data:

   nmp-data/nmp-recons/s##/surf
   View Freesurfer output:
   Open terminal
   Open nmp-data: 
   Mac: cd /Volumes/lc/nmp-data
   Linux: cd Documents/nmp-data
   To View Data for s01 to s18: ./runViewer.sh [s01] [regular/flipped] [pial/inflated]

File Explanations

Our Current System:

regular = close reading vs. pleasure reading flipped = pleasure reading vs. close reading nmp-data-original = s01 to s18 individually processed (just fsl for now)

.feat = a folder produced by processing things in fsl

.fsf = record of what parameters we set and ran in fsl for that subject.

  Uses: Can be checked to see what we ran and how we ran it. 
           Can be loaded for a new subject to save time and/or avoid human error. 
           If re-loaded from another subject (say s01) for processing a new one (say, s03), must be sure to change all relevant data being uploaded that would be unique to that new subject (fMRIall, T1brain, green.txt and red.txt, output file, etc... for s03 as opposed to s01) 
  Location: usually in the individual [s01] output file (i.e. wherever you saved it originally in the fsl)

green.txt = pleasure reading file red.txt = close reading file

What’s in green.txt and red.txt files:

    In each row
       the first number is the starting time of the event 
       the middle number is duration
       the last number is the weight to give it in the data processing (i.e. how much to count it).
    (In original green.txt and red.txt files for s01-s018 (i.e. in nmp-data-original), this last number was always 1 because we were always counting everything equally.)
    
    Each row of numbers relates to a "paragraph" (or red vs. green textbox) of reading. The total number should reflect the total # of such green or red boxes read in Mansfield Park.      
    The row with the lowest number (lowest across both green.txt and red.txt files) would be the beginning: likely 2 something. (If green has a 2 in it that was first the first one run; if red has a 2 in it, then that was probably the first. Can be cross-checked for evens vs. odds as we should know RGRG vs. GRGR)
    The row with the highest number (highest across both green and red txt files) marks the last section of reading--i.e. the final green or red textbox of Mansfield Park. This final number is going to be variable because people were reading at different speeds. We need to look for the highest number.
      




Parse the PsychoPy log file

parsePsychopyLog.py is a little python script that parses the log file from PsychoPy, extracts the relevant timing information, and uses it to generate the event timing file that you feed to FSL. It also prints some commands that will help you chop and merge the four fMRI runs.

 python parsePsychopyLog.py behavior/2_2011_Dec_11_1540.log 000?_0?_BOLD_EPI_32mm_2sec.nii.gz

This will produce the two explanatory variable (EV) timing files. It will also tell you how to chop the data files.

Prepare the data

Chop and merge the fmri runs, based on instructions spit out by parsePsychopyLog.py. You will do something like:

fslroi fmri1_raw.nii.gz fmri1.nii.gz -1 -1 -1 -1 -1 -1 10 160
fslroi fmri2_raw.nii.gz fmri2.nii.gz -1 -1 -1 -1 -1 -1 15 190
fslmerge -t fmri_all fmri1 fmri2

Now reorient the fmri:

fslreorient2std fmri_all fmri_all_std

Prepare the T1 data:

fslreorient2std 0002_01_T1w_9mm.nii.gz t1
bet t1 t1_brain

Run the FSL FEAT analysis

To open FSL, go to Terminal and type fsl. (No cd or ls).

Open FEAT.

Get file for s1 that Bob just ran with timing sections from Psychopy.

Load the previous configuration, or fsf file from s1.

In Data,

Set TR to 2 seconds.

DO NOT delete first 3 volumes. This was in general instructions from PPT and meeting, but Bob has already done this in the time slicing.

Make high pass filter cut off 600.

Select 4-D and link to file for INPUT DATA called “fMRI_all.nii.gz”

Name output directory to link to folder by chaining upwards (..) to get to appropriate file. s1 is "/Users/nmp/CNI_fMRI_Data/Experiment_Results/s1/s1_fMRI/s1.feat" (don't add feat myself, it will do this automatically)

If you leave output directory blank, it will create a folder called fMRI_all.feat. (check that it does so) file:///Users/nmp/CNI_fMRI_Data/Pilot/s8/s8_BobNIFTI/fmri_all.feat/report_poststats.html??

In Pre-stats, set timing correction to “interleaved” (EPI) Keep smoothing at 5.

In Stats,

EV 1= normal EV 2- attentive

Set BASIC SHAPE: to 3 volume format. custom 3 ( column format) add the file (the one Bob is creating) to both EVs. :)

add FILENAME w/ link to text file that bob has prepared. [EV1]: ...s9/normal.txt [EV2]: ...s9/attentive.txt

(In later versions normal became green. Normal=pleasure reading=green text boxes. Attentive=close reading=red text boxes. So we're looking for green.txt or red.txt) In Contrasts & F-tests. set up for 2 contrasts (maybe 3 later if we want to do a contrast of attentive & reading to reading for both?)

set up contrast between attentive and normal reading set up contrast between reading and not reading

In Registration: we’re using a high res T1 aligned to the functionals. Mapping to the main structural image. (point it to the T1 weighted,) = for us: T1..._brain

(Needs to be the one pre-processed by Bob, not the one directly from the NIFTI files)

Want to run the brain extraction on this. Fsl reorient to standard AND brain extraction for these T1 images entered in “registration.”

Under main structural image do the “T1 weighted...brain” Users/nmp/CNI_fMRI_Data/Pilot/s8/s8_BobNIFTI/t1_brain

Under standard space do the “/usr/local/fsl/data/standard/MNI152_T1_2mm_brain”


At end, hit SAVE and save file for EACH subject (so we know what we did :) (I saved s8 as … /fslsetup.fsf)

HIT GO!

Final Feat Report will end up in file identified on the web-sertver that pops up. Users/nmp/CNI_fMRI_Data/Pilot/s8_HannahDoherty/s8_BobNIFTI/fmri_all.feat

Notes for reassuring subjects. On risks of fMRI: http://en.wikipedia.org/wiki/Specific_absorption_rate#Mobile-phones_SAR_list

Overlay on the cortical surface

See the General_data_processing_notes page...

before running may need to type bash in terminal line.


Cross Group Analysis

I think this is old (update?)

Go into fsl Open FEAT Change First-Level analysis (button at top) to Higher-Level Analysis Enter number of inputs, or subjects (here, 18) Select FEAT directories Choose for each subject the regular or flipped feat directory Go to Volumes/lc/nmp-data/[s01]/[regular/flipped].feat Choose Output: sCombined (it will add gfeat) Hit Save Hit Go

Cross Group Analysis from fsl to full brain image

Notes:

There's an extra step for the cross group.

There's a freesurfer for average brain that comes with freesurfer. (Bob has the link somewhere.) The tutorial tells you to create a link to it wherever your individual subject freesurfer outputs are.

Freesurfer grabs things from fsl and applies them to the freesurfer brain. The results are already "aligned" coming into freesurfer. The average is already calculated; the statistical math files for each subject are not transformed. The "cope" file is the key result file. It's not thresholded; you can still choose a different threshold even after the fsl steps.

Opening Cope Files

Go into feat directory (lc --> nmp-data --> group analysis regular --> There will be cope1 and cope2).

We also need cope files for individual subjects: nmp-subjects-original --> s01 --> regular.feat --> stats --> There will be cope1 and cope2

Special instructions:

Open terminal

Type cd /

ype ls

Type cd Volumes

- Type cd lc

- Type cd nmp-data

- Type cd nmp-subjects-original

- Type cd s01

- Type cd regular.feat

- Type cd stats

- Type fslview cope1.nii.gz

    • So now we should have opened fslview and are able to see some brain images. **

The crosshairs isolate a voxel. Each voxel has a location, mapped by xyz coordinates. Each voxel has a number.

White means positive numbers, gray means zero, and black means negative numbers.

So for those coordinates, on the right it's millimeters, and on the left it's voxels. The intensity is a number "stored" in the voxel. It's for the statistical map. This is the result. This is what's being mapped in black and white. So if it's negative it's black, etc. (See above.) To reiterate: the intensity will later be correlated to our brain activity; after a threshold is applied, regions of certain intensity will be red and others will be blue, etc. It's all here in the raw data.

Again: Positives are non-thresholded raw data where there is more bloodflow (our comparison) for close v pleasure reading. And negatives are places where there's more activity for pleasure reading.

If we opened cope2, we'd be seeing the same thing, but for reading vs. not reading rather than close vs. pleasure.

What Russ needs to do is get into these cope files.

Bob:

There are two ways to map group data onto a surface. They're two versions of the same method, essentially. Basically, you have to take the individual subjects analyses; there's a command in the tutorial that has you map them to the group space; there's one command that will generate the group average statistical map.

Natalie:

I will send those tutorials to Russ. What I understand is... I need to think of fsl and freeview as two separate things. Freeview needs to be able to not just access group information, but also access the cope files, because these have the raw data for each individual subject for cross group analysis. We did fsl and got our group analysis, which got us a cope file for group analysis.

Bob:

This tutorial thing won't use the fsl group average cope file. The tutorial will show you how to create an average using freesurfer tools. It's the same idea as fsl -- you give it all the cope files for individual subjects, and then there's one command that will [...].

Natalie:

Talking about cropping the beginning and the end of scans... We know time course data isn't all that reliable for just that one voxel. Is there a way to get time course data for an "average" voxel?

Command line:

Terminal --> fslroi

This will let you crop in time.

We want to crop the fsl to feat. We're cropping off time. The input is a 4-dimensional data set: 3 spatial plus time. We don't want to crop anything in space, so... Bob suggests we take some time to use fslview to view the "fmri all" input. Get used to fslview and play around with it. It lets you see space, but it also lets you click through the different time points. Then try this fslroi; you're going to have to crop a different amount from each subject -- you'll want to crop the same time points, but each subject has a different length, because people read at different speeds.

Bob:

One example command: If you don't want to crop in space, you would use these two commands.

1.) fslroi fmri_all.nii.gz fmri_all_cropped.nii.gz 0 -1 0 -1 0 -1 10 80

2.) fslhd fmri_all.nii.gz

If you use fslhd, give it one file, it'll give you the information about that one file. You have to RUN THIS FIRST to figure out how many time points there are. Then command (1) will allow us to crop things out.

"dim4" is the only thing we care about -- this is the length of the 4th dimension. It will be some number. That's how many time points there are for that subject. So you'll tell fslroi to start at frame 10, say, and then you keep "total minus 10" -- this lets you keep total minus the first ten. If you tell it to start at frame 10 and keep "total minus 20" you'll keep the total minus the first ten and the last ten. Natalie: "cutting ten would mean cutting 20 seconds."

Doing this cropping means you'll have to change all the other stuff we ran. (?) Refer back to Psychopy. Keep in mind that people are reading at different speeds. We may have to rerun all of the psychopy versions that would then be entered.

Bob recommends going through the fsl course. Take a good tutorial. In fsl support, select fsl course.


See the freesurfer/FSL tutorial and the relevant FSL wiki page.

For final reconstruction stage: need to go to new folders (see Russ's new code)

In fsl, in the anatomy directory, there should be a folder “fs average”

The overlays should come from the the group overlays. Use the average t1 and average surfaces from this folder. Can use fs-average mgh files.

Calculating Threshold for Reconstructed Data based on False Discovery Rate (FDR)

False Discovery Rate (FDR) is a new approach to the multiple comparisons problem. Instead of controlling the chance of any false positives (as Bonferroni or random field methods do), FDR controls the expected proportion of false positives among suprathreshold voxels. A FDR threshold is determined from the observed p-value distribution, and hence is adaptive to the amount of signal in your data. FDR is more sensitive than traditional methods simply because it is using a more lenient metric for false positives. However, if there is truly no signal anywhere in the brain, a FDR-controlling method has the same control as standard methods. That is, if the null hypothesis is true everywhere, a FDR procedure will control the chance of a false positive anywhere in the brain at the specified level.

Anywhere between 1% and 10% is considered reasonable for FDR

Suggested 5%

FDR relevant links: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FDR https://surfer.nmr.mgh.harvard.edu/fswiki/TkSurferGuide/TkSurferWorkingWithData/TkSurferOverlay

Setting threshold in tksurfer: View → configure → overlay Use value of .05 (aka 5%) https://surfer.nmr.mgh.harvard.edu/fswiki/TkSurferGuide/TkSurferWorkingWithData/TkSurferOverlay

You can’t do fdr directly on cope files; you have to convert them to p files You need to create an image where each voxel is a p-value...

Right now, our Cope files are the log 10 of p, as directed by tk surfer -- it makes more sense to view the log 10 of p, but when doing actual analysis, we must do the actual p. This will spit out your p-value threshold. (You could then do the log 10 of that if you wanted to.) http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FDR All you should need, really, is the p-value image. We’ll have to go back to the nifti format files to get this.

There’s an FDR tool in freesurfer that may be easier to use; you just run it in the command line

Lab Equipment Notes

A nice fMRI analysis workstation

The following hardware would make a nice fMRI workstation. All can be purchased from NewEgg for about $1500.

  • Shuttle SH67H3 Intel Core i7 / i5 / i3 (LGA1155) Intel Socket H2(LGA1155) Intel H67 Intel HD Graphics 2000/3000 integrated in the processor 1 x HDMI XPC Barebone
  • Intel Core i7-2600 Sandy Bridge 3.4GHz (3.8GHz Turbo Boost) LGA 1155 95W Quad-Core Desktop Processor Intel HD Graphics 2000 BX80623I72600
  • G.SKILL Ripjaws X Series 32GB (4 x 8GB) 240-Pin DDR3 SDRAM DDR3 1333 (PC3 10666) Desktop Memory Model F3-10666CL9Q-32GBXL
  • 2X Seagate Barracuda ST3000DM001 3TB 7200 RPM SATA 6.0Gb/s 3.5" Internal Hard Drive (RAID 1+0, for data)
  • Crucial M4 CT128M4SSD2 2.5" 128GB SATA III MLC Internal Solid State Drive (system drive)

It should be installed with a NeuroDebian-compatible Linux distribution, such as Ubuntu.

One station is ideal. Two or three for students is still better. Adobe Photoshop & Adobe Publisher.

For software, install psychopy for experiment design, fsl for data processing and freesurfer for brain visualization. All are free applications. Consider hiring a cs undergrad to help us with coding for psychopy. (Eprime is about $2000 for one license and is an easier GUI for people who don't program).


SETTING UP A WORKSTATION

Network-attached storage

Maybe something like this for about $1600: Seagate STAU12000100 12TB BlackArmor 440 Network Storage