-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from nguyen-td/feature
Feature
- Loading branch information
Showing
15 changed files
with
305 additions
and
126 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
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
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
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
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
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
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,87 @@ | ||
% pop_roi_statsplot() - Generate p-values from FC null distributions and plots them. | ||
% | ||
% Inputs: | ||
% EEG - EEGLAB dataset with ROI activity computed. | ||
% | ||
% Optional inputs: | ||
% 'measure' - [cell] Cell of strings corresponding to methods. | ||
% 'CS' : Cross spectrum | ||
% 'aCOH' : Coherence | ||
% 'cCOH' : (complex-valued) coherency | ||
% 'iCOH' : absolute value of the imaginary part of coherency | ||
% 'wPLI' : Weighted Phase Lag Index | ||
% 'PDC' : Partial directed coherence | ||
% 'TRPDC' : Time-reversed partial directed coherence | ||
% 'DTF' : Directed transfer entropy | ||
% 'TRDTF' : Time-reversed directed transfer entropy | ||
% 'MIM' : Multivariate Interaction Measure for each ROI | ||
% 'MIC' : Maximized Imaginary Coherency for each ROI | ||
% 'freqrange' - [min max] frequency range in Hz. Default is to plot broadband power. | ||
|
||
function EEG = pop_roi_statsplot(EEG, varargin) | ||
|
||
if nargin < 2 | ||
help roi_connstats; | ||
return | ||
end | ||
|
||
if ~isfield(EEG, 'roi') || ~isfield(EEG.roi, 'source_roi_data') | ||
error('Cannot find ROI data - compute ROI data first'); | ||
end | ||
|
||
% decode input parameters | ||
% ----------------------- | ||
g = finputcheck(varargin, { | ||
'measure' 'string' { } ''; | ||
'freqrange' 'real' { } []}, 'pop_roi_statsplot'); | ||
if ischar(g), error(g); end | ||
S = EEG.roi; | ||
|
||
if isempty(g.measure) | ||
error('You must define a measure to plot'); | ||
end | ||
|
||
% extract frequency indices | ||
if ~isempty(g.freqrange) | ||
try | ||
frq_inds = find(S.freqs >= g.freqrange(1) & S.freqs < g.freqrange(2)); | ||
title = sprintf('%1.1f-%1.1f Hz frequency band', g.freqrange(1), g.freqrange(2)); | ||
catch | ||
frq_inds = find(S.freqs == g.freqrange(1)); % if a single frequency is passed | ||
title = sprintf('%1.1f Hz', g.freqrange(1)); | ||
end | ||
else | ||
frq_inds = 1:length(S.freqs); | ||
title = 'broadband'; | ||
end | ||
|
||
% select frequency or frequency band | ||
if length(frq_inds) > 1 | ||
matrix = squeeze(mean(S.(g.measure)(frq_inds, :, :, :))); | ||
else | ||
matrix = squeeze(S.(g.measure)(frq_inds, :, :, :)); | ||
end | ||
|
||
% generate p-values by comparing the true FC (first shuffle) to null distribution | ||
netFC = squeeze(mean(matrix, 2)); | ||
FC_pn = sum(netFC(:, 1) < netFC(:, 2:end), 2)./(size(matrix, 3) - 1); | ||
|
||
% use FDR-correction for multiple comparison's correction | ||
alpha = 0.05; % add this as a parameter? | ||
[p_fdr, ~] = fdr(FC_pn, alpha); | ||
FC_pn(FC_pn > p_fdr) = 1; | ||
|
||
% plot | ||
load cm17; | ||
load cortex; | ||
FC_pn(FC_pn==0) = 1 / (size(netFC, 2) - 1); % 1 / nshuf | ||
data = -log10(FC_pn); | ||
try | ||
allplots_cortex_BS(cortex_highres, data, [min(data) max(data)], cm17a ,'-log(p)', 0.3); | ||
h = textsc(title, 'title'); | ||
set(h, 'fontsize', 20); | ||
catch | ||
warning('There are no "significant" p-values to be plotted. These are the p-values:') | ||
disp(FC_pn) | ||
end | ||
end |
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
Oops, something went wrong.