Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkosciessa committed Mar 3, 2021
1 parent 65afe06 commit 8985e3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions eBOSC_example_empirical.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
cfg.eBOSC.postproc.effSignal= 'PT'; % Power deconvolution on whole signal or signal above power threshold? (default = 'PT')

% general processing settings
cfg.eBOSC.channel = [58:60]; % select posterior channels (default: all)
cfg.eBOSC.channel = [59]; % select posterior channels (default: all)
cfg.eBOSC.trial = []; % select trials (default: all)
cfg.eBOSC.trial_background = []; % select trials for background (default: all)

Expand Down Expand Up @@ -106,17 +106,18 @@
% Mark all periods with episodes falling into the alpha range
alphaDetected(eBOSC.episodes.ColID{idx_alpha(indEp)}(1):eBOSC.episodes.ColID{idx_alpha(indEp)}(end)) = 1;
end; clear idx_alpha;
h = figure('units','normalized','position',[.1 .1 .7 .3]); hold on;
scatter(idx_onset, repmat(100,1,numel(idx_onset)), 75, [.5 .5 .5], 'filled')

h = figure('units','normalized','position',[.1 .1 .3 .2]); hold on;
scatter(idx_onsetTime, repmat(100,1,numel(idx_onset)), 75, [.5 .5 .5], 'filled')
OnsetLine = squeeze(origData);
OnsetLine(idx_onset) = 100; clear idx_onset idx_onsetTime;
plot(OnsetLine, 'Color', [.5 .5 .5]); clear OnsetLine;
[orig]=plot(squeeze(origData), 'k');
[rhythm]=plot(squeeze(origData).*alphaDetected, 'r');
xlim([7.2, 7.9]*10^4)
OnsetLine(idx_onsetTime) = 100; clear idx_onset idx_onsetTime;
plot(cfg.tmp.finalTime,OnsetLine, 'Color', [.5 .5 .5]); clear OnsetLine;
[orig]=plot(cfg.tmp.finalTime,squeeze(origData), 'k');
[rhythm]=plot(cfg.tmp.finalTime,squeeze(origData).*alphaDetected, 'r');
xlim([162, 167])
xlabel('Time (s)'); ylabel('Power [µV]');
legend([orig, rhythm], {'Original signal'; 'Rhythmic signal'}, ...
'orientation', 'horizontal', 'location', 'south'); legend('boxoff')
'orientation', 'horizontal', 'location', 'NorthEast'); legend('boxoff')
set(findall(gcf,'-property','FontSize'),'FontSize',26)

%% optional: delete unnecessary fields prior to saving
Expand Down
2 changes: 1 addition & 1 deletion external/BOSC/BOSC_tf.m
Original file line number Diff line number Diff line change
@@ -1 +1 @@
% This file is part of the Better OSCillation detection (BOSC) library.%% The BOSC library is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.%% The BOSC library is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with Foobar. If not, see <http://www.gnu.org/licenses/>.%% Copyright 2010 Jeremy B. Caplan, Adam M. Hughes, Tara A. Whitten% and Clayton T. Dickson.function [B,T,F]=BOSC_tf(eegsignal,F,Fsample,wavenumber);% [B,T,F]=BOSC_tf(eegsignal,F,Fsample,wavenumber);%% This function computes a continuous wavelet (Morlet) transform on% a segment of EEG signal; this can be used to estimate the% background spectrum (BOSC_bgfit) or to apply the BOSC method to% detect oscillatory episodes in signal of interest (BOSC_detect).%% parameters:% eegsignal - a row vector containing a segment of EEG signal to be% transformed% F - a set of frequencies to sample (Hz)% Fsample - sampling rate of the time-domain signal (Hz)% wavenumber is the size of the wavelet (typically, width=6)% % returns:% B - time-frequency spectrogram: power as a function of frequency% (rows) and time (columns)% T - vector of time values (based on sampling rate, Fsample)st=1./(2*pi*(F/wavenumber));A=1./sqrt(st*sqrt(pi));B = zeros(length(F),length(eegsignal)); % initialize the time-frequency matrixfor f=1:length(F) % loop through sampled frequencies t=-3.6*st(f):(1/Fsample):3.6*st(f); m=A(f)*exp(-t.^2/(2*st(f)^2)).*exp(i*2*pi*F(f).*t); % Morlet wavelet y=conv(eegsignal,m); y=abs(y).^2; B(f,:)=y(ceil(length(m)/2):length(y)-floor(length(m)/2));endT=(1:size(eegsignal,2))/Fsample;
% This file is part of the Better OSCillation detection (BOSC) library.%% The BOSC library is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.%% The BOSC library is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with Foobar. If not, see <http://www.gnu.org/licenses/>.%% Copyright 2010 Jeremy B. Caplan, Adam M. Hughes, Tara A. Whitten% and Clayton T. Dickson.function [B,T,F]=BOSC_tf(eegsignal,F,Fsample,wavenumber)% [B,T,F]=BOSC_tf(eegsignal,F,Fsample,wavenumber);%% This function computes a continuous wavelet (Morlet) transform on% a segment of EEG signal; this can be used to estimate the% background spectrum (BOSC_bgfit) or to apply the BOSC method to% detect oscillatory episodes in signal of interest (BOSC_detect).%% parameters:% eegsignal - a row vector containing a segment of EEG signal to be% transformed% F - a set of frequencies to sample (Hz)% Fsample - sampling rate of the time-domain signal (Hz)% wavenumber is the size of the wavelet (typically, width=6)% % returns:% B - time-frequency spectrogram: power as a function of frequency% (rows) and time (columns)% T - vector of time values (based on sampling rate, Fsample)st=1./(2*pi*(F/wavenumber));A=1./sqrt(st*sqrt(pi));B = zeros(length(F),length(eegsignal)); % initialize the time-frequency matrixfor f=1:length(F) % loop through sampled frequencies t=-3.6*st(f):(1/Fsample):3.6*st(f); m=A(f)*exp(-t.^2/(2*st(f)^2)).*exp(i*2*pi*F(f).*t); % Morlet wavelet y=conv(eegsignal,m); y=abs(y).^2; B(f,:)=y(ceil(length(m)/2):length(y)-floor(length(m)/2));endT=(1:size(eegsignal,2))/Fsample;
Expand Down
5 changes: 3 additions & 2 deletions internal/eBOSC_getThresholds.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@
% find empirical peak in specified range
freqInd1 = find(cfg.eBOSC.F >= cfg.eBOSC.threshold.excludePeak(indExFreq,1), 1, 'first');
freqInd2 = find(cfg.eBOSC.F <= cfg.eBOSC.threshold.excludePeak(indExFreq,2), 1, 'last');
[~, indPos] = max(mean(BG(freqInd1:freqInd2,:),2));
indPos = freqInd1+indPos;
freqidx = freqInd1:freqInd2;
[~, indPos] = max(mean(BG(freqidx,:),2));
indPos = freqidx(indPos);
% approximate wavelet extension in frequency domain
% note: we do not remove the specified range, but the FWHM
% around the empirical peak
Expand Down

0 comments on commit 8985e3b

Please sign in to comment.