Skip to content

Commit

Permalink
add PAC and TDE to GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyen-td committed Mar 23, 2024
1 parent 859963c commit 9710f35
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
19 changes: 16 additions & 3 deletions pop_roi_connect.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@

rowg = [0.1 0.6 1 0.2];
% uigeom = { 1 1 rowg rowg 1 rowg rowg [0.1 0.6 0.9 0.3] 1 rowg 1 [0.5 1 0.35 0.5] [0.5 1 0.35 0.5] [0.5 1 0.35 0.5] [1] [0.9 1.2 1] };
uigeom = { [1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1] [0.2 1 0.35 0.8] [0.2 1 0.35 0.8] };
uigeom = { [1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1.2 1] [1] [0.2 1 0.35 0.8] [0.2 1 0.35 0.8] [0.2 1 0.35 0.8] [0.2 1 0.35 0.8]};
uilist = { { 'style' 'text' 'string' 'Select connectivity measures' 'fontweight' 'bold' } ...
{ 'style' 'checkbox' 'string' 'Cross-spectrum' 'tag' 'cs' 'value' 1 } {} ...
{'style' 'checkbox' 'string' '(Complex-valued) Coherency' 'tag' 'ccoh' 'value' 0 } ...
Expand All @@ -140,9 +140,13 @@
{ 'style' 'checkbox' 'string' 'Time-reversed DTF' 'tag' 'trdtf' 'value' 0 } ...
{ 'style' 'checkbox' 'string' 'Multivariate Interaction Measure' 'tag' 'mim' 'value' 0 } ...
{ 'style' 'checkbox' 'string' 'Maximized Imaginary Coherency' 'tag' 'mic' 'value' 0 } ...
{ 'style' 'checkbox' 'string' 'Phase-Amplitude Coupling' 'tag' 'pac' 'value' 0 } ...
{ 'style' 'checkbox' 'string' 'Time Delay Estimation' 'tag' 'tde' 'value' 0 } ...
{} ...
{} { 'style' 'text' 'string' 'Autoregressive model order' } { 'style' 'edit' 'string' '20' 'tag' 'morder' } {} ...
{} { 'style' 'text' 'string' 'Bootstrap if any (n)' } { 'style' 'edit' 'string' '' 'tag' 'naccu2' } {} };
{} { 'style' 'text' 'string' 'Bootstrap if any (n)' } { 'style' 'edit' 'string' '' 'tag' 'naccu2' } {} ...
{} { 'style' 'text' 'string' 'Frequency combination in Hz (for PAC) [f1 f2]' } { 'style' 'edit' 'string' '' 'tag' 'fcomb' } {} ...
{} { 'style' 'text' 'string' 'Region selection by index (for TDE) [region1 region2]' } { 'style' 'edit' 'string' '' 'tag' 'tde_regions' } {} };
...
[result,~,~,out] = inputgui('geometry', uigeom, 'uilist', uilist, 'helpcom', 'pophelp(''pop_roi_connect'')', 'title', 'pop_roiconnect - connectivity');
if isempty(result), return, end
Expand All @@ -163,10 +167,19 @@
if out.trdtf, methods = [ methods { 'TRDTF' } ]; end
if out.mim , methods = [ methods { 'MIM' } ]; end
if out.mic, methods = [ methods { 'MIC' } ]; end
if out.pac, methods = [ methods { 'PAC' } ]; end
if out.tde, methods = [ methods { 'TDE' } ]; end
options = { ...
'morder' str2num(out.morder) ...
'naccu' str2num(out.naccu2) ...
'methods' methods };
'methods' methods ...
'tde_regions' eval( [ '[' out.tde_regions ']' ] )};
if ~isempty(eval( [ '[' out.fcomb ']' ] ))
out_fcomb = eval( [ '[' out.fcomb ']' ] );
fcomb.low = out_fcomb(1);
fcomb.high = out_fcomb(2);
options = [options {'fcomb' fcomb}];
end
else
options = varargin;
end
Expand Down
28 changes: 15 additions & 13 deletions pop_roi_connectplot.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
splot(end ).unit = 'aCOH';
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -169,7 +169,7 @@
splot(end ).unit = 'cCOH';
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -180,7 +180,7 @@
splot(end ).unit = 'iCOH';
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -191,7 +191,7 @@
splot(end ).unit = 'GC';
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -202,7 +202,7 @@
splot(end ).unit = 'TRGC'; % not used yet
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -213,7 +213,7 @@
splot(end ).unit = 'MIC'; % not used yet
splot(end ).cortex = cortexFlag;
splot(end ).matrix = -1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -224,7 +224,7 @@
splot(end ).unit = 'MIM'; % not used yet
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -235,18 +235,18 @@
splot(end ).unit = 'PAC'; % not used yet
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

if isfield(EEG.roi, 'PAC')
splot(end+1).label = 'ROI to ROI Phase-amplitude coupling';
splot(end+1).label = 'ROI to ROI Phase-amplitude coupling (antisymmetrized)';
splot(end ).labelshort = 'Phase-amplitude coupling';
splot(end ).acronym = 'PAC_anti'; % PAC based on antisymmetrized bicoherence
splot(end ).unit = 'PAC'; % not used yet
splot(end ).cortex = cortexFlag;
splot(end ).matrix = 1;
splot(end ).psd = 0;
splot(end ).psd = -1;
splot(end ).plot3d = plot3dFlag;
end

Expand All @@ -262,7 +262,7 @@
end

if isfield(EEG.roi, 'TDE')
splot(end+1).label = 'ROI to ROI Time-delay estimation';
splot(end+1).label = 'ROI to ROI Time-delay estimation (antisymmetrized)';
splot(end ).labelshort = 'Time-delay estimation';
splot(end ).acronym = 'TDE_anti'; % TDE based on antisymmetrized bispectrum
splot(end ).unit = 'TDE'; % not used yet
Expand Down Expand Up @@ -508,6 +508,7 @@
error('PAC (original bicoherence) cannot be plotted, field is missing.')
end
cortexPlot = mean(matrix, 2);
titleStr = sprintf('f1 = %1.1f Hz, f2 = %1.1f Hz', S.PAC.fcomb.low, S.PAC.fcomb.high);

case {'pac_anti'}
if isfield(S.PAC, 'b_anti_norm')
Expand All @@ -518,6 +519,7 @@
error('PAC (antisymmetrized bicoherence) cannot be plotted, field is missing.')
end
cortexPlot = mean(matrix, 2);
titleStr = sprintf('f1 = %1.1f Hz, f2 = %1.1f Hz', S.PAC.fcomb.low, S.PAC.fcomb.high);

case {'tde' 'tde_anti'}
if strcmpi(g.measure, 'tde')
Expand Down Expand Up @@ -970,8 +972,8 @@ function plot_tde(T, shift, region_X, region_Y, method)
[~, peak_idx] = max(T);
est_delay = shift(peak_idx); % in Hz

figure; plot(shift, T, 'LineWidth', 1)
xline(est_delay, '--r')
figure; plot(shift, T, 'black', 'LineWidth', 1)
xline(est_delay, '--r', 'LineWidth', 1)
xlabel('Time (s)')
ylabel('a.u.')
h = title(sprintf('%s -> %s TDE | Method %d', region_X, region_Y, method));
Expand Down
1 change: 1 addition & 0 deletions roi_pac.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
[b_orig, b_anti, b_orig_norm, b_anti_norm] = data2bs_pac(data, params);

% options which bispectral tensors to store
EEG.roi.PAC.fcomb = fcomb;
switch bs_outopts
case 2
EEG.roi.PAC.b_orig = b_orig;
Expand Down

0 comments on commit 9710f35

Please sign in to comment.