- read_erp_041019.m calculates evoked potentials
- eeg_source_coregister.m manual electrode registration
- show_eeg_mri_coregister.m displays electrode registration
- show_erp_scalp.m shows evoked responses
- eeg_mri_coregister_072922.m more detailed registration
- make_decimated_bem_052524.m simplifies surfaces
- make_bem_d10_eeg_042319.m generates .dip, .eegsensors, .tri, and, .cond files
- make_fwd_openmeeg_072922.m generates a eeg_rh_gain.mat and eeg_lh_gain.mat file
- make_eeg_fwd_042319.m generates a eeg_fwd_042319.mat file
- make_eeg_mne_052524.m generates 6 .stc files
- Download read_erp_041019.m and add it to your subjects eeg_raw folder. This script calculates evoked potentials.
- Change the header file to your .vhdr file location
headerFile = {
'../eeg_raw/SSVEP_out_1.vhdr'
- Change the marker file to your .vmrk file location associated with your header file. It is important to have only one file listed as the script expects only one.
markerFile={
'../eeg_raw/SSVEP_out_1.vmrk'
- Open a new terminal window
tcsh
source .cshrc
setenv SUBJECTS_DIR /Users/jessica/data_analysis/eegfmri/subjects
cd /Users/jessica/data_analysis/eegfmri/subjects
to your subject foldermne_setup_mri --subject 180330_SYH
(there is a strong possibility that this file already exists)mne_setup_source_space --subject 180330_SYH --spacing 5
(there is a strong possibility that this file already exists)mne_watershed_bem --subject 180330_SYH
(there is a strong possibility that this file already exists)cd $SUBJECTS_DIR/180330_SYH/bem
ln -s watershed/041019_inner_skull_surface inner_skull.surf
(there is a strong possibility that this file already exists)ln -s watershed/041019_outer_skull_surface outer_skull.surf
(there is a strong possibility that this file already exists)ln -s watershed/041019_outer_skin_surface outer_skin.surf
(there is a strong possibility that this file already exists)
- Make sure you are in the subjects folder directory.
mkheadsurf -subjid 180330_SYH
if done successfully, output should be "mkheadsurf done" and a lh.seghead file should be in /Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/surf
If Error "mkheadsurf: Command not found"
cd home
tcsh
source .cshrc
cd /Users/jessica/data_analysis/eegfmri/subjects
setenv SUBJECTS_DIR /Users/jessica/data_analysis/eegfmri/subjects
setenv FREESURFER_HOME /Applications/freesurfer/7.4.1
source $FREESURFER_HOME/SetUpFreeSurfer.csh
setenv FSL_DIR /Users/jessica/fsl
echo $SUBJECTS_DIR /Users/jessica/data_analysis/eegfmri/subjects
make sure you are in the correct subject directorycd /Users/jessica/data_analysis/eegfmri/subjects
mkheadsurf -subjid 180330_SYH
should now work
cd /Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/surf
to the location of your lh.seghead filemris_convert lh.seghead lh.seghead.tri
if done successfully, output should be "Saving lh.seghead.tri as a surface in TKREGISTER space"
- Download the digitizer folder
- Download eeg_source_coregister.m and add it to your subjects eeg_raw folder
- Change line 4, 7, 8, and 9 to your subject ID, and line 12 and 13 to the name of your .eps and .ela files in your digitizer folder then run
- If done successfully, there should be a figure 1 pop-up of a head model
- Download show_eeg_mri_coregister.m and add it to your subjects eeg_raw folder. This script displays the results of electrode co-registration.
- Change line 3 to your subject directory
setenv('SUBJECTS_DIR','/Users/jessica/data_analysis/eegfmri/subjects/');
- Change line 6 to the location of your 5-src.fif file
file_source_fif='/Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/bem/180330_SYH-5-src.fif';
- Change line 8 to the location of your lh.white file
surfin_lh='/Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/surf/lh.white';
- Change line 9 to the location of your rh.white file
surfin_lh='/Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/surf/rh.white';
- Change line 10 to the location of your outer_skin_surface file
surf_outer_skin='/Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/bem/watershed/180330_SYH_outer_skin_surface';
- Change line 11 to the location of your outer_skull_surface file
surf_outer_skull='/Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/bem/watershed/180330_SYH_outer_skull_surface';
- Change line 12 to the location of your inner_skull_surface file
surf_inner_skull='/Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/bem/watershed/180330_SYH_inner_skull_surface';
- Change line 15 to the output name from the previous step
eeg_output_name='fwd_prep_041618.mat';
- Download show_erp_scalp.m and add it to your subjects eeg_raw folder. Change all variable names from
erp_avg
toerp
(this step should only be done when you have the eeg_fwd_prep_042319.mat file). If done successfully, you should have Figure 1 of the scalp model and if you click on a region there should be a Figure 2 pop-up of the evoked response plot
setenv SUBJECTS_DIR /Users/jessica/data_analysis/eegfmri/subjects
mkheadsurf -subjid 180330_SYH
if done successfully, output should be "mkheadsurf done" and a lh.seghead file should be in /Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/surfcd /Users/jessica/data_analysis/eegfmri/subjects/180330_SYH/surf
to the location of your lh.seghead filemris_convert lh.seghead lh.seghead.tri
if done successfully, output should be "Saving lh.seghead.tri as a surface in TKREGISTER space"- Download eeg_mri_coregister_072922.m and add it to your subjects eeg_raw folder
- Change line 3 to your subject directory
setenv('SUBJECTS_DIR','/Users/jessica/data_analysis/eegfmri/subjects/');
- Change line 6 to the location of your fif file
file_source_fif='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/180401_YTH-5-src.fif';
- Change line 9-11 to the location of your inner/outer skull and outer skin files
surf_outer_skull='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/watershed/180401_YTH_outer_skull_surface';
surf_inner_skull='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/watershed/180401_YTH_inner_skull_surface';
surf_outer_skin='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/surf/lh.seghead.tri';
- Change line 14 to
file_elec_loc='../digitizer/YTH.DAT';
- If done successfully there should be a more detailed co-registration, press k to move the blue dots for manual registration. When complete, save and export to the eeg_fwd_prep_072922.mat file
- Download make_decimated_bem_052524.m and add this to your subjects eeg_raw folder
- Change lines 3-9, make sure these are the decimated files (_d10)
setenv('SUBJECTS_DIR','/Users/jessica/data_analysis/eegfmri/subjects/'); %for MAC/Linux
file_surface={
'/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/outer_skin.surf_d10.surf';
'/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/outer_skull.surf_d10.surf';
'/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/inner_skull.surf_d10.surf';
};
- If done successfully, there should be a Figure 1 and 2 pop-up of the original (Figure 1) and simplified surface (Figure 2)
- Download make_bem_d10_eeg_042319.m and add this to your subjects eeg_raw folder
- Change lines 3-13 make sure your file_eeg_mat file is the same as the one you populated in the previous detailed co-registration step (in this case eeg_fwd_prep_072922.mat)
setenv('SUBJECTS_DIR','/Users/jessica/data_analysis/eegfmri/subjects/'); %for MAC/Linux
%source space
file_source_fif='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/180401_YTH-5-src.fif';
%make sure these are the decimated files (_d10)
surf_outer_skin='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/outer_skin_d10.surf';
surf_outer_skull='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/outer_skull_d10.surf';
surf_inner_skull='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/inner_skull_d10.surf';
%sesnor info
file_eeg_mat='./eeg_fwd_prep_072922.mat';
output_stem='180401_YTH_d10';
- If done successfully, there should be a Figure 1 pop-up showing the inner skull, outer skull, and outer skill geometries, as well as source points (in red) and EEG sensor locations (in blue). You should also have 7 files generated in your eeg_raw folder: 041019_d10-{lh, rh}.dip (dipole current source), 041019_d10.eegsensors (locations of EEG sensors), scalp.tri, skull.tri, cortex.tri (description on geometry for skull and scalp boundaries), 041019_d10_bem.cond (conductivity of materials between boundaries), 041019_d10_bem.geom (wrapper file for boundary geometries)
- Download OpenMEEG and add it to your fhlin_toolbox
- Download make_fwd_openmeeg_072922.m and add it to your eeg_raw folder
- Change line 3 to your subject ID
subject='180401_YTH';
and run. This step may take a while. If done successfully, there should be a eeg_lh_gain.mat and eeg_rh_gain.mat in your subjetcs eeg_raw folder
Troubleshooting Error Zsh:1: command not found
Make sure OpenMEEG is correctly initiated in your vi .cshrc file in the settiing up environment step
Running Script on Server
- Enter the server (seen in the useful commands page)
cd /space_lin2/jdin
mkdir eeg_source
make a eeg_source folder in the jdin foldercd eeg_source
inside this folder make a subjects foldermkdir subjects
- In another teriminal window
cd /Users/jessica/data_analysis/eegfmri
scp -r -P 2222 ./180401_YTH/* jdin@localhost:/space_lin2/jdin/eeg_source
moves the 180401_YTH folder from your local computer to the specified folder location on the server- In another teriminal window
cd /Users/jessica/data_analysis/eegfmri/subjects
- cp -r -P 2222 ./180401_YTH/* jdin@localhost:/space_lin2/jdin/eeg_source` moves the 180401_YTH subject folder (with the T1 data) from your local computer to the specified folder location on the server
tcsh
matlab -nodisplay
open MatLab in the terminal window you opened the server on (Note: to exit matlab typeexit
)setenv ('EDITOR', 'vi');
setenv ('SUBJECTS_DIR','/space_lin2/jdin/eeg_source/subjects')
cd /space_lin2/jdin/eeg_source/eeg_raw
thenls
and there should be all the files from 180401_YTHedit e8_make_fwd_openmeeg_072922
to edit this script, if needede8_make_fwd_openmeeg_072922
to run the script (Note you can type 'e8' then tab to autocomplete the rest of the file name)
- Download make_eeg_forward_052524.m and add it to your eeg_raw folder
- Change line 9 to your subject directory and line 11 to your subject ID. Make sure the file_eeg_mat in line 13 is correct and run
- If done successfully, there should be a eeg_fwd_052524.mat file in your subjects egg_raw folder
- Download make_eeg_fwd_042319.m and add it to your eeg_raw folder
- Change line 10 to the location of your subjects src.fif file
file_source_fif='/Users/jessica/data_analysis/eegfmri/subjects/180401_YTH/bem/180401_YTH-5-src.fif';
- If done successfully, there should be a eeg_fwd_042319.mat file in your subjects eeg_raw folder
- Download make_eeg_mne_052524.m and add it to your eeg_raw folder
- Change lines 3-4 to ensure you are using the correct eeg_fwd and fwd_prep files
file_fwd='eeg_fwd_052524.mat';
file_bem='fwd_prep_041618.mat';
- Change line 9 to your subject ID
- Change all
erp_avg
toerp
in lines 29-31 - Make sure the number in 29-31 is the trigger with the event (in this case 10, which is the 2ed trigger).
Y=erp{2}.erp; %
timeVec=erp{2}.timeVec;
label=erp{2}.electrode_name;
- If done successfully, there should be 6 .stc files, SSVEP_out_1_042124_15.0hz_dspm-lh/rh, SSVEP_out_1_042124_dspm-lh/rh, and SSVEP_out_1_042124_mne_abs-lh/rh
- Download make_eeg_mne_052524.m and add it to your eeg_raw folder
- Change line 3 to your subject directory and line 5 to your subject ID
- Change line 11 to the .stc file with an event with the trigger (in this case trigger 2, number 10)
[stc,v_idx,a,b,timeVec]=inverse_read_stc('SSVEP_out_1_042124_dspm-rh.stc');
- Run one hemisphere at a time (comment out the other)