-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFieldTrip3.m
65 lines (58 loc) · 1.73 KB
/
FieldTrip3.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
57
58
59
60
61
62
63
64
65
%% Import FieldTrip toolbox
restoredefaultpath
addpath /home/raquib/Documents/MATLAB/fieldtrip-20191025
addpath /home/raquib/Documents/MATLAB/eeglab2019_0
ft_defaults
%%
fileList = dir("/home/raquib/Desktop/workspaces/mep-classification/data/original/*/*/eeg/SP 110RMT*/clean-prestimulus.set");
%%
for k = 30:length(fileList)
file = fileList(k);
segments = regexp(file.folder, '/', 'split');
subject = segments{8};
session = segments{9};
take = segments{11};
['Transforming EEG of ' subject '/' session '/' take]
filename = [file.folder '/' file.name]
% Preprocessing.
cfg = []
cfg.datafile = filename
cfg.headerfile = filename
cfg.lpfilter = 'yes'
cfg.lpfreq = 100
cfg.lpfiltord = 4
cfg.bsfilter = 'yes'
cfg.bsfreq = [48 52]
cfg.bsfiltord = 4
cfg.reref = 'yes'
cfg.refchannel = 'Cz'
cfg.demean = 'yes'
cfg.baselinewindow = [-1 0]
cfg.detrend = 'yes'
[data] = ft_preprocessing(cfg)
% Inspect visually.
cfg = []
cfg.viewmode = 'vertical'
cfg = ft_databrowser(cfg, data)
% Reject artifact.
% cfg = []
% data = ft_rejectartifact(cfg, data)
%
% % Hjorth transformation.
% neighbours(1).label = 'C3';
% neighbours(1).neighblabel = {'FC1', 'CP1', 'FC5', 'CP5'};
% neighbours(2).label = 'C4';
% neighbours(2).neighblabel = {'FC2', 'CP2', 'FC6', 'CP6'};
% cfg = []
% cfg.method = 'hjorth'
% cfg.elec = data.hdr.elec
% cfg.trials = 'all'
% cfg.feedback = 'gui'
% cfg.neighbours = neighbours
% dt2 = ft_scalpcurrentdensity(cfg, data)
%
% % Save file.
% filename = [file.folder '/07-ft-hjorth-raw.mat']
% ft_write_data(filename, dt2, 'dataformat', 'matlab')
break
end