-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfp_2chan_sim_baseline.m
54 lines (40 loc) · 1.31 KB
/
fp_2chan_sim_baseline.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function fp_2chan_sim_baseline(seed,iit)
% Two-channel baseline simulation (for Supplementary Figure S1 in Pellegrini 2023)
%
% Copyright (c) 2023 Franziska Pellegrini and Stefan Haufe
rng('default')
rng(seed)
DIROUT = './';
logname = num2str(iit);
%% Parameters
N = 120000; % total number of samples
nchan= 2; %two channels
fs = 200; %sampling frequency
n_trials_s = 60; % number of trials for MI-based methods
n_shuffles = 1000; % number of shuffles
% interacting frequency bands for simulating signal
low = [9 11]; %low freq band
high = [58 62]; % high freq band
filt.low = low;
filt.high = high;
%SNR
snr_v = [0 0.1 0.2 0.3 0.4];
%% Signal generation
%generate univariate PAC signal
[~, ~, pac_0] = syn_sig(N,fs, low, high);
%white noise
channels_noise1 = randn(N,1);
channels_noise = [channels_noise1 channels_noise1];
channels_noise = channels_noise./ norm(channels_noise(:),'fro');
for isnr = 1:length(snr_v)
isnr
%Calculate PAC within single signal
X_3 = [pac_0 pac_0];
X_3 = X_3./norm(X_3(:),'fro');
X_3 = snr_v(isnr)*X_3 + (1-snr_v(isnr))*channels_noise;
X_3 = reshape(X_3',nchan,[],n_trials_s);
%estimate within-channel PAC
[pac{1,isnr}, p{1,isnr}] = fp_get_all_pac_baseline(X_3, fs, filt, n_shuffles);
end
%% Save
save([DIROUT 'pvals_' logname '.mat'],'p','-v7.3')