-
Notifications
You must be signed in to change notification settings - Fork 0
/
TSA_data_transform.m
75 lines (48 loc) · 1.34 KB
/
TSA_data_transform.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
66
67
68
69
70
%
%
% TSA data transform to EEGLAB
%
% Sangtae Ahn ([email protected])
% Brain AI Lab.
%
% first written by 05/13/2021
%
%
close all
clear
clc
%% Load dataset
MainPath = ['D:\OneDrive - University of North Carolina at Chapel Hill\MATLAB\'];
addpath([MainPath 'toolbox\eeglab2019_1']);
addpath([MainPath 'SSSEP']);
eeglab;
pop_editoptions( 'option_savetwofiles', 1,'option_single', 0);
dPath=[MainPath 'SSSEP\Data'];
cd(dPath);
subStruct=dir;
subStruct = subStruct(cellfun(@any,strfind({subStruct.name},'.set')));
nSub = length(subStruct);
%%
for iSub = 1 : nSub
eeglab
load(['sub' num2str(iSub) '_SSSEP']);
data=[eeg.raw_left eeg.raw_right];
EEG.data = data./32; % gain 32
EEG.srate = eeg.srate;
nTrial = eeg.n_trials;
% LEFT
idxLeft = find(eeg.event(1:size(EEG.data,2)/2)==1);
for iIdx = 1 : length(idxLeft)
EEG.event(iIdx).latency= idxLeft (iIdx);
EEG.event(iIdx).type= 'left';
end
% RIGHT
idxRight = idxLeft + size(EEG.data,2)/2;
for iIdx = length(idxRight)+1 : length(idxRight)*2
EEG.event(iIdx).latency= idxRight (iIdx-nTrial);
EEG.event(iIdx).type= 'right';
end
EEG.chanlocs = readlocs('biosemi64.ced');
eeglab redraw;
pop_saveset(EEG,'filepath',dPath,'filename',['SSSEP_sub' num2str(iSub) '.set']);
end