Commit f091e9a7 authored by Martynka's avatar Martynka
Browse files

Upload New File

parent 4f92fb1e
clc
clear
cd('\\130.60.169.45\methlab\Neurometric\Antisaccades\code\eeglab14_1_2b')
eeglab;
close all
addpath('\\130.60.169.45\methlab\Decoding_workshop\fieldtrip\fieldtrip-20200109\fieldtrip-20200109');
addpath('\\130.60.169.45\methlab\Decoding_workshop\mvpa_light\MVPA-Light-master\MVPA-Light-master\startup');
ft_defaults
startup_MVPA_Light
x = dir('\\130.60.169.45\methlab\ETH_AS\preprocessed2')
subjects = {x.name};
subjects = {subjects{4:end-3}}';
clear x
cd('\\130.60.169.45\methlab\ETH_AS')
%%
for subj = 347:length(subjects) %186 - BA5 didnt work, 346- BY2
datapath = strcat('\\130.60.169.45\methlab\ETH_AS\preprocessed2\',subjects{subj});
cd (datapath)
load EEGprocuelong
load trialinfocuelockedlong %called trialinfopro/trialinfoanti
EEG=EEGprocuelong
%% reorganize data to be compatible with FieldTrip
ftdata.fsample = EEG.srate;
ftdata.label = {EEG.chanlocs(:).labels};
for trl = 1:EEG.trials
ftdata.trial{trl} = EEG.data(:,:,trl);
ftdata.time{trl} = EEG.times./1000;
end
ftdata.trialinfo = trialinfopro.cues(1:trialinfopro.epochs)
cuedata = ftdata;
clear ftdata
%% reference of time freq
% http://www.fieldtriptoolbox.org/tutorial/timefrequencyanalysis/
cfg = [];
cfg.output = 'pow';
cfg.method = 'mtmconvol';
cfg.taper = 'hanning';
cfg.foi = 1:1:40; % analysis 2 to 30 Hz in steps of 2 Hz
cfg.t_ftimwin = ones(length(cfg.foi),1).*1; % length of time window = 1 sec, in order to have 1 Hz freq resolution
cfg.toi = (ftdata.time{1}(1)+cfg.t_ftimwin(1)/2):0.05:(ftdata.time{1}(end)-cfg.t_ftimwin(1)/2); % time window "slides" from -1.5 to 2.5 sec in steps of 0.05 sec (50 ms).
cfg.keeptrials = 'yes';
tfrcue = ft_freqanalysis(cfg, cuedata);
tfrcue.trialinfo = cuedata.trialinfo;
%% do baseline first for cue locked data
cfg = [];
cfg.baseline = [-.8 -.5];
cfg.baselinetype = 'db';
tfrblcue = ft_freqbaseline(cfg,tfrcue);
%%
save tfrcue tfrcue tfrblcue
%% select single trials data
cfg = [];
cfg.latency = [-.8 2];
cfg.frequency = [8 12];% set here the freq of interest
%number of frequency bins as loop
cfg.avgoverfreq = 'yes';
erdcue = ft_selectdata(cfg,tfrblcue);
%% create raw erd data for cue locked data (event related desynchonisation)
for trl = 1:EEG.trials
rawerdcue.trial{trl} = squeeze(erdcue.powspctrm(trl,:,:,:));
rawerdcue.time{trl} = erdcue.time;
end
rawerdcue.label = erdcue.label;
rawerdcue.dimord = 'chan_time';
rawerdcue.trialinfo = erdcue.trialinfo;
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment