Analysis Overview

Use this template study file to set up your analysis (updated 3/14/2010):

/space/mdkm1/7/halgdev/analysis/iEEG_NYU/STUDIES/STUDY_template_olf_110314.mat

ERP analysis

  1. Artifact rejection

Before you do artifact rejection, you have to do preprocessing first;

Load data; raw data (NY***_task_500Hz_flt32.nspike.epoch_data.mat), then from global menu choose ts_preprocess

Set the filters then hit run. Wait until you see “finished” in the matlab window.

Now you can start artifact rejection.

Save reject data as: NY***_task_reject_data.mat

Filters to set:

baseline correction= yes

baseline window = [-0.15  0] ( or [-0.1 0.01] )

detrend = yes

bpfilter=yes

bpfreq=  [0.1  30]

linenotchfilter = yes

linenotchfilterfreq=60

lineDFTfilter = yes

  1. ts_process_ieeg_data for epochs

This function saves each condition as it’s own epoch_data file. (Make sure to set saveepochs to 1, and saveaverage to 0)

Input: raw data (NY***_task_500Hz_flt32.nspike.epoch_data.mat) (file type: epoch_data)

Rejectfile: NY***_task_reject_data.mat  (generated ERP artifact rejection) — bad trials are deleted.

Create epoch combinations, if needed: epoch_combinations = {‘1+2’,’1+4’}  and   epoch_neweventcodes = [5 6]

Filters to set:

baseline correction = [-0.15  0]

detrend = yes

bpfilter =  [0.1  30]

linenotchfilter = yes

lineDFTfilter = yes

Ouput: 1 epoch data file per condition saved in the matfiles folder, (NY***_task_epoch_data_rej_event1.mat) (file type: epoch_data)

** Filters are not applied and saved when you save epoch data, they are only applied and saved when you save average data

  1. ts_process_ieeg_data for averages

This saves an epoch_data structure with an average wave for each condition with filters applied. (Make sure to set saveepochs to 0, and saveaverage to 1)

Input: All ouput files from ts_process_ieeg_data (NY***_task_epoch_data_rej_event1.mat), file for every condition (file type: epoch_data)

Rejectfile: NONE

Filters to set:

baseline correction = [-0.15  0]

detrend = yes

bpfilter =  [0.1  30]

lnfilter = yes

dftfilter = yes

Output: One average data file saved in the matfiles (NY***_task_ avg_data_In60_dt_dt_pb0.1-30_blc.mat) (file type: avg_data)

**Filters are now applied and  saved.

  1. ts_statistics_wrapper

This function creates a statistics file for each contrast. Indicate contrasts in event = {[1 2],[1 3]}

Input: All epoch output files from ts_process_ieeg_data, not avg file (NY***_task_epoch_data_rej_event1.mat) (file type: epoch_data)

Rejectfile: NONE

Filters to set:

baseline correction = [-0.15  0]

detrend = yes

bpfilter =  [0.1  30]

lnfilter = yes

dftfilter = yes

Output: statistics files, one for each comparison in the matfiles/stats folder (NY**_stats_events1_3.mat)

  1. ts_ezplot

Input: the one average data file from ts_process_ieeg_data for averaging ERP  (NY***_task_ avg_data_In60_dt_dt_pb0.1-30_blc.mat (file type: avg_data)

Indicate contrasts in event = {[1 2],[1 3]} (same as stats wrapper)

Statfile: statistics file created by ts_statistics_wrapper

Rejectfile: NONE

Filters to set: NONE

Indicate output directory in outpath. (rootoutdir/images/erp_auto)

After you plot the ERPs, you may need to re plot them after setting the autoscale filter = 1 and if you are searching for late cognitive responses, you also need to set the: ts_ezplot.toilim = [-0.3 0.9]. For this new images, you can indicate output directory in outpath (rootoutdir/images/erp_abs)

High gamma analysis

  1. ts_freqanalysis_fieldtrip

This function creates the wavelets for all frequencies: [2 3 4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 25 30 35 40 45 50 55 70 80 90 100 110 120 130 140 150 160 170 180 190 200].

Make sure to process only original events, without combinations.

events={[1],[2],[3]}

Input: original raw data file (NY***_task_500Hz_flt32.nspike.epoch_data.mat) (file type: epoch_data)

** this function can not take a *.eeg file as it’s input. If you are working with a Nicolet patient, then run a ts_process_eeg_data (NO FILTERS OR BLC) with the *.eeg as your input to save the epoch files (1 for each condition) and select all of those files as your input for ts_freqanalysis_fieldtrip. **

Rejectfile: NONE

Filters to set:

baseline correction = [-0.15 0]

Output:  for each condition: 1 summary file (NY***_timefreq_event1.mat) and 1 file per channel (NY***_timefreq_event1_chan*.mat) in the matfiles/timefreq folder (file type: timefreq_data)

  1. ts_freqband_average

This function creates an epoch data structure for all channels and conditions in the specified frequency range. ex: freqband = [70 190]

Input: all output files, summary (NY***_timefreq_event1.mat)  and chan (NY***_timefreq_event1_chan*.mat)  from ts_freqanalysis_fieldtrip (file type: timefreq_data)

Rejectfile: NONE

Make sure to list the original conditions in the event parameter [1 2 3].

The findex parameter (not frequencies!) selects the frequencies you would like to include. The values in findex correspond to the indices of the frequency parameter in ts_freqanalysis_fieldtrip. (ex if findex=[1] it will select the first value in frequency, which is 2)

highgamma: findex = [25 26 27 28 29 30 31 32 33 34 35 36 37 38] which correspond to frequencies: 70 80 90 100 110 120 130 140 150 160 170 180 190 200

lowgamma: findex = [18 19 20 21 22 23 24] which correspond to frequencies: 25 30 35 40 45 50 55

Filters to set:

baseline correction = [-0.15 0]

baselinetype = absolute

freqcorr = 1

Output: 1 epoch data structure file for the specific frequency range in the matfiles/timefreq/bands folder (NY***_freqband_70_190Hz_events*.mat) (file type: epoch_data)

  1. Artifact rejection

Do artifact rejection on the epoch data structure that is generated by ts_freqband_average (NY***_freqband_70_190Hz_events*.mat), this is done the same way as ERP artifact rejection.

Before you run artifact rejection, run ts_preproc on the TF wave data:

blc = [-0.15 0]

Save reject data as: NY***_task_reject_data_70_190.mat

  1. ts_data_selection

This function applies the reject file and deletes the rejected trials of the original conditions.

You have to add a new batch in the batch list. You can copy any batch, and then remove the function in that batch (for example ts_combination) and add the ts_data_selection function (select this function from the dropdown menu at the top of the neurophysiology window, and then hit add function)

Input: epoch data structure created by ts_freqband_average (NY***_freqband_70_190Hz_events*.mat)  (file type: epoch_data)

Rejectfile:  NY***_task_reject_data_70_190.mat

Filters to set: NONE

Make sure to set save_falg to 1

The name of the output file will just be whatever your prefix. So, it is a good idea to add something to the prefix for this file (ex: NY276_HH_highgamma_rej). Also, once the combination file has been created, delete this file, to save memory.

Output:  high gamma data for original conditions with rejected trials deleted (NY***_rej.mat) (file type: epoch_data)

  1. ts_combine conditions

This function makes your combination events for the high gamma, and applies artifact rejection. Enter same condition combinations as the ERP analysis.

Input: epoch data structure created by ts_data selection (NY***_rej.mat)  (file type: epoch_data)

Rejectfile: NONE

Filters to set:

blc = [-0.15 0]

Specify output directoy in outpath (ex: matfiles/timefreq/bans/combo_highgamma)

Output:  high gamma data for original conditions and combination conditions (NY***_epoch_data_combos) (file type: epoch_data)

  1. ts_statistics_wrapper

This function creates a statistics file for each contrast (indicate contrasts in event = {[1 2],[1 3]}

Input: combination file created by ts_combine_conditions (NY***_epoch_data_combos)  (file type: epoch_data)

Rejectfile:  None

Filters to set:

blc = [-0.15 0]

Output: statistics files, one for each comparison (NY**_stats_events1_3.mat)

  1. ts_ezplot

Input: combination file created by ts_combine_conditions (NY***_epoch_data_combos) (file type: epoch_data)

Statfile: statistics file created by ts_statistics_wrapper

Rejectfile:  None

Filters to set:

blc = [-0.15 0]

Indicate output directory in outpath. (rootoutdir/images/highgamma)

After you plot the high gamma, you may need to re plot them with setting the autoscale filter = 1 and if you are searching for late cognitive responses, you should set the:  ts_ezplot.toilim = [-0.3 0.9]. For this new images, you can indicate output directory in outpath (rootoutdir/images/highgamma_abs)

Common Errors

  1. Input must cell array of string.

— check brackets: {} and []. Make sure you have the correct syntax.

  1. error using == mkdir

permission denied

— make sure that your current matlab directory is the same as your analysis directory, timesurfer creates a Log folder in your current directory, and if you are in a folder where you don’t have write permission, you will get this error.

  1. error having to do with the label variable.

— make sure there are no duplicate channels in raw data

— open your raw data dile (file>import data) and look at the channel names (epoch_data.sensors_info.label) and make sure there are no duplicates. If there are you can either ask Olga to fix the names and resave the raw data, or you can fix the name in your epochs created by process_ieeg_data (import each epoch, fix the chan names and resave the epoch)

  1. Reference to non-existent field ‘mask’

— check that your events match up in number and order with the stats file!

— make sure you can plot your events without statistics

— make sure that your stats file ran and saved without any errors

  1.  When combining for ts_combo conditions, make sure brackets are correct

–ex.  {‘1+2+3’,’4+5+6’….}

** To check how much space is left on a disk, type in the terminal:

df -h /space/mdeh2/2

Raw data file types:

For Nspike patients: NY***_task_500Hz_flt32.nspike.epoch_data.mat

– some of the older patients maybe at a different sampling rate (ex. 400Hz). The important things is that it is an epoch_data.mat file.

*.dio file is the list of timestamps and triggers

For Nicolet patients: *.eeg is the equivalent of the epoch_data.mat file. (these files can be used for the input of ts_process_ieeg_data. They can not be used as the input for ts_freqanalysis_fieldtrip, run ts_process_ieeg_data to save them in an epoch_data format)

*.edf and *.cnt files are the continuous raw data

*.ev2 file is the list of timestamps and triggers.