-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
%% Perform the Hilbert transform on multiple data stored in ALLEEG structure (EEGLAB) | ||
|
||
% Script allows to perform Hilbert transform on multiple EEG signals stored in ALLEEG structure. | ||
% Input: ALLEEG structure with multiple EEG datasets. | ||
% Output: Simple structure HilbertResults that can be used for further | ||
% statistical analysis or calculations. | ||
|
||
%% | ||
%% Step 1: filter the data for a given EEG band (e.g. alpha, theta) | ||
|
||
% User provided data (optional): | ||
% NewNameAdd - specifies a suffix to be added to the name of each dataset to be analyzed | ||
newNameU = 'Theta'; % np. Theta | ||
% lowFreq and highFreq specify the filter bandwidth, e.g. for the theta EEG band it will be 4-7 Hz | ||
lowFreq = 4; %e.g 4 | ||
highFreq = 7; %e.g. 7 | ||
|
||
for ii = 1:numel(ALLEEG) | ||
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 1,'retrieve',ii,'study',0); | ||
oldName = EEG.setname; | ||
newName=sprintf('%s_%s',oldName, newNameU); | ||
EEG = pop_eegfiltnew(EEG, lowFreq, highFreq,[],0,[],1); | ||
[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 1,'setname',newName,'gui','off'); | ||
[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); | ||
end | ||
|
||
%% Step 2: Hilbert transform | ||
|
||
for jj=1:numel(ALLEEG) | ||
elNum = numel(ALLEEG(jj).data(:,1,1)); % liczba elektrod | ||
|
||
for ii=1:elNum | ||
HilbertResults(jj).setname = ALLEEG(jj).setname; | ||
HilbertResults(jj).hilbert(ii,:,:) = abs(hilbert(ALLEEG(jj).data(ii,:,:))); | ||
end | ||
|
||
end | ||
clearvars jj ii elNum | ||
|
||
%% Step 3: additional calculations creating results structure | ||
|
||
% Average of epochs for each electrode | ||
for jj=1:numel(HilbertResults) | ||
HilbertResults(jj).meanEpochs = mean(HilbertResults(jj).hilbert,3); | ||
end | ||
clearvars jj | ||
|
||
% Average of epochs and time points for each electrode | ||
for jj=1:numel(HilbertResults) | ||
HilbertResults(jj).meanEpochsTime = mean(HilbertResults(jj).meanEpochs,2); | ||
end | ||
clearvars jj |