Alpha frequency shapes perceptual sensitivity by modulating optimal phase likelihood.
The 4 matches · 1 of them tie a paragraph to a whole file, not to given lines: a weak match, whose lines are not tinted
- [1] § Methods › Extract instantaneous alpha frequency and phase ↔ SCRIPT/restingIAF_natcomm.m, the whole file · a weak match · score 0.64 · alpha band, spectral, derivative, spectopo, filtered, noise
- [2] § Methods › Extract instantaneous alpha frequency and phase ↔ SCRIPT/Script_NC.m, lines 1004–1130 · score 0.64 · single trial IAF, instantaneous frequency, IAF accuracy, EEGLAB, FFT, pre
- [3] § Methods › Assessing the specificity of the relationship between IAF and perceptual accuracy relative to alpha power ↔ SCRIPT/Script_NC.m, lines 780–913 · score 0.62 · alpha power, trial fluctuation, perceptual accuracy, amplitude, EEG, incorrect
- [4] § Methods › IAF single-trial regression: accuracy ↔ SCRIPT/Script_NC.m, lines 1004–1130 · score 0.54 · single trial IAF, instantaneous frequency, row, FFT, pre, stimulus
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
MATLAB · 1,130 lines · 44 KB · no license · 3 matches
- %% ------------------------- EXTRACT PEAK & ELECTRODES ---------------------
- clc; clear; close all
- eegfolder = ''%path
- cd(EEGFOLDER);
- dEEG = dir(EEGFOLDER);
- EEG_files = struct2cell(dEEG)';
- EEG_files = EEG_files(3:end,1);
- start_from = 2;
- subji = start_from:2:length(EEG_files);
- dataEEG = cell(1, numel(subji));
- cd(EEGFOLDER);
- for p = 1:numel(subji)
- idxEEG = subji(p);
- filename = char(EEG_files{idxEEG});
- EEG = pop_loadset('filename', filename);
- EEG = eeg_checkset(EEG);
- dataEEG{p} = EEG;
- end
- electrodes_peak = cell(1, numel(subji));
- peak = nan(1, numel(subji));
- for soggetto = 1:numel(subji)
- EEG = dataEEG{soggetto};
- EEG.data = diff(EEG.data, 1, 2);
- data = double(EEG.data);
- chosedelectrodes = [18,49,50,17,48];
- time2anal = [-800 -100];
- time2idx = dsearchn(EEG.times', time2anal');
- datawin = data(chosedelectrodes, time2idx(1):time2idx(2), :);
- [a,b] = spectopo(datawin, 0, EEG.srate, 'nfft', EEG.srate*100, 'plot', 'off', 'verbose', 'off');
- alphalim = [7 13];
- alphaidx = dsearchn(b, alphalim');
- alphapow = mean(a(:, alphaidx(1):alphaidx(2)), 2);
- [~, which_elec] = sort(alphapow, 'descend');
- electrodes_peak{soggetto} = EEG.chanlocs(chosedelectrodes(which_elec(1))).labels;
- data1 = squeeze(EEG.data(chosedelectrodes(which_elec(1)), :, :));
- data1 = reshape(data1, 1, size(data1,1), size(data1,2));
- cmin=1; fRange=[1 40]; w=[7 13]; Fw=11; k=5; Fs=EEG.srate;
- data_colcoran = reshape(data1(:, time2idx(1):time2idx(2), :), 1, []);
- [~, colcalpha] = restingIAF(data_colcoran, 1, cmin, fRange, Fs, w, Fw, k);
- peak(soggetto) = colcalpha.peaks;
- for elec = 2:length(chosedelectrodes)
- if isnan(peak(soggetto))
- electrodes_peak{soggetto} = EEG.chanlocs(chosedelectrodes(which_elec(elec))).labels;
- data_alt = squeeze(EEG.data(chosedelectrodes(which_elec(elec)), time2idx(1):time2idx(2), :));
- data_alt = reshape(data_alt, 1, size(data_alt,1), size(data_alt,2));
- data_colcoran = reshape(data_alt, 1, []);
- [~, colcalpha] = restingIAF(data_colcoran, 1, cmin, fRange, Fs, w, Fw, k);
- peak(soggetto) = colcalpha.peaks;
- end
- end
- end
- %% --------------------- EXTRACT INST_IAF --------------------
- clc; clear; close all
- load('AllSubjects.mat')
- eegfolder = ''%path
- cd(EEGFOLDER);
- dEEG = dir(EEGFOLDER);
- EEG_files = struct2cell(dEEG)';
- EEG_files = EEG_files(3:end,1);
- start_from = 2;
- subji = start_from:2:length(EEG_files);
- dataEEG = cell(1, numel(subji));
- cd(EEGFOLDER);
- for p = 1:numel(subji)
- idxEEG = subji(p);
- filename = char(EEG_files{idxEEG});
- EEG = pop_loadset('filename', filename);
- EEG = eeg_checkset(EEG);
- dataEEG{p} = EEG;
- end
- electrodes_to_analyze_all = readcell('electrodes_to_analyze.xlsx');
- peak = readmatrix('peak_to_analyze.xlsx');
- for subject = 1:numel(databehx)
- EEG = dataEEG{subject};
- EEG.data = diff(EEG.data, 1, 2);
- electrodes_to_analyze = find(strcmpi({EEG.chanlocs.labels}, electrodes_to_analyze_all{subject}));
- alpha_lim = [peak(subject)-2, peak(subject)+2];
- [inst_freq, inst_ph] = instantaneous_NatComm(EEG.data(electrodes_to_analyze,:,:), EEG.srate, alpha_lim);
- inst_freq = squeeze(inst_freq);
- inst_ph = squeeze(inst_ph);
- end
- %% Pre-stimulus IAF is linked to variations in perceptual sensitivity: BIN analysis
- clc,clear
- load('IAF_allSubjects.mat');
- nS = numel(datax);
- d = zeros(nS,2);
- c = zeros(nS,2);
- accuracy = zeros(nS,2);
- iaf_mean_terciles = zeros(nS,2);
- for s = 1:nS
- data = datax{s};
- data(:,4) = mean(data(:,4:end), 2);
- data(:,5:end) = [];
- [~, h] = sort(data(:,4));
- data = data(h,:);
- N = size(data,1);
- iLow = 1:ceil(N/3);
- iHigh = (ceil(2*N/3)+1):N;
- % ========== FIRST TERCILE ===============
- sub = data(iLow,:);
- iaf_mean_terciles(s,1) = mean(sub(:,4));
- stim_pres = sub(sub(:,1)==1,:);
- stim_abs = sub(sub(:,1)==0,:);
- nPres = size(stim_pres,1);
- nAbs = size(stim_abs,1);
- hit = sum(stim_pres(:,1)==stim_pres(:,2)) / nPres;
- fa = sum(stim_abs(:,1)~=stim_abs(:,2)) / nAbs;
- if hit == 0, hit = 0.5/nPres; elseif hit == 1, hit = (nPres-0.5)/nPres; end
- if fa == 0, fa = 0.5/nAbs; elseif fa == 1, fa = (nAbs-0.5)/nAbs; end
- d(s,1) = norminv(hit) - norminv(fa);
- c(s,1) = -(norminv(hit) + norminv(fa)) / 2;
- accuracy(s,1) = mean(sub(:,1) == sub(:,2));
- % ========== THIRD TERCILE ==============
- sub = data(iHigh,:);
- iaf_mean_terciles(s,2) = mean(sub(:,4));
- stim_pres = sub(sub(:,1)==1,:);
- stim_abs = sub(sub(:,1)==0,:);
- nPres = size(stim_pres,1);
- nAbs = size(stim_abs,1);
- hit = sum(stim_pres(:,1)==stim_pres(:,2)) / nPres;
- fa = sum(stim_abs(:,1)~=stim_abs(:,2)) / nAbs;
- if hit == 0, hit = 0.5/nPres; elseif hit == 1, hit = (nPres-0.5)/nPres; end
- if fa == 0, fa = 0.5/nAbs; elseif fa == 1, fa = (nAbs-0.5)/nAbs; end
- d(s,2) = norminv(hit) - norminv(fa);
- c(s,2) = -(norminv(hit) + norminv(fa)) / 2;
- accuracy(s,2) = mean(sub(:,1) == sub(:,2));
- end
- %% Time-resolved binning analysis revealed that the IAF effect on sensitivity
- %% is broadly extended over the pre-stimulus period: Bin analysis timeresolved
- clc,clear
- load('IAF_allSubjects.mat');
- nperms = 1000;
- rng('Shuffle')
- ntpns = size(datax{1},2) - 3;
- nS = numel(datax);
- iaf_mean_timeresolved = zeros(nS,ntpns,2);
- d = zeros(nS,ntpns,2);
- c = zeros(nS,ntpns,2);
- accuracy = zeros(nS,ntpns,2);
- for timepointi = 1:ntpns
- for participant = 1:nS
- data = datax{participant};
- data(:,4) = data(:, 3+timepointi);
- data(:,5:end)= [];
- [~, h] = sort(data(:,4));
- data_real = data(h,:);
- N = size(data_real,1);
- iL = 1:ceil(N/3);
- data_low_alpha = data_real(iL,:);
- stim_pres = data_low_alpha(data_low_alpha(:,1)==1,:);
- hit = (sum(stim_pres(:,1) == stim_pres(:,2)))/(length(stim_pres));
- if hit == 1, hit = (length(stim_pres) - 0.5)/length(stim_pres); end
- if hit == 0, hit = 0.5/length(stim_pres); end
- stim_abs = data_low_alpha(data_low_alpha(:,1)==0,:);
- fa = (sum(stim_abs(:,1) ~= stim_abs(:,2)))/(length(stim_abs));
- if fa == 0, fa = 0.5/length(stim_abs); end
- d(participant,timepointi,1) = norminv(hit) - norminv(fa);
- c(participant,timepointi,1) = -(norminv(hit) + norminv(fa))/2;
- accuracy(participant,timepointi,1) = sum(data_low_alpha(:,1)==data_low_alpha(:,2))/length(data_low_alpha);
- iH = (ceil(2*N/3)+1):N;
- data_hig_alpha = data_real(iH,:);
- stim_pres = data_hig_alpha(data_hig_alpha(:,1)==1,:);
- hit = (sum(stim_pres(:,1) == stim_pres(:,2)))/(length(stim_pres));
- if hit == 1, hit = (length(stim_pres) - 0.5)/length(stim_pres); end
- if hit == 0, hit = 0.5/length(stim_pres); end
- stim_abs = data_hig_alpha(data_hig_alpha(:,1)==0,:);
- fa = (sum(stim_abs(:,1) ~= stim_abs(:,2)))/(length(stim_abs));
- if fa == 0, fa = 0.5/length(stim_abs); end
- d(participant,timepointi,2) = norminv(hit) - norminv(fa);
- c(participant,timepointi,2) = -(norminv(hit) + norminv(fa))/2;
- accuracy(participant,timepointi,2) = sum(data_hig_alpha(:,1)==data_hig_alpha(:,2))/length(data_hig_alpha);
- end
- end
- d = d; % d, accuracy, c
- d_t_t_lowalpha = mean(d(:,:,1));
- d_t_t_highalpha = mean(d(:,:,2));
- load('timeperiod_iaf.mat')
- x = timeperiod;
- sig_real = zeros(ntpns,1);
- t_real = zeros(ntpns,1);
- for timi = 1:ntpns
- lowalpha = d(:,timi,1);
- highalpha = d(:,timi,2);
- [sig_real(timi),~,~,e] = ttest(lowalpha,highalpha);
- t_real(timi) = e.tstat;
- end
- t_real(~sig_real) = 0;
- islands = bwconncomp(t_real);
- clustsizes = islands.PixelIdxList;
- sum_t = zeros(length(clustsizes),1);
- for clusti = 1:length(clustsizes)
- ii = clustsizes{clusti};
- sum_t(clusti) = sum(abs(t_real(ii(1):ii(end))));
- end
- sig_fake = zeros(ntpns,nperms);
- t_fake = zeros(ntpns,nperms);
- max_cluster_sizes = zeros(nperms,1);
- for perm = 1:nperms
- lowalpha = d(:,:,1);
- highalpha = d(:,:,2);
- randorder = randperm(nS);
- randorder_1 = rem(randorder,2);
- lowalpha_fake = zeros(size(lowalpha));
- highalpha_fake = zeros(size(highalpha));
- for part = 1:nS
- if randorder_1(part)==1
- lowalpha_fake(part,:) = lowalpha(part,:);
- highalpha_fake(part,:) = highalpha(part,:);
- else
- lowalpha_fake(part,:) = highalpha(part,:);
- highalpha_fake(part,:) = lowalpha(part,:);
- end
- end
- for timi = 1:ntpns
- [sig_fake(timi,perm),~,~,e] = ttest(lowalpha_fake(:,timi),highalpha_fake(:,timi));
- t_fake(timi,perm) = e.tstat;
- end
- t_fake(~sig_fake(:,perm),perm) = 0;
- islands = bwconncomp(t_fake(:,perm));
- tempclustsizes = islands.PixelIdxList;
- sum_t_fake = zeros(max([length(tempclustsizes),1]),1);
- if ~isempty(tempclustsizes)
- for clusti = 1:length(tempclustsizes)
- ii = tempclustsizes{clusti};
- sum_t_fake(clusti) = sum(abs(t_fake(ii(1):ii(end),perm)));
- end
- end
- max_cluster_sizes(perm) = max(sum_t_fake);
- end
- p_value_cluster = zeros(length(clustsizes),1);
- S = sort(max_cluster_sizes);
- for clusti = 1:length(clustsizes)
- p_value_cluster(clusti) = (nperms - dsearchn(S,sum_t(clusti)')) / nperms;
- end
- %% IAF is higher in correct vs. incorrect trials.
- clc,clear
- load('IAF_allSubjects.mat');
- nS = length(datax);
- iaf = zeros(nS,2);
- for participant = 1:nS
- data = datax{participant};
- data(:,4) = mean(data(:,4:end),2);
- data(:,5:end) = [];
- accuracy = (data(:,1) == data(:,2));
- iaf_acc = data(accuracy ,4);
- iaf_inc = data(~accuracy,4);
- iaf(participant,1) = mean(iaf_acc);
- iaf(participant,2) = mean(iaf_inc);
- end
- %% Trial-by-trial fluctuations in IAF predict the accuracy of perceptual report.
- clc,clear
- load('IAF_allSubjects.mat');
- rng shuffle
- nperms = 2000;
- nS = length(datax);
- b_perms = zeros(nperms,1);
- b_z = zeros(nS,1);
- b = zeros(nS,1);
- for participant = 1:nS
- participant
- data = datax{participant};
- data(:,4) = mean(data(:,4:end),2);
- data(:,5:end) = [];
- data(:,4) = zscore(data(:,4));
- accuracy = (data(:,1) == data(:,2));
- X = [ones(length(data),1), data(:,4)];
- t = (X'*X)\(X'*accuracy);
- b(participant) = t(2);
- datat = data;
- for permi = 1:nperms
- datat(:,4) = Shuffle(data(:,4));
- Xp = [ones(length(data),1), datat(:,4)];
- tp = (Xp'*Xp)\(Xp'*accuracy);
- b_perms(permi) = tp(2);
- end
- b_z(participant) = (b(participant) - mean(b_perms)) / std(b_perms);
- end
- %% Alpha phase effects on perceptual sensitivity are moderated by IAF.
- clc,clear
- rng('Shuffle')
- load('timeperiod_phase.mat');
- NT = numel(timeperiod);
- which_group = 'below'; % 'below' | 'above'
- switch which_group
- case 'below'
- load('PHASE_below.mat');
- datax = data_phase_below;
- group = 1:numel(datax);
- case 'above'
- load('PHASE_above.mat');
- datax = data_phase_above;
- group = 1:numel(datax);
- end
- acc_phase = zeros(length(group), NT, 2);
- for participant = 1:length(group)
- X = datax{group(participant) };
- acc = (X(:,1) == X(:,2));
- for t = 1:NT
- phase_degree = rad2deg( X(:, t+3) );
- numBins = 2;
- binEdges = linspace(-180, 180, numBins+1);
- binIndices = zeros(size(phase_degree));
- for i = 1:numBins
- binIndices( phase_degree >= binEdges(i) & phase_degree <= binEdges(i+1) ) = i;
- end
- peak = (binIndices==2);
- trough = (binIndices==1);
- acc_phase(participant,t,1) = sum(acc(peak)) / sum(peak);
- acc_phase(participant,t,2) = sum(acc(trough)) / sum(trough);
- end
- end
- sign = zeros(NT,1);
- tval = zeros(NT,1);
- for t = 1:NT
- [sign(t),~,~,st] = ttest(acc_phase(:,t,1), acc_phase(:,t,2));
- tval(t) = st.tstat;
- end
- tval(sign<1) = 0;
- CC = bwconncomp(tval);
- clustsizes = CC.PixelIdxList;
- sum_t = zeros(numel(clustsizes),1);
- for c = 1:numel(clustsizes)
- idx = clustsizes{c};
- sum_t(c) = sum(abs(tval(idx(1):idx(end))));
- end
- nperms = 1000;
- sig_fake = zeros(NT,nperms);
- t_fake = zeros(NT,nperms);
- max_cluster_sizes = zeros(nperms,1);
- for perm = 1:nperms
- lowalpha = acc_phase(:,:,1);
- highalpha = acc_phase(:,:,2);
- randorder = randperm(size(acc_phase,1));
- randorder_1 = rem(randorder,2);
- lowalpha_fake = zeros(size(lowalpha));
- highalpha_fake = zeros(size(highalpha));
- for s = 1:size(acc_phase,1)
- if randorder_1(s)==1
- lowalpha_fake(s,:) = lowalpha(s,:);
- highalpha_fake(s,:) = highalpha(s,:);
- else
- lowalpha_fake(s,:) = highalpha(s,:);
- highalpha_fake(s,:) = lowalpha(s,:);
- end
- end
- for t = 1:NT
- [sig_fake(t,perm),~,~,e] = ttest(lowalpha_fake(:,t), highalpha_fake(:,t));
- t_fake(t,perm) = e.tstat;
- end
- t_fake(~sig_fake(:,perm),perm) = 0;
- CCp = bwconncomp(t_fake(:,perm));
- tmpMass = zeros(max([CCp.NumObjects,1]),1);
- if CCp.NumObjects>0
- for c = 1:CCp.NumObjects
- idx = CCp.PixelIdxList{c};
- tmpMass(c) = sum(abs(t_fake(idx(1):idx(end),perm)));
- end
- else
- tmpMass(1) = 0;
- end
- max_cluster_sizes(perm) = max(tmpMass);
- end
- p_value_cluster = zeros(numel(clustsizes),1);
- mx = sort(max_cluster_sizes);
- for c = 1:numel(clustsizes)
- p_value_cluster(c) = (nperms - dsearchn(mx, sum_t(c))) / nperms;
- end
- %% Trial-by-trial fluctuations in alpha phase predict perceptual sensitivity only in lower IAF trials.
- clc,clear
- rng shuffle
- load('PHASE_all.mat');
- load('IAF_allSubjects.mat')
- load('timeperiod_phase.mat')
- phase2analyse = 5;
- phaseidx = dsearchn(timeperiod', phase2analyse');
- phaseidx = unique(phaseidx);
- nS = numel(datax);
- iaf_coeff = zeros(nS,1);
- pha_coeff = zeros(nS,1);
- iaf_pha_c = zeros(nS,1);
- for participant = 1:nS
- X_iaf = datax{participant};
- accuracy = (X_iaf(:,1) == X_iaf(:,2)); % 0/1
- iaf = zscore( mean(X_iaf(:,4:end),2) );
- X_phase = data_phase_all{participant};
- phase = X_phase(:, phaseidx(1)+3);
- phase_degree = rad2deg(phase);
- numBins = 2;
- binEdges = linspace(-180, 180, numBins + 1);
- binIndices = zeros(size(phase_degree));
- for i = 1:numBins
- binIndices( phase_degree >= binEdges(i) & phase_degree <= binEdges(i+1) ) = i;
- end
- peak = (binIndices == 2);
- X = [ones(size(X_phase,1),1), iaf, double(peak), iaf .* double(peak)];
- t = (X'*X)\(X'*accuracy);
- iaf_coeff(participant) = t(2);
- pha_coeff(participant) = t(3);
- iaf_pha_c(participant) = t(4);
- iaf_coeff_p = zeros(1000,1);
- pha_coeff_p = zeros(1000,1);
- iaf_pha_p = zeros(1000,1);
- for permi = 1:1000
- acc_perm = Shuffle(accuracy);
- tperm = (X'*X)\(X'*acc_perm);
- iaf_coeff_p(permi) = tperm(2);
- pha_coeff_p(permi) = tperm(3);
- iaf_pha_p(permi) = tperm(4);
- end
- iaf_coeff(participant) = (iaf_coeff(participant) - mean(iaf_coeff_p)) ./ std(iaf_coeff_p);
- pha_coeff(participant) = (pha_coeff(participant) - mean(pha_coeff_p)) ./ std(pha_coeff_p);
- iaf_pha_c(participant) = (iaf_pha_c(participant) - mean(iaf_pha_p)) ./ std(iaf_pha_p);
- end
- %% Correct vs. incorrect decisions are associated with a different phase angle only in the low IAF group
- clc,clear
- rng Shuffle
- load('timeperiod_phase.mat')
- T = numel(timeperiod);
- which_group = 'below'; % 'below' | 'above'
- switch which_group
- case 'below'
- load('PHASE_below.mat');
- datax = data_phase_below;
- group = 1:numel(datax);
- case 'above'
- load('PHASE_above.mat');
- datax = data_phase_above;
- group = 1:numel(datax);
- end
- circolar_mean = zeros(numel(datax), T, 2);
- for p = 1:numel(datax)
- data = datax{p};
- accuracy = (data(:,1) == data(:,2));
- for t = 1:T
- circolar_mean(p,t,1) = circ_mean(data( accuracy==1, t+3)); % Correct
- circolar_mean(p,t,2) = circ_mean(data( accuracy==0, t+3)); % Incorrect
- end
- end
- p_obs = zeros(T,1);
- F_obs = zeros(T,1);
- for t = 1:T
- [p_obs(t), tbl] = circ_wwtest(circolar_mean(:,t,1), circolar_mean(:,t,2));
- F_obs(t) = tbl{2,5};
- end
- is_sig = (p_obs < 0.05);
- CC = bwconncomp(is_sig);
- clusters_obs = CC.PixelIdxList;
- mass_obs = zeros(numel(clusters_obs),1);
- for c = 1:numel(clusters_obs)
- idx = clusters_obs{c};
- mass_obs(c) = sum(F_obs(idx));
- end
- nperms = 1000;
- T = size(circolar_mean,2);
- nSubj = size(circolar_mean,1);
- max_mass = zeros(nperms,1);
- for perm = 1:nperms
- cm_tmp = circolar_mean;
- swap_mask = false(nSubj,1);
- swap_mask(randperm(nSubj, floor(nSubj/2))) = true;
- tmpMass = cm_tmp(swap_mask,:,1);
- cm_tmp(swap_mask,:,1) = cm_tmp(swap_mask,:,2);
- cm_tmp(swap_mask,:,2) = tmpMass;
- pvec = zeros(T,1); Fvec = zeros(T,1);
- for t = 1:T
- [pvec(t), tbl] = circ_wwtest(cm_tmp(:,t,1), cm_tmp(:,t,2));
- Fvec(t) = tbl{2,5};
- end
- is_sig_p = (pvec < 0.05);
- CCp = bwconncomp(is_sig_p);
- if CCp.NumObjects==0
- max_mass(perm) = 0;
- else
- masses = zeros(CCp.NumObjects,1);
- for c = 1:CCp.NumObjects
- ii = CCp.PixelIdxList{c};
- masses(c) = sum(Fvec(ii));
- end
- max_mass(perm) = max(masses);
- end
- end
- p_value_cluster = nan(numel(mass_obs),1);
- sort_max = sort(max_mass);
- for c = 1:numel(mass_obs)
- p_value_cluster(c) = (nperms - dsearchn(sort_max, mass_obs(c))) / nperms;
- end
- %% Alpha-phase clustering increases for correct responses only in low IAF individuals (Time-resolved)
- clc, clear
- rng('Shuffle')
- load('timeperiod_phase.mat')
- NT = numel(timeperiod);
- which_group = 'below'; % 'below' | 'above'
- switch which_group
- case 'below'
- load('PHASE_below.mat');
- datax = data_phase_below;
- group = 1:numel(datax);
- case 'above'
- load('PHASE_above.mat');
- datax = data_phase_above;
- group = 1:numel(datax);
- end
- no_perm = 500;
- itpc = zeros(length(datax), NT, 2);
- for participant = 1:length(datax)
- participant
- data = datax{participant};
- accuracy = (data(:,1) == data(:,2));
- nCorr = sum(accuracy==1);
- nErr = sum(accuracy==0);
- nMin = min(nCorr,nErr);
- for t = 1:NT
- itpc_s = zeros(no_perm,1);
- for r = 1:no_perm
- temp = Shuffle(find(accuracy==1));
- temp = temp(1:nMin);
- itpc_s(r,1) = abs(mean(exp(1i*data(temp , t+3))));
- end
- itpc(participant,t,1) = mean(itpc_s);
- itpc(participant,t,2) = abs(mean(exp(1i*data(accuracy==0, t+3))));
- end
- end
- signP = zeros(NT,1);
- tstat = zeros(NT,1);
- for t = 1:NT
- [~,signP(t),~,st] = ttest(itpc(:,t,1), itpc(:,t,2));
- tstat(t) = st.tstat;
- end
- tmask = tstat; tmask(signP>0.05) = 0;
- CC = bwconncomp(tmask);
- clists = CC.PixelIdxList;
- sum_t = zeros(numel(clists),1);
- for c = 1:numel(clists)
- idx = clists{c};
- sum_t(c) = sum(abs(tmask(idx(1):idx(end))));
- end
- nperms = 1000;
- sig_fake = zeros(NT,nperms);
- t_fake = zeros(NT,nperms);
- max_cluster_sizes = zeros(nperms,1);
- for perm = 1:nperms
- lowalpha = itpc(:,:,1); % Correct(bal)
- highalpha = itpc(:,:,2); % Incorrect
- randorder = randperm(size(itpc,1));
- randorder_1 = rem(randorder,2);
- lowalpha_fake = zeros(size(lowalpha));
- highalpha_fake = zeros(size(highalpha));
- for s = 1:size(itpc,1)
- if randorder_1(s)==1
- lowalpha_fake(s,:) = lowalpha(s,:);
- highalpha_fake(s,:) = highalpha(s,:);
- else
- lowalpha_fake(s,:) = highalpha(s,:);
- highalpha_fake(s,:) = lowalpha(s,:);
- end
- end
- for t = 1:NT
- [sig_fake(t,perm),~,~,e] = ttest(lowalpha_fake(:,t), highalpha_fake(:,t));
- t_fake(t,perm) = e.tstat;
- end
- t_fake(~sig_fake(:,perm),perm) = 0;
- CCp = bwconncomp(t_fake(:,perm));
- tmpMass = zeros(max([CCp.NumObjects,1]),1);
- if CCp.NumObjects>0
- for c = 1:CCp.NumObjects
- idx = CCp.PixelIdxList{c};
- tmpMass(c) = sum(abs(t_fake(idx(1):idx(end),perm)));
- end
- else
- tmpMass(1) = 0;
- end
- max_cluster_sizes(perm) = max(tmpMass);
- end
- p_value_cluster = zeros(numel(clists),1);
- mx = sort(max_cluster_sizes);
- for c = 1:numel(clists)
- p_value_cluster(c) = (nperms - dsearchn(mx, sum_t(c))) / nperms;
- end
- %% Alpha-phase clustering increases for correct responses only in low IAF individuals (Time-Frequency)
- clc, clearvars
- rng('shuffle');
- load('timeperiod_phase.mat')
- load('idx_group.mat')
- load('PHASE_all.mat');
- below_median_indices = idx_group(:,1);
- above_median_indices = idx_group(:,2);
- eegfolder = ''%path
- group_mode = 'below';
- switch group_mode
- case 'below'
- subj_idx = below_median_indices;
- case 'above'
- subj_idx = above_median_indices;
- end
- EEG_struct = dir(fullfile(eegfolder, '*.set'));
- EEG_files = {EEG_struct.name}';
- EEG_files_sel = EEG_files(subj_idx);
- PHASE_files_sel = data_phase_all(subj_idx);
- elec_list_all = readcell('electrodes_to_analyze.xlsx');
- elec_list = elec_list_all(subj_idx);
- EEG = pop_loadset('filename', EEG_files_sel{1}, 'filepath', eegfolder);
- EEG = eeg_checkset(EEG);
- freqs2use = linspace(2,50,50);
- tvec = -1.5:1/EEG.srate:1.5;
- half_wavelet = (length(tvec)-1)/2;
- range_cycles = [3 11];
- s = logspace(log10(range_cycles(1)),log10(range_cycles(end)),numel(freqs2use)) ./ (2*pi*freqs2use);
- n_wavelet = numel(tvec);
- cmwX_template = cell(numel(freqs2use),1);
- for fi = 1:numel(freqs2use)
- wavelet = exp(1i*2*pi*freqs2use(fi).*tvec) .* exp(-tvec.^2./(2*s(fi)^2));
- cmwX_template{fi} = wavelet;
- end
- nSubj = numel(EEG_files_sel);
- NT = numel(timeperiod);
- itpc = zeros(nSubj, numel(freqs2use), NT, 2);
- for s = 1:nSubj
- s
- data = PHASE_files_sel{s};
- accuracy = (data(:,1) == data(:,2));
- eeg_file = fullfile(eegfolder, EEG_files_sel{s});
- EEG = pop_loadset('filename', EEG_files_sel{s}, 'filepath', eegfolder);
- EEG = eeg_checkset(EEG);
- elec_name = elec_list{s};
- chan_idx = find(strcmp({EEG.chanlocs.labels}, elec_name));
- n_data = size(EEG.data,2)*size(EEG.data,3);
- n_conv = n_wavelet + n_data - 1;
- TF_phase = zeros(numel(freqs2use), size(EEG.data,2), size(EEG.data,3));
- chandat = reshape(EEG.data(chan_idx,:,:), 1, []);
- dataX = fft(chandat, n_conv);
- for fi = 1:numel(freqs2use)
- wavelet = cmwX_template{fi};
- cmw = fft(wavelet, n_conv);
- cmw = cmw ./ max(cmw);
- as = ifft(cmw .* dataX);
- as = as(half_wavelet+1:end-half_wavelet);
- as = reshape(as, size(EEG.data,2), size(EEG.data,3));
- TF_phase(fi,:,:) = angle(as);
- end
- nCorr = sum(accuracy==1);
- nErr = sum(accuracy==0);
- nMin = min(nCorr,nErr);
- time2saveidx = dsearchn(EEG.times', [-800 200]');
- itpc_s = zeros(numel(freqs2use), size(TF_phase,2), 500);
- corr_idx = find(accuracy==1);
- for subs = 1:500
- temp = Shuffle(corr_idx);
- temp = temp(1:nMin);
- for fi = 1:numel(freqs2use)
- itpc_s(fi,:,subs) = abs(mean(exp(1i*TF_phase(fi,:,temp)),3));
- end
- end
- itpc(s,:,:,1) = mean(itpc_s(:, time2saveidx(1):time2saveidx(2), :), 3);
- err_idx = (accuracy==0);
- for fi = 1:numel(freqs2use)
- itpc(s,fi,:,2) = abs(mean(exp(1i*TF_phase(fi, time2saveidx(1):time2saveidx(2), err_idx)), 3));
- end
- end
- itpc_corr = itpc(:,:,:,1);
- itpc_incorr = itpc(:,:,:,2);
- itpc_diff = itpc_corr - itpc_incorr;
- npart = size(itpc_diff,1);
- pval = 0.05/2;
- zval = abs(norminv(pval));
- n_permutes = 1000;
- permmaps = zeros(n_permutes, numel(freqs2use), numel(timeperiod));
- tf3d = {itpc_corr, itpc_incorr};
- for permi = 1:n_permutes
- group_temp = zeros(numel(freqs2use), numel(timeperiod));
- randorder = randperm(npart);
- randorder_1 = rem(randorder,2)+1;
- randorder_2 = rem(randorder_1,2)+1;
- for subj = 1:length(randorder_1)
- A = tf3d{randorder_1(subj)}(subj,:,:);
- B = tf3d{randorder_2(subj)}(subj,:,:);
- group_temp = group_temp + squeeze(B(1,:,:)-A(1,:,:));
- end
- permmaps(permi,:,:) = group_temp./subj;
- end
- mean_h0 = squeeze(mean(permmaps,1));
- std_h0 = squeeze(std(permmaps,0,1));
- zmap = (squeeze(nanmean(itpc_diff,1)) - mean_h0) ./ std_h0;
- zmap(abs(zmap)<zval) = 0;
- max_cluster_sizes = zeros(1,n_permutes);
- for permi = 1:n_permutes
- threshimg = squeeze(permmaps(permi,:,:));
- threshimg = (threshimg-mean_h0) ./ std_h0;
- threshimg(abs(threshimg)<zval) = 0;
- islands = bwconncomp(threshimg);
- if numel(islands.PixelIdxList)>0
- tempclustsizes = cellfun(@length, islands.PixelIdxList);
- max_cluster_sizes(permi) = max(tempclustsizes);
- end
- end
- mx = sort(max_cluster_sizes);
- islands = bwconncomp(zmap);
- nClust = islands.NumObjects;
- p_cluster = zeros(nClust,1);
- for c = 1:nClust
- this_size = numel(islands.PixelIdxList{c});
- rank_idx = dsearchn(mx', this_size);
- p_cluster(c) = 1-(rank_idx/n_permutes);
- if p_cluster(c) >= 0.05
- zmap(islands.PixelIdxList{c}) = 0;
- end
- end
- %% SI: No significant differences observed in behavioural performance between first and third power terciles
- clc; clearvars;
- rng('shuffle');
- eegfolder = ''%path
- load('AllSubjects.mat')
- cd(eegfolder);
- EEG_struct = dir(fullfile(eegfolder, '*.set'));
- EEG_files = {EEG_struct.name}';
- elec_to_select = readcell('electrodes_to_analyze.xlsx');
- iaf_to_select = readcell('peak_to_analyze.xlsx');
- freqs2use = linspace(2,50,50);
- nSubj = numel(EEG_files);
- d = zeros(nSubj,2);
- c = zeros(nSubj,2);
- for s = 1:nSubj
- filename = EEG_files{s};
- EEG = pop_loadset('filename', filename, 'filepath', eegfolder);
- EEG = eeg_checkset(EEG);
- EEG.data = diff(EEG.data,1,2);
- elec2anal = elec_to_select{s};
- chan_idx = find(strcmpi({EEG.chanlocs.labels}, elec2anal));
- TF_abs = TF_IAF(EEG.data, EEG.srate, chan_idx); % [F x T x trials]
- mean_pow = mean(TF_abs,3);
- basewin = [-3200 -2800];
- baseidx = round(dsearchn(EEG.times', basewin'));
- bslpow = mean(mean_pow(:, baseidx(1):baseidx(2)), 2);
- BSLpow = repmat(bslpow, [1, size(TF_abs,2), size(TF_abs,3)]);
- ampl_all = 10*log10(TF_abs ./ BSLpow);
- iaf2select = iaf_to_select{s};
- iafrange2select = dsearchn(freqs2use', iaf2select');
- time2select = [-800 -100];
- timerange2select = dsearchn(EEG.times', [time2select(1) time2select(2)]');
- subpow = ampl_all(iafrange2select, timerange2select(1):timerange2select(2), :);
- meanampl = squeeze(mean(subpow, 2));
- meanampl = meanampl(:);
- [~, sorted_alpha_ampl] = sort(meanampl);
- nTrials = numel(sorted_alpha_ampl);
- n1 = ceil(nTrials/3);
- n3start = ceil(2*nTrials/3);
- first_tercile = sorted_alpha_ampl(1:n1);
- third_tercile = sorted_alpha_ampl(n3start:end);
- data = databehx{s};
- data = data(:,1:2);
- data_low_alpha = data(first_tercile,:);
- stim_pres = data_low_alpha(data_low_alpha(:,1)==1,:);
- hit = sum(stim_pres(:,1)==stim_pres(:,2)) / size(stim_pres,1);
- if hit==1, hit = (size(stim_pres,1)-0.5)/size(stim_pres,1); end
- if hit==0, hit = 0.5/size(stim_pres,1); end
- stim_abs = data_low_alpha(data_low_alpha(:,1)==0,:);
- fa = sum(stim_abs(:,1)~=stim_abs(:,2)) / size(stim_abs,1);
- if fa==0, fa = 0.5/size(stim_abs,1); end
- d(s,1) = norminv(hit) - norminv(fa);
- c(s,1) = -(norminv(hit) + norminv(fa))/2;
- data_high_alpha = data(third_tercile,:);
- stim_pres = data_high_alpha(data_high_alpha(:,1)==1,:);
- hit = sum(stim_pres(:,1)==stim_pres(:,2)) / size(stim_pres,1);
- if hit==1, hit = (size(stim_pres,1)-0.5)/size(stim_pres,1); end
- if hit==0, hit = 0.5/size(stim_pres,1); end
- stim_abs = data_high_alpha(data_high_alpha(:,1)==0,:);
- fa = sum(stim_abs(:,1)~=stim_abs(:,2)) / size(stim_abs,1);
- if fa==0, fa = 0.5/size(stim_abs,1); end
- d(s,2) = norminv(hit) - norminv(fa);
- c(s,2) = -(norminv(hit)+norminv(fa))/2;
- end
- [~,p_d,~,st_d] = ttest(d(:,1), d(:,2));
- bf_d = bf.ttest(d(:,1), d(:,2));
- [~,p_c,~,st_c] = ttest(c(:,1), c(:,2));
- bf_c = bf.ttest(c(:,1), c(:,2));
- %% SI: Correct and Incorrect trials are not characterized by difference in oscillatory amplitude.
- %% SI: Trial-by-trial fluctuations in alpha power do not account for perceptual accuracy.
- clc; clearvars;
- rng('shuffle');
- eegfolder = ''%path
- D = dir(eegfolder);
- folder_direeg = struct2cell(D)';
- folder_direeg = folder_direeg(3:end,1);
- folder_direeg = folder_direeg(2:2:end);
- all_idx = 1:116;
- group = all_idx;
- freqs2use = linspace(2,50,50);
- iaf_to_select = readmatrix('peak_to_analyze.xlsx');
- elec_to_select= readcell('electrodes_to_analyze.xlsx');
- load('IAF_allSubjects.mat');
- nSubj = numel(group);
- ampl = cell(nSubj,2);
- b_z_pow = zeros(nSubj,1);
- iaf_z_pow = zeros(nSubj,1);
- for pi = 1:nSubj
- subj_id = group(pi);
- data = datax{subj_id};
- accuracy = (data(:,1) == data(:,2));
- iaf_p = zscore(mean(data(:,4:end), 2));
- cd(eegfolder);
- filename = folder_direeg{subj_id};
- EEG = pop_loadset('filename', filename);
- EEG = eeg_checkset(EEG);
- EEG.data = diff(EEG.data, 1, 2);
- iaf_part = iaf_to_select(subj_id);
- elec_name = elec_to_select{subj_id};
- chan_idx = find(strcmpi({EEG.chanlocs.labels}, elec_name));
- iafidx = dsearchn(freqs2use', iaf_part);
- TF_amp = TF_IAF(EEG.data, EEG.srate, chan_idx);
- time2save = [-800 -100];
- time2saveidx = dsearchn(EEG.times', time2save');
- basewin = [-3200 -2800];
- baseidx = round(dsearchn(EEG.times', basewin'));
- mean_pow_corr = mean(TF_amp(:,:,accuracy), 3);
- bslpow_CORR = mean(mean_pow_corr(:, baseidx(1):baseidx(2)), 2);
- mean_pow_incorr = mean(TF_amp(:,:,accuracy==0), 3);
- bslpow_INCORR = mean(mean_pow_incorr(:, baseidx(1):baseidx(2)), 2);
- ampl{pi,1} = 10*log10( mean(TF_amp(:, time2saveidx(1):time2saveidx(2), accuracy), 3) ./ bslpow_CORR );
- ampl{pi,2} = 10*log10( mean(TF_amp(:, time2saveidx(1):time2saveidx(2), accuracy==0),3) ./ bslpow_INCORR );
- mean_pow_all = mean(TF_amp, 3);
- bslpow_all = mean(mean_pow_all(:, baseidx(1):baseidx(2)), 2);
- BSLpow = repmat(bslpow_all, [1, size(TF_amp,2), size(TF_amp,3)]);
- powtrialbytrial = TF_amp ./ BSLpow;
- ampl2use = squeeze( zscore( mean(powtrialbytrial(iafidx, time2saveidx(1):time2saveidx(2), :), 2) ) );
- ampl2use = ampl2use(:);
- X = [ones(length(ampl2use),1), ampl2use, iaf_p];
- beta = (X' * X) \ (X' * accuracy);
- b_pow = beta(2);
- b_iaf = beta(3);
- nPermReg = 2000;
- b_perms_ampl = zeros(nPermReg,1);
- b_perms_iaf = zeros(nPermReg,1);
- for permi = 1:nPermReg
- rp = randperm(length(ampl2use));
- pow_r = ampl2use(rp);
- iaf_r = iaf_p(rp);
- Xp = [ones(length(pow_r),1), pow_r, iaf_r];
- beta_p = (Xp' * Xp) \ (Xp' * accuracy);
- b_perms_ampl(permi) = beta_p(2);
- b_perms_iaf(permi) = beta_p(3);
- end
- b_z_pow(pi) = (b_pow - mean(b_perms_ampl)) ./ std(b_perms_ampl);
- iaf_z_pow(pi) = (b_iaf - mean(b_perms_iaf)) ./ std(b_perms_iaf);
- end
- [~,p_b,~,st_b] = ttest(b_z_pow);
- bf_b = bf.ttest(b_z_pow);
- [~,p_i,~,st_i] = ttest(iaf_z_pow);
- bf_i = bf.ttest(iaf_z_pow);
- [F,T] = size(ampl{1,1});
- correct_value = zeros(nSubj,F,T);
- incorrect_value = zeros(nSubj,F,T);
- for i = 1:nSubj
- correct_value(i,:,:) = ampl{i,1};
- incorrect_value(i,:,:) = ampl{i,2};
- end
- correct_responses = squeeze(mean(correct_value,1)); % [F x T]
- incorrect_responses = squeeze(mean(incorrect_value,1)); % [F x T]
- difference_matrix = correct_responses - incorrect_responses;
- pval = 0.05/2;
- zval = abs(norminv(pval));
- time2save = [-800 -100];
- time2saveidx = dsearchn(EEG.times', time2save');
- timeperiod = EEG.times(time2saveidx(1):time2saveidx(2));
- num_zeros = nSubj/2;
- num_ones = nSubj/2;
- vector = [zeros(1,num_zeros), ones(1,num_ones)] + 1;
- meanamplcorr = {correct_value, incorrect_value};
- nPermTF = 1000;
- difference_matrix_perm = zeros(nPermTF,F,T);
- for permi = 1:nPermTF
- v = vector(randperm(nSubj));
- sv = 3 - v;
- corrtemp = zeros(F,T);
- incorrtemp = zeros(F,T);
- for part = 1:nSubj
- corrtemp = corrtemp + squeeze(meanamplcorr{v(part)} (part,:,:));
- incorrtemp = incorrtemp + squeeze(meanamplcorr{sv(part)}(part,:,:));
- end
- difference_matrix_perm(permi,:,:) = (corrtemp - incorrtemp) ./ nSubj;
- end
- mean_h0 = squeeze(mean(difference_matrix_perm,1));
- std_h0 = squeeze(std(difference_matrix_perm,[],1));
- zmap = (difference_matrix - mean_h0) ./ std_h0;
- zmap(abs(zmap) < zval) = 0;
- max_cluster_sizes = zeros(1, nPermTF);
- for permi = 1:nPermTF
- thr = squeeze(difference_matrix_perm(permi,:,:));
- thr = (thr - mean_h0) ./ std_h0;
- thr(abs(thr) < zval) = 0;
- islands = bwconncomp(thr);
- if numel(islands.PixelIdxList) > 0
- tempclustsizes = cellfun(@length, islands.PixelIdxList);
- max_cluster_sizes(permi) = max(tempclustsizes);
- else
- max_cluster_sizes(permi) = 0;
- end
- end
- mx = sort(max_cluster_sizes);
- islands = bwconncomp(zmap);
- nClust = islands.NumObjects;
- p_cluster = zeros(nClust,1);
- for c = 1:nClust
- this_size = numel(islands.PixelIdxList{c});
- rank_idx = dsearchn(mx', this_size);
- p_cluster(c) = 1 - (rank_idx / nPermTF);
- if p_cluster(c) >= 0.05
- zmap(islands.PixelIdxList{c}) = 0;
- end
- end
- %% SI: Low and Fast IAF groups do not exhibit significant differences in oscillatory amplitude.
- clc; clearvars;
- rng('shuffle');
- load('idx_group.mat');
- group_low = idx_group(:,1);
- group_high = idx_group(:,2);
- nLow = numel(group_low);
- nHigh = numel(group_high);
- iaf_to_select = readmatrix('peak_to_analyze.xlsx');
- elec_to_select = readcell('electrodes_to_analyze.xlsx');
- eegfolder = '';%path
- cd(eegfolder);
- D = dir(eegfolder);
- folder_direeg = struct2cell(D)';
- folder_direeg = folder_direeg(3:end,1);
- folder_direeg = folder_direeg(2:2:end);
- nSubj = numel(folder_direeg);
- freqs2use = linspace(2,50,50);
- EEG = pop_loadset('filename', folder_direeg{1}, 'filepath', eegfolder);
- EEG = eeg_checkset(EEG);
- time_window = [-800 -100];
- time2idx = dsearchn(EEG.times', time_window');
- timeperiod = EEG.times(time2idx(1):time2idx(2));
- basewin = [-3200 -2800];
- baseidx = round(dsearchn(EEG.times', basewin'));
- nFreq = numel(freqs2use);
- nTimeWin = numel(timeperiod);
- tf_ampl_all = NaN(nSubj, nFreq, nTimeWin);
- for s = 1:nSubj
- part_elec = elec_to_select{s};
- filename = folder_direeg{s};
- EEG = pop_loadset('filename', filename, 'filepath', eegfolder);
- EEG = eeg_checkset(EEG);
- EEG.data = diff(EEG.data,1,2);
- elec_idx = find(strcmpi({EEG.chanlocs.labels}, part_elec));
- TF_abs = TF_IAF(EEG.data, EEG.srate, elec_idx);
- bslpow = mean(mean(TF_abs(:, baseidx(1):baseidx(2), :), 2), 3);
- meanampl = mean(TF_abs, 3);
- BSLpow = repmat(bslpow, [1, size(meanampl,2)]);
- ampl_all = 10*log10(meanampl ./ BSLpow);
- tf_ampl_all(s,:,:) = ampl_all(:, time2idx(1):time2idx(2));
- end
- low_tf = squeeze(mean(tf_ampl_all(group_low,:,:), 1));
- high_tf = squeeze(mean(tf_ampl_all(group_high,:,:), 1));
- diff_tf = low_tf - high_tf;
- pval = 0.05/2;
- zval = abs(norminv(pval));
- nPermTF = 1000;
- all_idx = [group_low(:); group_high(:)];
- nTot = numel(all_idx);
- perm_maps = zeros(nPermTF, nFreq, nTimeWin);
- for permi = 1:nPermTF
- rp = randperm(nTot);
- fake_low_idx = all_idx(rp(1:nLow));
- fake_high_idx = all_idx(rp(nLow+1:end));
- fake_low_tf = squeeze(mean(tf_ampl_all(fake_low_idx,:,:), 1));
- fake_high_tf = squeeze(mean(tf_ampl_all(fake_high_idx,:,:), 1));
- perm_maps(permi,:,:) = fake_low_tf - fake_high_tf;
- end
- mean_h0 = squeeze(mean(perm_maps,1));
- std_h0 = squeeze(std(perm_maps,0,1));
- zmap = (diff_tf - mean_h0) ./ std_h0;
- zmap(abs(zmap) < zval) = 0;
- max_cluster_sizes = zeros(1, nPermTF);
- for permi = 1:nPermTF
- thr = squeeze(perm_maps(permi,:,:));
- thr = (thr - mean_h0) ./ std_h0;
- thr(abs(thr) < zval) = 0;
- islands = bwconncomp(thr);
- if numel(islands.PixelIdxList) > 0
- temp_sizes = cellfun(@length, islands.PixelIdxList);
- max_cluster_sizes(permi) = max(temp_sizes);
- else
- max_cluster_sizes(permi) = 0;
- end
- end
- mx = sort(max_cluster_sizes(:));
- islands = bwconncomp(zmap);
- nClust = islands.NumObjects;
- p_cluster = zeros(nClust,1);
- for c = 1:nClust
- this_size = numel(islands.PixelIdxList{c});
- rank_idx = dsearchn(mx, this_size);
- p_cluster(c) = 1 - (rank_idx / nPermTF);
- if p_cluster(c) >= 0.05
- zmap(islands.PixelIdxList{c}) = 0;
- end
- end
- %% SI : FFT-based method for estimating single-trial IAF confirmed the pattern
- %% of results observed with the instantaneous frequency approach.
- %% SI : The FFT-based and instantaneous frequency approaches result in comparable single-trial IAF values.
- clc; clear; close all;
- EEGFOLDER = '';%path
- cd(EEGFOLDER);
- dEEG = dir(EEGFOLDER);
- EEG_files = struct2cell(dEEG)';
- EEG_files = EEG_files(3:end,1);
- start_from = 2;
- subji = start_from:2:length(EEG_files);
- dataEEG = cell(1, numel(subji));
- cd(EEGFOLDER);
- for p = 1:numel(subji)
- idxEEG = subji(p);
- filename = char(EEG_files{idxEEG});
- EEG = pop_loadset('filename', filename);
- EEG = eeg_checkset(EEG);
- dataEEG{p} = EEG;
- end
- electrodes_to_analyze = readcell('electrodes_to_analyze.xlsx');
- cmin = 1;
- fRange = [1 40];
- Fw = 11;
- k = 5;
- iaf_all = cell(1, size(subji,2));
- god_all = cell(1, size(subji,2));
- for soggetto = 1:size(subji,2)
- EEG = dataEEG{soggetto};
- EEG.data = diff(EEG.data,1,2);
- time2anal = [-800 -100];
- time2idx = dsearchn(EEG.times',time2anal');
- Fs = EEG.srate;
- idxElectrode = find(strcmpi({EEG.chanlocs.labels}, ...
- electrodes_to_analyze{soggetto}));
- w = [7 14];
- ntrials = size(EEG.data,3);
- iaf_p = zeros(ntrials,1);
- god_p = zeros(ntrials,1);
- for triali = 1:ntrials
- data_colcoran = EEG.data(idxElectrode,time2idx(1):time2idx(2),triali);
- [~,colcalpha] = restingIAF_natcomm(data_colcoran, 1, cmin, fRange, Fs, w, Fw, k,'nfft', EEG.srate*4);
- iaf_p(triali) = colcalpha.peaks;
- god_p(triali) = ~isnan(iaf_p(triali));
- end
- iaf_all{soggetto} = iaf_p;
- god_all{soggetto} = god_p;
- end
- load('IAF_allSubjects.mat')
- iaf = zeros(length(datax),2);
- gof = zeros(length(datax),2);
- nperms = 2000;
- [d,c,accuracies] = deal(zeros(length(datax),2));
- b = zeros(1,length(iaf_all));
- b_z = zeros(1,length(iaf_all));
- rho = NaN(numel(iaf_all),1);
- for participant = 1:length(iaf_all)
- databeh = datax{participant};
- iaf_inst = mean(databeh(:,4:end),2);
- databeh = databeh(:,1:3);
- accuracy = databeh(:,1) == databeh(:,2);
- data_iaf = iaf_all{participant};
- rho(participant) = corr(data_iaf, iaf_inst,'Type','Spearman','Rows','complete');
- iaf_acc = data_iaf(accuracy);
- iaf_inc = data_iaf(~accuracy);
- iaf(participant,1) = nanmean(iaf_acc);
- iaf(participant,2) = nanmean(iaf_inc);
- data_gof = god_all{participant};
- gof_acc = data_gof(accuracy);
- gof_inc = data_gof(~accuracy);
- gof(participant,1) = mean(gof_acc);
- gof(participant,2) = mean(gof_inc);
- X = [ones(length(data_iaf),1), data_iaf];
- todel = isnan(X(:,2));
- X(todel,:) = [];
- accuracy(todel) = [];
- X(:,2) = zscore(X(:,2));
- t = (X'*X)\(X'*accuracy);
- b(participant) = t(2);
- datat = X;
- X_o = X;
- b_perms = zeros(nperms,1);
- for permi = 1:nperms
- datat(:,2) = Shuffle(X_o(:,2));
- Xt = [ones(length(datat),1), datat(:,2)];
- tt = (Xt'*Xt)\(Xt'*accuracy);
- b_perms(permi) = tt(2);
- end
- b_z(participant) = (b(participant)-mean(b_perms))./std(b_perms);
- todel = isnan(data_iaf);
- data_iaf(todel) = [];
- databeh(todel,:) = [];
- [~, h] = sort(data_iaf);
- databeh = databeh(h,:);
- data_low_alpha = databeh(1:ceil(length(data_iaf)/3),:);
- data_hig_alpha = databeh(ceil(length(data_iaf)/3*2)+1:end,:);
- stim_pres = data_low_alpha( data_low_alpha(:,1)==1 ,:);
- hit = (sum(stim_pres(:,1) == stim_pres(:,2)))/(length(stim_pres));
- stim_abs = data_low_alpha( data_low_alpha(:,1)==0 ,:);
- fa = (sum(stim_abs(:,1) ~= stim_abs(:,2)))/(length(stim_abs));
- if hit==0, hit=0.5/length(stim_pres); elseif hit==1, hit=(length(stim_pres)-0.5)/length(stim_pres); end
- if fa==0, fa=0.5/length(stim_abs); elseif fa==1, fa=(nN-0.5)/length(stim_abs); end
- d(participant,1) = norminv(hit) - norminv(fa);
- c(participant,1) = -(norminv(hit) + norminv(fa))/2;
- accuracies(participant,1) = sum(data_low_alpha(:,1) == data_low_alpha(:,2)) ...
- / length(data_low_alpha(:,1));
- stim_pres = data_hig_alpha( data_hig_alpha(:,1)==1 ,:);
- hit = (sum(stim_pres(:,1) == stim_pres(:,2)))/(length(stim_pres));
- stim_abs = data_hig_alpha( data_hig_alpha(:,1)==0 ,:);
- fa = (sum(stim_abs(:,1) ~= stim_abs(:,2)))/(length(stim_abs));
- if hit==0, hit=0.5/length(stim_pres); elseif hit==1, hit=(length(stim_pres)-0.5)/length(stim_pres); end
- if fa==0, fa=0.5/length(stim_abs); elseif fa==1, fa=(nN-0.5)/length(stim_abs); end
- d(participant,2) = norminv(hit) - norminv(fa);
- c(participant,2) = -(norminv(hit) + norminv(fa))/2;
- accuracies(participant,2) = sum(data_hig_alpha(:,1) == data_hig_alpha(:,2)) ...
- / length(data_hig_alpha(:,1));
- end
- [a,b,cc,dd] = ttest(iaf(:,1),iaf(:,2))
- [bf10a] = bf.ttest(iaf(:,1),iaf(:,2))
- [a,b,cc,dd] = ttest(gof(:,1),gof(:,2))
- [bf1] = bf.ttest(gof(:,1),gof(:,2))
- [aa,bb,cc,ddd] = ttest(b_z)
- [bf10b] = bf.ttest(b_z)
- [a,b,cc,dd] = ttest(d(:,1),d(:,2))
- [bf10c] = bf.ttest(d(:,1),d(:,2))
- [a,b,cc,dd] = ttest(c(:,1),c(:,2))
- [bf10] = bf.ttest(c(:,1),c(:,2))
- [a,b,cc,dd] = ttest(accuracies(:,1),accuracies(:,2))
- [bf10d] = bf.ttest(accuracies(:,1),accuracies(:,2))
Script_NC.m, no license · at the source
Overview
- Dipartimento di Psicologia, Università di Bologna and Centro studi e ricerche in Neuroscienze Cognitive, Università di Bologna, Cesena, Italy
- Universidad Antonio de Nebrija, Madrid, Spain
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repository
Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.
OSF 6298n
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
- 30 September 2026: the link answers (HTTP 200)
4 files
- SCRIPT/
Script_NC.m , MATLAB, 1,130 lines, 3 matches - SCRIPT/
TF_IAF.m , MATLAB, 33 lines - SCRIPT/
instantaneous_NatComm.m , MATLAB, 32 lines - SCRIPT/
restingIAF_natcomm.m , MATLAB, 134 lines, 1 match
Code availability statement
The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: OSF 6298n
Read it in the paper: doi.org/10.1038/s41467-026-70124-9.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 4 scripts, each with its path and the digest of its content;
- 4 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability statement
The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- no repository, dataset or request procedure was recognized in it
Read it in the paper: doi.org/10.1038/s41467-026-70124-9.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 30 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 2 authors, 2 keywords, 10 MeSH terms, 82 references.
Cite
This paper
Romei, V., & Tarasi, L. (2026). Alpha frequency shapes perceptual sensitivity by modulating optimal phase likelihood. Nature communications, 17(1), 3384. https://
BibTeX
@article{romei2026alpha,
author = {Romei, Vincenzo and Tarasi, Luca},
title = {{Alpha frequency shapes perceptual sensitivity by modulating optimal phase likelihood}},
journal = {Nature communications},
year = {2026},
month = mar,
volume = {17},
number = {1},
pages = {3384},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/
url = {https://
pmid = {41776179},
pmcid = {PMC13065768}
}
RIS
TY - JOUR
AU - Romei, Vincenzo
AU - Tarasi, Luca
TI - Alpha frequency shapes perceptual sensitivity by modulating optimal phase likelihood
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/
VL - 17
IS - 1
SP - 3384
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Alpha frequency shapes perceptual sensitivity by modulating optimal phase likelihood",
"container-title": "Nature communications",
"author": [
{
"family": "Romei",
"given": "Vincenzo"
},
{
"family": "Tarasi",
"given": "Luca"
}
],
"container-title-short":
"volume": "17",
"issue": "1",
"page": "3384",
"DOI": "10.1038/
"PMID": "41776179",
"PMCID": "PMC13065768",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
3
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1162/imag.a.1263
- Individual alpha frequency predicts the sensitivity of time perception.Journal: Imaging neuroscience (Cambridge, Mass.)In common: cognitive, 13 references
- [2] doi:10.7554/elife.110000 [code]
- Alpha-band phase modulates perceptual sensitivity by changing internal noise and sensory tuning.Journal: eLifeIn common: CircStat, Image Processing Toolbox, Statistics and Machine Learning Toolbox, EEG, 10 references
- [3] doi:10.1093/cercor/bhag117 [code]
- Spontaneous changes in the prestimulus alpha power predict both objective and subjective aspects of perception-evidence from 4 paradigms and 471 experimental sessions.Journal: Cerebral cortex (New York, N.Y. : 1991)In common: EEG, cognitive, 8 references
- [4] doi:10.7554/elife.108408 [code]
- Frequency and laminar profile of feature-specific visual activity revealed by interleaved EEG-fMRI.Journal: eLifeIn common: Image Processing Toolbox, Signal Processing Toolbox, Statistics and Machine Learning Toolbox, EEG, 5 references
- [5] doi:10.1523/jneurosci.0154-26.2026 [code]
- Faster but less precise: expectation enhances response speed while reducing sensory fidelity.Journal: The Journal of neuroscience : the official journal of the Society for NeuroscienceIn common: CircStat, EEGLAB, Image Processing Toolbox, 2 other tools, EEG, cognitive, 2 references
- [6] doi:10.1111/psyp.70271 [code]
- Disentangling Respiratory Phase-Dependent and Phase-Independent Components of Anticipatory Cardiac Deceleration.Journal: PsychophysiologyIn common: CircStat, EEGLAB, Image Processing Toolbox, 2 other tools, EEG, cognitive, 1 reference
- [7] doi:10.1016/j.isci.2025.113806 [code]
- Beta-band frequency shifts signal decisions in human prefrontal cortexJournal: n/aIn common: Statistics and Machine Learning Toolbox, 6 references
- [8] doi:10.1162/imag.a.1229 [code]
- 40 Hz audiovisual stimulation improves sustained attention and related brain oscillations.Journal: Imaging neuroscience (Cambridge, Mass.)In common: CircStat, EEGLAB, Image Processing Toolbox, 2 other tools, EEG, 1 reference
- [9] doi:10.1162/imag.a.1199 [code]
- Sustained alpha oscillations serve attentional prioritization in working memory, not maintenance.Journal: Imaging neuroscience (Cambridge, Mass.)In common: CircStat, EEGLAB, Image Processing Toolbox, 2 other tools, EEG, cognitive, 1 reference
- [10] doi:10.1371/journal.pbio.3003818 [code]
- Human neuronal firing varies with the frequency of local field potential oscillations.Journal: PLoS biologyIn common: CircStat, EEGLAB, Image Processing Toolbox, 2 other tools, 1 reference
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 4 scripts, and 4 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:1a8e8b907b45a73f…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[.
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
