-
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
7 changed files
with
412 additions
and
289 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,19 @@ | ||
function mean_engage_across_channels = Arousal(n_epoch, stim_spectrum,baseline_spectrum) | ||
|
||
clear arousal_ratio; | ||
for epoch = 1:n_epoch | ||
for seg = 1:size(stim_spectrum{epoch,1},2) | ||
alpha_ratio=0; | ||
beta_ratio=0; | ||
for ch = [3 12] %calculate Arousal level at channels F3 and F4 | ||
% power ratio of signal with respect to the baseline | ||
alpha_ratio = alpha_ratio+(mean(baseline_spectrum{epoch,1}(ch,4:6))-mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6)))/mean(baseline_spectrum{epoch,1}(ch,4:6)); % 8~12Hz | ||
beta_ratio = beta_ratio+(mean(baseline_spectrum{epoch,1}(ch,7:15))-mean(stim_spectrum{epoch,1}{ch,seg}(1,7:15)))/mean(baseline_spectrum{epoch,1}(ch,7:15)); % 14~30Hz | ||
end | ||
|
||
arousal_ratio(epoch,seg) = beta_ratio/alpha_ratio; | ||
end | ||
end | ||
|
||
% Average the arousal level across epochs and segments, excluding NaNs that may occur. | ||
mean_engage_across_channels = mean2(arousal_ratio(~isnan(arousal_ratio))); |
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 |
---|---|---|
@@ -1,13 +1,28 @@ | ||
function FAA = FAA_calculation(n_epoch, stim_spectrum,baseline_spectrum) | ||
|
||
clear alpha_ratio | ||
for ch = [2 3 4 11 12 13] %calculate alpha power at F7, F3, FC5, FC6, F4, F8 | ||
for epoch = 1:n_epoch | ||
for seg = 1:size(stim_spectrum{epoch,1},2) | ||
% alpha power ratio of signal with respect to the baseline | ||
alpha_ratio{ch}(epoch,seg) = mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6))/mean(baseline_spectrum{epoch,1}(ch,4:6)); | ||
end | ||
end | ||
end | ||
|
||
FAA = log((mean(alpha_ratio{2},1)+mean(alpha_ratio{3},1)+mean(alpha_ratio{4},1))/3) - log((mean(alpha_ratio{11},1)+mean(alpha_ratio{12},1)+mean(alpha_ratio{13},1))/3); | ||
% function FAA = FAA_calculation(n_epoch, stim_spectrum,baseline_spectrum) | ||
% | ||
% clear alpha_ratio | ||
% for ch = [2 3 4 11 12 13] %calculate alpha power at F7, F3, FC5, FC6, F4, F8 | ||
% for epoch = 1:n_epoch | ||
% for seg = 1:size(stim_spectrum{epoch,1},2) | ||
% % alpha power ratio of signal with respect to the baseline | ||
% alpha_ratio{ch}(epoch,seg) = mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6))/mean(baseline_spectrum{epoch,1}(ch,4:6)); | ||
% end | ||
% end | ||
% end | ||
% | ||
% FAA = log((mean(alpha_ratio{2},1)+mean(alpha_ratio{3},1)+mean(alpha_ratio{4},1))/3) - log((mean(alpha_ratio{11},1)+mean(alpha_ratio{12},1)+mean(alpha_ratio{13},1))/3); | ||
|
||
% Modified on June 10, 2018 by Jihyun Lee | ||
function FAA = FAA_calculation(n_epoch, stim_spectrum,baseline_spectrum) | ||
|
||
clear alpha_ratio | ||
for ch = [2 3 4 11 12 13] %calculate alpha power at F7, F3, FC5, FC6, F4, F8 | ||
for epoch = 1:n_epoch | ||
for seg = 1:size(stim_spectrum{epoch,1},2) | ||
% alpha power ratio of signal with respect to the baseline | ||
alpha_ratio{ch}(epoch,seg) = (mean(baseline_spectrum{epoch,1}(ch,4:6))-mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6)))/mean(baseline_spectrum{epoch,1}(ch,4:6)); | ||
end | ||
end | ||
end | ||
|
||
FAA = (mean(alpha_ratio{2},1)+mean(alpha_ratio{3},1)+mean(alpha_ratio{4},1))./(mean(alpha_ratio{11},1)+mean(alpha_ratio{12},1)+mean(alpha_ratio{13},1)); |
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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
function mean_alpha_across_channels = alpha_power(n_epoch, stim_spectrum,baseline_spectrum,selected_ch_id) | ||
|
||
clear alpha_ratio | ||
for ch = selected_ch_id' %calculate alpha power at selected channels | ||
for epoch = 1:n_epoch | ||
for seg = 1:size(stim_spectrum{epoch,1},2) | ||
% alpha power ratio of signal with respect to the baseline | ||
alpha_ratio{ch}(epoch,seg) = mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6))/mean(baseline_spectrum{epoch,1}(ch,4:6)); | ||
end | ||
end | ||
end | ||
|
||
% Average the alpha power ratio across the selected channels | ||
sum_alpha_ratio=0; | ||
for ch = selected_ch_id' | ||
if sum(sum(isnan(alpha_ratio{ch}))) || sum(sum(isinf(alpha_ratio{ch}))) | ||
% skip epochs which has NaN or inf | ||
continue | ||
end | ||
|
||
sum_alpha_ratio = sum_alpha_ratio + alpha_ratio{ch}; | ||
end | ||
|
||
function mean_alpha_across_channels = alpha_power(n_epoch, stim_spectrum,baseline_spectrum,selected_ch_id) | ||
|
||
clear alpha_ratio | ||
for ch = selected_ch_id' %calculate alpha power at selected channels | ||
for epoch = 1:n_epoch | ||
for seg = 1:size(stim_spectrum{epoch,1},2) | ||
% alpha power ratio of signal with respect to the baseline | ||
alpha_ratio{ch}(epoch,seg) = (mean(baseline_spectrum{epoch,1}(ch,4:6))-mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6)))/mean(baseline_spectrum{epoch,1}(ch,4:6)); | ||
end | ||
end | ||
end | ||
|
||
% Average the alpha power ratio across the selected channels | ||
sum_alpha_ratio=0; | ||
for ch = selected_ch_id' | ||
if sum(sum(isnan(alpha_ratio{ch}))) || sum(sum(isinf(alpha_ratio{ch}))) | ||
% skip epochs which have NaN or inf | ||
continue | ||
end | ||
|
||
sum_alpha_ratio = sum_alpha_ratio + alpha_ratio{ch}; | ||
end | ||
|
||
mean_alpha_across_channels = sum_alpha_ratio/size(selected_ch_id,1); |
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,20 @@ | ||
function mean_alpha_across_epochs = alpha_power_all(n_epoch, stim_spectrum,baseline_spectrum,selected_ch_id) | ||
|
||
clear alpha_ratio | ||
for ch = selected_ch_id' %calculate alpha power at selected channels | ||
for epoch = 1:n_epoch | ||
for seg = 1:size(stim_spectrum{epoch,1},2) | ||
% alpha power ratio of signal with respect to the baseline | ||
alpha_ratio{ch}(epoch,seg) = (mean(baseline_spectrum{epoch,1}(ch,4:6))-mean(stim_spectrum{epoch,1}{ch,seg}(1,4:6)))/mean(baseline_spectrum{epoch,1}(ch,4:6)); | ||
end | ||
end | ||
end | ||
|
||
% Average the alpha power ratio across epochs | ||
ch_count=1; | ||
for ch = selected_ch_id' | ||
alpha_across_epoch(ch_count) = mean(nanmean(alpha_ratio{ch},1)); | ||
ch_count = ch_count + 1; | ||
end | ||
|
||
mean_alpha_across_epochs = alpha_across_epoch; |
Oops, something went wrong.