Commit 1da5daa7 authored by Julius Welzel's avatar Julius Welzel

Replace ana04_preERD.m

parent 25efb947
......@@ -22,10 +22,11 @@ SUBJ = extractBefore({list.name},'_');
load ([PATHIN_EMG 'EMG_ES.mat']); %includes cfg file
load ([PATHIN_EMG 'emg_all.mat']); %includes cfg file
FB = {'mue','beta','broad'};
%% Define params for ERD ME analyses to select ROI
cfg.ERD.HP = 8;
cfg.ERD.LP = 12;
cfg.ERD.HP = [8 13 8];
cfg.ERD.LP = [12 30 30];
cfg.ERD.EEG_ELECS = {'E01' 'E02' 'E03' 'E04' 'E05' 'E06' 'E07' 'E08' 'E09' 'E10' 'E11' 'E12' 'E13' 'E14' 'E15' 'E16' 'E17' 'E18' 'E19' 'E20' 'E21' 'E22' 'E23' 'E24' 'E25' 'E26' 'E27' 'E28' 'E29' 'E30' 'E31' 'E32' 'E33' 'E34' 'E35' 'E36' 'E37' 'E38' 'E39' 'E40' 'E41' 'E42' 'E43' 'E44' 'E45' 'E46' 'E47' 'E48' 'E49' 'E50' 'E51' 'E52' 'E53' 'E54' 'E55' 'E56' 'E57' 'E58' 'E59' 'E60' 'E61' 'E62' 'E63' 'E64'};
cfg.ERD.resample = 100;
......@@ -37,7 +38,8 @@ BL_sam = cfg.ERD.BL_ms_ep/(1000/cfg.ERD.resample);
%%
for fb = 1:length(FB)
for sub = 1:length(SUBJ)
tic
% take different trials into account
......@@ -65,11 +67,13 @@ for sub = 1:length(SUBJ)
%rename redundant triggers
EEG = triggerhand(EEG);
%low-pass filter 30 Hz
EEG = pop_firws(EEG, 'fcutoff', cfg.ERD.LP, 'ftype', 'lowpass', 'wtype', 'hamming', 'forder', 508);
f_order = pop_firwsord('hamming', EEG.srate, cfg.ERD.LP(fb)*0.15)
EEG = pop_firws(EEG, 'fcutoff', cfg.ERD.LP(fb), 'ftype', 'lowpass', 'wtype', 'hamming','forder',f_order);
%resample to 100 Hz
EEG = pop_resample(EEG, cfg.ERD.resample);
%high-pass filter 8 Hz
EEG = pop_firws(EEG, 'fcutoff', cfg.ERD.HP, 'ftype', 'highpass', 'wtype', 'hamming', 'forder', 826);
f_order = pop_firwsord('hamming', EEG.srate, cfg.ERD.HP(fb)*0.15)
EEG = pop_firws(EEG, 'fcutoff', cfg.ERD.HP(fb), 'ftype', 'highpass', 'wtype', 'hamming','forder',f_order);
originalEEG = EEG;
......@@ -139,15 +143,17 @@ for sub = 1:length(SUBJ)
m_rERD_bl(sub,:,t) = nanmean(rERD_blc{sub,t}(:,BL_rERD_time_log),2); %average over BL timepoints with all values
%rERD trial
m_rERD_trial_all(sub,:,t) = nanmean(rERD_blc{sub,t}(:,time_ep_ms>0),2); %average over trial with time bigger 0 -> after '1' for all values
auc_ERD = rERD_blc{sub,t}(:,:)< m_rERD_bl(sub,:,t)'; %after onset store logical for every ERD smaller then BL mean
rERD_blc{sub,t}(~auc_ERD) = NaN; % all ERD
m_rERD_trial(sub,:,t) = nanmean(rERD_blc{sub,t}(:,time_ep_ms>0),2); %average over trial with time bigger 0 -> after '1'
m_rERD_trial(sub,:,t) = nanmean(rERD_blc{sub,t}(:,time_ep_ms>0),2); %average over trial with time bigger 0 -> after '1' for values smaller BL mean
if isnan(EMG_all(sub,t)) | emg_check(sub).trials_valid(t) == 0
m_rERD_trial(sub,:,t) = NaN;
m_rERD_bl(sub,:,t) = NaN;
m_rERD_trial_all(sub,:,t) = NaN;
end
end % trial
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -158,9 +164,7 @@ for sub = 1:length(SUBJ)
% extract trial relevant markers // 1 = Start, 0 = Stimulus start, 2 = trial end
%find index in emg_check to substract BP time
idx_bp_s = find(strcmp(SUBJ{sub},{emg_check.ID}));
bp_lat = cfg.EMG.thresh_BP_ms(idx_bp_s); %ES BP time in ms
%{
t = 1;
e = 1;
while e < length(EEG.event)
......@@ -177,13 +181,14 @@ for sub = 1:length(SUBJ)
te = te+1;
end
EEG.event(te).trial = 2;
RT(sub).times(t) = (EEG.event(te).latency-EEG.event(o).latency)*(1000/EEG.srate)-bp_lat; % RT of trial in ms
RT(sub).times(t) = (EEG.event(te).latency-EEG.event(o).latency)*(1000/EEG.srate); % RT of trial in ms
t = t+1;
end
e = e+1;
end
%}
toc
end
......@@ -192,8 +197,9 @@ cfg.ERD.BL_sam = BL_sam;
%% Save data
save([PATHOUT_ERD 'ERD_mue.mat'],'m_rERD_bl','m_rERD_trial','ERD');
save([PATHOUT_ERD 'cfg_mue.mat'],'cfg');
save([PATHOUT_ERD 'RTs_mue.mat'],'RT');
save([PATHOUT_ERD 'ERD_' FB{fb} '.mat'],'m_rERD_trial','m_rERD_trial_all','ERD');
save([PATHOUT_ERD 'cfg_' FB{fb} '.mat'],'cfg');
% save([PATHOUT_ERD 'RTs.mat'],'RT');
end
\ No newline at end of file
Markdown is supported
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