-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSRMR2_01_prepro_1_automatic_Rpeakdetection.m
executable file
·56 lines (40 loc) · 1.96 KB
/
SRMR2_01_prepro_1_automatic_Rpeakdetection.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
% Author: Birgit Nierula
%% SpinCCsep_01_prepro_1_automatic_Rpeakdetection
srmr_nr = 2;
ana_dir = '/data/pt_02151/';
cfg_path = [ana_dir 'analysis/manuscript_sep/scripts/cfg_srmr2/']; % here is important info for the analysis
% Add paths
addpath('/data/pt_02068/toolboxes/eeglab14_1_2b/')
addpath(genpath('/data/pt_02068/analysis/manuscript_sep/scripts/functions/'))
% Start EEGLab
eeglab;
close
n_subjects = 24;
for subject = 1:n_subjects
% set path
subject_id = sprintf('sub-%03i', subject);
analysis_path = [ana_dir 'analysis/final/tmp_data/' subject_id '/'];
% define different endings for each block
for condition = 1:5 % 1 = rest, 2 = median digits, 3 = median mixed nerve, 4 = tibial digits, 5 = tibial mixed nerve
[cond_info] = get_conditionInfo(condition, srmr_nr);
cond_name = cond_info.cond_name;
nblocks = cond_info.nblocks;
for iblock = 1:nblocks
%% ===== load data =============
load([cfg_path 'cfg.mat'], 'srate_rpeak')
fname = ['noStimart_sr' num2str(srate_rpeak) '_ecgChan_' cond_name '_' num2str(iblock) '.set'];
cnt = pop_loadset('filename', fname, 'filepath', analysis_path);
%% ===== R-peak detection =============
% run qrs detection plugin from fmrib toolbox
ecg_channel = 1;
cnt_qrs = pop_myfmrib_qrsdetect(cnt, ecg_channel, 'qrs', 'no');
cnt = cnt_qrs; clear cnt_qrs
%% ===== save =============
fname_new = ['noStimart_sr' num2str(srate_rpeak) '_rpeak_autocorrect_ecgChan_' cond_name '_' num2str(iblock) '.set'];
cnt = pop_saveset(cnt, 'filename', fname_new, 'filepath', analysis_path);
% clear unnecessary variables
clearvars -except subjects subject condition cond_name iblock
end
end
end