Functional Connectivity Maps

From NUTMEGwiki

Jump to: navigation, search

Contents

Setting up your account

In the Linux terminal:

  • cd
  • gedit .cshrc
  • In the line set path=(...$path), add /data/research_meg/fcm before the $path) in the end. Save.
  • Close and reopen a terminal, or type source .cshrc
  • You will also need the permission to submit qsub jobs. Ask around to learn how.

In MATLAB:

  • Go to menu File-->Set Path
  • Select Add Folder, input the folder /data/research_meg/fcm, Ok
  • Click Save. You might have to indicate the path to your MATLAB path definition file (pathdef.m), which is usually in your home directory or in ~/matlab/
  • You also need a current working copy of NUTMEG (make sure you have an updated version).

General Note

Each command automatically checks if the data to be calulated next is already saved in the current directory. Therefore, if you take a break at some time, or if a certain step fails, you do not have to repeat everything from scratch. However, this also means that you have to delete or rename a file, if it contains wrong data that you would like to recalculate. In the following, I will indicate the file saved in each step. Also, some of the steps described below are skipped if a file containing the data is already present in the current directory.

Selecting an Artifact-Free Segment of Resting State Data

Linux Terminal:

  • cd to the folder containing the subject's dataset.
  • List its contents: =ls LastFirst_EPI_date_00.ds=
  • If there is a file ending with =.gz=, you have to unzip this first: =gunzip LastFirst_EPI_date_00.ds/*.gz=.
  • =DataEditor -data LastFirst_EPI_date_00.ds=
  • Check the sampling rate and the length of each trial (how many seconds)
  • Find a trial of at least 1 minute length that contains no artifacts, and that was recorded with eyes closed. If you are not sure which trials correspond to eyes closed, you can check the log books in the lab.
  • =fcm_sensor -help= to see the syntax
  • =fcm_sensor dataset.ds trial samplingrate shapefile= to create a new dataset with the selected trial. =trial= is the selected trial number, the =samplingrate= is in Hz, and =shapefile= is the path to a file ending with =.shape= that you should find either in the subject's MRI directory or in the data directory.
  • If the selected trial has more than 1 minute of data or an artifact you want to exclude, you can define the start and end time of your selected trial: =fcm_sensor dataset.ds trial samplingrate shapefile starttime endtime=. The times are in seconds.
  • This creates a new dataset named =RestingState_Sensor_trx.ds=

P-images

Calculating Source Time-Series with an Adaptive Spatial Filter

Linux Terminal:

  • =fcm_virtual -help= to see syntax
  • =fcm_virtual RestingState_Sensor_trx.ds P= to calculate source time series. The =x= in =trx= should be replaced with the trial number you used.
  • This creates a new dataset named =RestingState_Virtual_P.ds=.

Settings

In MATLAB:

  • =fcm_set_Pimage=
  • Wait while the source time series are imported and saved in MATLAB format as =RestingState_Virtual_P_1-20Hz.mat=.
  • A new window opens that lets you define the boundaries of the subject's alpha band. With the left mouse button, click at the lower edge of the individual's alpha peak, and then on the higher edge. The red vertical lines indicate your chosen alpha band. If you are happy with it, click =Yes=, otherwise click =Let me do it again=. This saves a file named =alpharange.mat=.
  • NUTMEG's MRI Coregistration GUI opens. Choose the individuals structural MRI and [[Bil.SpatNormStrucMRI][normalized structural MRI]] (in the subject's MRI or data directory). In the Fiducials section, load the file =default.hdm= in RestingState_Sensor_trx.ds=. Check the correct position of the fiducials by clicking on the =show= buttons. If they are off, you have to set them manually by moving the green crosshairs in the SPM window, and clicking the =set= buttons in the NUTMEG Coregistration window. *Click =Done= once you are done.* This saves a file named =coreg.mat=.
  • The function then defines all possible combinations of connections between all voxel pairs, and saves them in the folder =comps=. Note that P-images and L-images have different connection definitions, but both of them save them in a folder named =comps=. You can therefore not run L-images and P-images at the same time (only subsequently). Once the L- and P-images are completed, the definitions in =comps= are automatically removed, so that you can run the other image type.
  • A menu asks you when you would like to submit your qsub jobs.

Linux Terminal:

  • You can check the status of your jobs by typing =qstat=, or =qstat -u yourusername=.

Assembling all jobs and calculating functional connectivity

In MATLAB:

  • Once all your qsub jobs are done, type =fcm_get_Pimage=.
  • If you get an error, your qsub jobs might have failed. You can find out the reason by displaying the qPimage.* files in the subject's directory: =!more qPimage.csh.o1234.1=.
  • The imaginary coherence of all defined connections is assembled and saved under =imcoh_Pimage.mat=.
  • A file named =s_beamtf_meanabsimcoh.mat= is automatically created and displayed. The mean imaginary coherence (i.e., the functional connectivity) of each square (voxel) with all other squares (voxels) is represented by a corresponding color. You can change the color scale by clicking on =Scale Abs Max= and changing the drop down menu to =Scale Min - Max=, and by changing the settings of the =Normal Style= drop down menu. *NOTE: The =dB= color scale label in the Time-Frequency Viewer is wrong in this case. The scale represents mean (absolute) imaginary coherence bound between 0 and 1* (if you have time to make the labels in nut_timef_viewer flexible, this would be appreciated).
  • A menu pops up and gives you the option to statistically compare the imaginary coherence values of the current subject with a healthy control population of 14 subjects, and thus to create the actual P-image. If the available control population does not match your patient sample, you can skip this part, and later create your own control population (see below).
  * If you choose to create P-images, the data is automatically spatially normalized and saved under: =s_beamtf_meanabsimcoh_spatnorm.mat=. If you did not specify a spatially normalized structural MRI in the NUTMEG Coregistration window, this is might fail.
  * The P-image is created, saved under =s_beamtf_Pimage.mat=, and displayed. The color scale now represents: (mean imaginary coherence of current subject) - (average imaginary coherence of all control subjects). You can statistically threshold the image by clicking on =Power= and setting the drop down menu to =p=. By default, the p cutoff is not set to 0.05, but to a cutoff calculated with 10% false discovery rate to correct for multiple testing. This is, however, not necessary, since each voxel is tested against its own normal distribution. You may therefore change the values in the =+= and =-= fields to =0.05=.

Creating your own control population for P-images

In MATLAB:

  • For each control subject, go through the steps described above. When =fcm_get_Pimage= asks you for the control population, choose the last option (=Do not calculate P-image=)
  • Type =edit nut_beamstats=. Press =Ctrl+H=. In the =Find what= field, type =%allsubj=, and in the =Replace with= field =allsubj=. Click on =Find= and then =Replace= 3 times until the computer beeps.
  • =nut_timef_stats=
  • In the =Task= square, check the option =Mean activation from baseline w/o statistics=, and in the =Filetype= square =s_beamtf files=. In the =Subjects= field, enter the number of control subjects you want to include (there should be as many as possible, at least ~10). Then click =Check=.
  • In the window that appears, go to the directory of the first subject and load the file =s_beamtf_meanabsimcoh_spatnorm.mat=. Repeat this for all subjects, until no further windows appear and the =Run= button becomes enabled. Click =Run=.
  • When MATLAB displays the =K>>= prompt, type =save somepath/allsubj.mat allsubj refvoxels= with =somepath= referring to the path to your data folder. Hit enter, and then type =dbquit=.
  • =load /data/research_meg/fcm/controlpopulations=
  • =num = length(controls)=, this displays the number of control populations created by all users so far.
  • =controls(num+1).path = 'somepath/allsubj.mat'=, with =somepath= being the path to the folder that you specified above for the =save ...= command.
  • =controls(num+1).description = 'some description'=. Describe the type of dataset, number of subjects, mean age, age range, number of women.
  • =save /data/research_meg/fcm/controlpopulations controls=
  • =edit nut_beamstats=. Change all modifications you made above back to as they were before: find =allsubj=, replace with =%allsubj=. Save.
  • That's it. Now you can run your patients, and choose your own control population when asked for it.

L-images

Calculating Source Time-Series with an Adaptive Spatial Filter

Linux Terminal:

  • =fcm_virtual -help= to see syntax
  • =fcm_virtual RestingState_Sensor_trx.ds L= to calculate source time series. The =x= in =trx= should be replaced with the trial number you used.
  • This creates a new dataset named =RestingState_Virtual_L.ds=. *Do not try to display this data in CTF's DataEditor. There are thousands of virtual channels, which will probably blow up your memory.*

Settings

In MATLAB:

  • =fcm_set_Limage=
  • Wait while the source time series are imported and saved in =.mat= format (this may take a while).
  • A new window opens that lets you define the boundaries of the subject's alpha band. With the left mouse button, click at the lower edge of the individual's alpha peak, and then on the higher edge. The red vertical lines indicate your chosen alpha band. If you are happy with it, click =Yes=, otherwise click =Let me do it again=. This saves a file named =alpharange.mat=.
  • NUTMEG's MRI Coregistration GUI opens. Choose the individuals structural MRI (in the subject's MRI or data directory). You do not need a spatially normalized structural MRI for L-images, but for P-images. Therefore, if you plan on running P-images later, load the normalized structural MRI here. In the Fiducials section, load the file =default.hdm= in RestingState_Sensor_trx.ds=. Check the correct position of the fiducials by clicking on the =show= buttons. If they are off, you have to set them manually by moving the green crosshairs in the SPM window, and clicking the =set= buttons in the NUTMEG Coregistration window. *Click =Done= once you are done.* This saves a file named =coreg.mat=.
  • A message window pops up telling you what to do next. *STOP: DO NOT CLICK "OK" BEFORE YOU HAVE COMPLETED THE INSTRUCTIONS!* For step 2, bring up the NUTMEG window, and choose menu =Manual VOI-->Select VOI=. Then use the left mouse button to mark the corners of the tumor region in the cross-sectional view that is surrounded by a red square. Its better to include to much than to cut off parts of the tumor. Also include edema. Once you have marked a complete polygon, click the right mouse button. Do the same thing for all 3 cross-sections. After you are done, you may click the =Ok= button in the instruction window to continue. If you realize that you selected badly, complete any non-empty selection in all cross-sections. You are then asked if you are happy with your choice, and are given the opportunity to do it again.
  • The function then defines the connections between the just selected "tumor voxels" and a grid of equally distributed voxel in the entire brain. In addition, it also does the same thing for the voxels that are contralateral to the selected "tumor voxels". These connection definitions are saved as text files in the folder =comps=. Note that P-images and L-images have different connection definitions, but both of them save them in a folder named =comps=. You can therefore not run L-images and P-images at the same time (only subsequently). Once the L- and P-images are completed, the definitions in =comps= are automatically removed, so that you can run the other image type.
  • A menu asks you when you would like to submit your qsub jobs.

Linux Terminal:

  • You can check the status of your jobs by typing =qstat=, or =qstat -u yourusername=.

Assembling all jobs and calculating functional connectivity

In MATLAB:

  • Once all your qsub jobs are done, type =fcm_get_Limage=.
  • If you get an error, your qsub jobs might have failed. You can find out the reason by displaying the qLimage.* files in the subject's directory: =!more qLimage.csh.o1234.1=.
  • The imaginary coherence of all defined connections is assembled and saved under =imcoh_Limage.mat=.
  • The function then automatically calculates the mean imaginary coherence of all "tumor voxels", and performs a statistical comparison with the contralateral voxels (see Annals of Neurology paper for details). The resulting data is saved under =s_beamtf_Limage.mat= and displayed.
  • The T-value of each tumor voxel is represented by a corresponding color. You can change the color scale by changing the settings of the =Normal Style= drop down menu. *NOTE: The color scale label in the Time-Frequency Viewer is wrong in this case. The scale represents T-values and not dB* (if you have time to make the labels in nut_timef_viewer flexible, this would be appreciated).
  • You can statistically threshold the image by clicking on =Power= and setting the drop down menu to =T-test p=. By default, the p cutoff is not set to 0.05, but to a cutoff calculated with 10% false discovery rate to correct for multiple testing. In our experience, however, even the uncorrected p-values are reliable. You may therefore change the values in the =+= and =-= fields to =0.05=.

Contact

For any questions: aguggis_(a)_gmail.com