Changes in visuocortical engagement and oscillatory brain activity during associative learning.
The 2 matches
- [1] § Data recording and processing › Statistical analyses ↔ Code/ggtone_postpro_final.m, lines 832–839 · score 0.93 · 0–700 ms, 1300–2000 ms, 700–1300 ms
- [2] § Data recording and processing › SSVEP ↔ Code/ggtone_postpro_final.m, lines 187–256 · score 0.52 · single trial spectra, attenuates, spectral, noise, Gabor, RESS
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 · 845 lines · 29 KB · no license · 2 matches
- %% GaborGen Tone post-processing code - Final for repository
- %% SSVEP RESS Method
- % Set working directory to the RESS data folder
- clear
- clc
- cd ;
- % Get trial files for RESS analysis
- filemat = getfilesindir(pwd, 'gaborgentone*trls*.pow3.mat');
- %
- % Loop over subjects to compute RESS spatial filters for each group of 4 conditions.
- for filestart = 1:4:88
- filemat_actual = filemat(filestart:filestart+3, :);
- pause(1)
- RESS_filegroups23(filemat_actual, 1:120, 301:1300, 500, 15, 0); %1000 sample points from baseline to sound onset = 2000 ms
- end
- % Merge RESS power files across conditions
- filemat = getfilesindir(pwd, 'gabor*RESSpow*');
- mergemulticons(filemat, 4, 'GM22.RESSpow');
- cd
- filemat = getfilesindir(pwd, 'gabor*RESSpow*');
- % Load merged condition files for plotting/statistics
- Csplus = ReadAvgFile('GM22.RESSpow.at1');
- GS1 = ReadAvgFile('GM22.RESSpow.at2');
- GS2 = ReadAvgFile('GM22.RESSpow.at3');
- GS3 = ReadAvgFile('GM22.RESSpow.at4');
- % Build a 4D matrix for statistics: channels x frequencies x subjects x conditions
- [repmatress] = makerepmat(filemat, 22, 4, []);
- load repmatress.mat;
- % Perform an F test (ANOVA-like contrast) on RESS power over frequency
- for frequency = 1:500
- temprep = squeeze(repmatress(:, frequency, :, :));
- repmatress2 = reshape(temprep, [1, 22, 4]);
- [Fcontmat_linear_ress(:, frequency),~,~,~,~] = contrast_rep_sign(repmatress2, [2 1 -1 -2]);
- end
- SaveAvgFile('Fcontmat_linear_ress.at',Fcontmat_linear_ress,[],[],2000)
- % Plot
- faxisFFT = 0:.5:250;
- figure
- plot(faxisFFT(1:40), Csplus(1:40), 'r', LineWidth=3), hold on,
- plot(faxisFFT(1:40), GS1(1:40), 'm', LineWidth=3),
- plot(faxisFFT(1:40), GS2(1:40), 'b', LineWidth=3),
- plot(faxisFFT(1:40), GS3(1:40), 'g', LineWidth=3),
- title 'RESS Spectra by Condition', fontsize = 22, legend
- %% open emegs and plot ssvep
- emegs2d
- %% extract the power at 15 Hz for an anova-like spreadsheet in jasp
- filemat = getfilesindir(pwd, '*RESSpow.at')
- [outmat] = extractstats(filemat, 4, 1, 31, []);
- bar(faxisFFT(5:100), GS3(5:100), 'k')
- %% RESS Linear effect Bayesian Bootstrapping and Permutation
- % uses the repmatress
- clear
- clc
- % add location of RESS files
- cd
- load repmatress.mat;
- linearBootstrap =[];
- size(repmatress)
- nsubjects = size(repmatress, 3);
- % make distributions of effects
- lineareffect = [2 1 -1 -2];
- % the linear effect distribution
- for elec = 1:size(repmatress,1)
- for frequency = 1:size(repmatress,2)
- for draw = 1:2000
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- linearBootstrap(elec, frequency, draw) = mean(squeeze(repmatress(elec, frequency, bootstrapvec, : )), 1) * lineareffect';
- end
- end
- end
- % the null distribution permutation
- linearBootstrapPerm = []
- elec = 1;
- for perm = 1:2000
- repeatmatperm_Ress = repmatress;
- for subject = 1:nsubjects
- repeatmatperm_Ress(: , :, subject, 1:4) = repmatress(: , :, subject, randperm(4));
- end
- for frequency = 1:size(repmatress,2)
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- linearBootstrapPerm(elec, frequency, perm) = mean(squeeze(repeatmatperm_Ress(elec, frequency, bootstrapvec, : )), 1) * lineareffect';
- end
- disp(['draw ', num2str(perm)])
- end
- % Compare the bootstrapped with permuted data
- for elec = 1:size(repmatress,1)
- for frequency = 1:size(repmatress,2)
- BFmap_RESS_linear(elec, frequency) = bootstrap2BF_z(squeeze(linearBootstrap(elec, frequency, :)),squeeze(linearBootstrapPerm(elec, frequency, :)), 0);
- end
- end
- faxisFFT = 0:.5:250;
- faxisFFT(31)
- plot(BFmap_RESS_linear)
- title 'Bayes Factors Linear RESS'
- BFmap_RESS_linear(31)
- log10(BFmap_RESS_linear(31))
- %% RESS Selective effect Bayesian Bootstrapping and Permutation
- clear
- clc
- load repmatress.mat; % 1 electrode, 500 freqs, 22 people, 4 conds
- % uses the repmatress
- selectBootstrap_csplus =[];
- size(repmatress)
- nsubjects = size(repmatress, 3);
- selecteffect = [3 -1 -1 -1];
- % the linear effect distribution
- for elec = 1:size(repmatress,1)
- for frequency = 1:size(repmatress,2)
- for draw = 1:2000
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- selectBootstrap_csplus(elec, frequency, draw) = mean(squeeze(repmatress(elec, frequency, bootstrapvec, : )), 1) * selecteffect';
- end
- end
- end
- % the null distribution permutation
- selectBootstrapPerm_csplus = []
- elec = 1;
- for perm = 1:2000
- repeatmatperm_Ress = repmatress;
- for subject = 1:nsubjects
- repeatmatperm_Ress(: , :, subject, 1:4) = repmatress(: , :, subject, randperm(4));
- end
- for frequency = 1:size(repmatress,2)
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- selectBootstrapPerm_csplus(elec, frequency, perm) = mean(squeeze(repeatmatperm_Ress(elec, frequency, bootstrapvec, : )), 1) * selecteffect';
- end
- disp(['draw ', num2str(perm)])
- end
- % Compare the bootstrapped with permuted data
- for elec = 1:size(repmatress,1)
- for frequency = 1:size(repmatress,2)
- BFmap_RESS_select_cs(elec, frequency) = bootstrap2BF_z(squeeze(selectBootstrap_csplus(elec, frequency, :)), ...
- squeeze(selectBootstrapPerm_csplus(elec, frequency, :)), 0);
- end
- end
- faxisFFT = 0:.5:250;
- faxisFFT(31) %15 hz
- figure, plot(BFmap_RESS_select_cs)
- BFmap_RESS_select_cs(31) % result = .484
- log10(.484)
- %% SSVEP Single-Trial Spectra Method
- clear
- clc
- % power from the FFT3d (normal FFT, no RESS) is an aletrnative to the RESS, we examine this next:
- cd ;
- % does spectral analysis on each single trial and then
- % averages them together within conditions) which gives combo of steady state response from each
- % single trial and also all spontaneous (noise) frequencies will be
- % retained bc they are not attenuated by any type of averaging; (each trial
- % may be in different phase but phase information is not used)
- %only want original trls files (not PLI or POW)
- filemat = getfilesindir(pwd, 'gabor*trls*.mat'); %dont need to do this now
- % Compute FFT on each trial (using the desired time window and frequency resolution)
- get_FFT_mat3d(filemat, 301:1300, 500);
- % Get FFT spectrum files ('.spec') and merge across conditions
- cd
- filemat = getfilesindir(pwd, '*.spec');
- mergemulticons(filemat, 4, 'GM22.singletrialspec');
- [outmat] = extractstats(filemat, 4, [70 71 74 75 76 82 83] , 31, []);
- epoch = 301:1300;
- sizeEpochInSecs = length(epoch)*2/1000;
- fstep = 1/sizeEpochInSecs;
- faxis = 0:.5:250;
- % Get all matching files first
- filemat_all = getfilesindir(pwd, 'gaborgentone_*.trls.*.mat');
- % Now filter out the ones that contain '.trls.21.'
- exclude_pattern = 'trls.21.mat';
- keep_idx = ~contains(string(filemat_all), '.trls.21.');
- % Apply logical indexing to keep only desired filenames
- filemat = filemat_all(keep_idx, :);
- for i = 1:size(filemat, 1)
- % Load file and extract matrix
- fname = deblank(filemat(i, :));
- data = load(fname, '-mat');
- % Assumes the variable is called Mat3D
- if isfield(data, 'Mat3D')
- dat = data.Mat3D;
- else
- warning(['Mat3D not found in file: ' fname]);
- continue
- end
- % Average over 3rd dimension
- avgmat = mean(dat, 3, 'omitnan');
- % Generate output filename
- [~, name, ~] = fileparts(fname);
- outfile = [name '_avg.mat'];
- % % Save the averaged matrix
- % save(outfile, 'avgmat', '-mat');
- % disp(['Saved: ' outfile])
- end
- filematavg = getfilesindir(pwd, 'gaborgentone_*.trls.*_avg.mat');
- ERP = avgmats_mat(filematavg, 'ERP_Oz.mat');
- ERP_Oz = load('ERP_Oz.mat');
- ERP_Oz = ERP_Oz.avgmat;
- figure
- plot(taxis, ERP_Oz(75, :));
- %% Get FFT spectrum files ('.spec') and merge across conditions
- cd
- filemat = getfilesindir(pwd, '*.spec');
- mergemulticons(filemat, 4, 'GM22.singletrialspec');
- [outmat] = extractstats(filemat, 4, [70 71 74 75 76 82 83] , 31, []);
- % we saved the stat matrix to a file called resspower4cons.csv
- % to further examine this with method with higher sensitivity, we examined the largest effect visible post-hoc
- % Build repmat for statistical analysis: sensors x frequencies x subjects x conditions
- [repmatsingleSpec] = makerepmat(filemat, 22, 4, []);
- %
- [Fcontmat,rcontmat,MScont,MScs, dfcs]=contrast_rep_sign(squeeze(repmatsingleSpec(:, 31, :, :)) ,[1.5 .5 -.5 -1.5]);
- % now do the permutation test to see if this survives
- for draw = 1:1000
- for x = 1:22
- repmatsingleSpec(:, :, x, 1:4) = repmatsingleSpec(:, :,x, randperm(4));
- end
- [Fcontmat,rcontmat,MScont,MScs, dfcs]=contrast_rep_sign(squeeze(repmatsingleSpec(:, 31, :, :)) ,[1.5 .5 -.5 -1.5]);
- dist(draw) = max(Fcontmat);
- if draw./100 == round(draw./100), fprintf('.'), end
- end
- hist(dist, 50)
- quantile(dist, .95)
- % Load merged condition files for plotting/statistics
- csplus = ReadAvgFile('GM22.singletrialspec.at1');
- GS1 = ReadAvgFile('GM22.singletrialspec.at2');
- GS2 = ReadAvgFile('GM22.singletrialspec.at3');
- GS3 = ReadAvgFile('GM22.singletrialspec.at4');
- %
- figure
- plot(faxisFFT(1:50),GS1(75, 1:50), LineWidth=2),hold on,
- plot(faxisFFT(1:50),GS2(75, 1:50), LineWidth=2),
- plot(faxisFFT(1:50),GS3(75, 1:50), LineWidth=2),
- plot(faxisFFT(1:50),csplus(70, 1:50), 'r', LineWidth=2)
- title('Frequency Spectra by Condition', 'FontSize', 22)
- xlabel('Frequency (Hz)', 'FontSize', 20) % Label for x-axis
- ylabel('Power', 'FontSize', 20) % Label for y-axis
- legend({'GS1', 'GS2', 'GS3', 'CS+'}, 'FontSize', 20) % Adding legend
- ssvep21 = csplus(75,31);
- ssvep22 = GS1(75,31);
- ssvep23 = GS2(75,31);
- ssvep24 = GS3(75,31), 2;
- % Transpose if needed so rows = subjects, columns = conditions
- alpha_gm = [alphagm21; alphagm22; alphagm23; alphagm24]'; % size: [4 x N_conditions]
- alpha_mean = mean(alpha_gm, 1); % Mean across participants
- alpha_sem = std(alpha_gm, 0, 1) / sqrt(size(alpha_gm, 1)); % Standard Error of Mean (SEM)
- % Plot with error bars
- figure;
- % bar(alpha_mean);
- hold on
- errorbar(1:length(alpha_mean), alpha_mean, alpha_sem);
- xlabel('Condition');
- ylabel('Alpha Power (Grand Mean ± SEM)');
- xticks(1:length(alpha_mean));
- xticklabels({'Cond1','Cond2','Cond3','Cond4'});
- title('Alpha Power Across Conditions');
- % examine with emegs2d
- emegs2d
- %% Bayes bootstrapping for single-trial spectra - linear
- clear
- clc
- cd
- % uses the repmatsingleSpec: 129 channels, 500 freqs, 22 people, 4 conds
- load('repmatsingleSpec.mat')
- linearBootstrap =[];
- size(repmatsingleSpec)
- nsubjects = size(repmatsingleSpec, 3);
- % make distributions of effects
- lineareffect = [2 1 -1 -2];
- % the linear effect distribution
- for elec = 1:size(repmatsingleSpec,1)
- for frequency = 1:size(repmatsingleSpec,2)
- for draw = 1:2000
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- linearBootstrap(elec, frequency, draw) = mean(squeeze(repmatsingleSpec(elec, frequency, bootstrapvec, : )), 1) * lineareffect';
- end
- end
- disp(['draw ', num2str(draw)])
- end
- %%
- cd
- load('linearBootstrap_singleSpec.mat')
- %%
- % the null distribution permutation
- linearBootstrapPerm = [];
- for perm = 1:2000
- repeatmatperm_singleSpec = repmatsingleSpec;
- for subject = 1:nsubjects
- repeatmatperm_singleSpec(: , :, subject, 1:4) = repmatsingleSpec(: , :, subject, randperm(4));
- end
- for elec = 1:size(repmatsingleSpec,1)
- for frequency = 1:size(repmatsingleSpec,2)
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- linearBootstrapPerm(elec, frequency, perm) = mean(squeeze(repeatmatperm_singleSpec(elec, frequency, bootstrapvec, : )), 1) * lineareffect';
- end
- end
- disp(['draw ', num2str(perm)])
- end
- %% load permuted bf
- load('single_Spec_linearBootPerm.mat')
- %% Compare the bootstrapped with permuted data
- for elec = 1:size(repmatsingleSpec,1)
- for frequency = 1:size(repmatsingleSpec,2)
- BFmap_singleSpec_linear(elec, frequency) = bootstrap2BF_z(squeeze(linearBootstrap(elec, frequency, :)),squeeze(linearBootstrapPerm(elec, frequency, :)), 0);
- end
- disp(['elec', num2str(elec)])
- end
- faxisFFT = 0:.5:250;
- faxisFFT(31) %15 hz
- figure, plot(BFmap_singleSpec_linear(:, 31)) %select frequency of interest for all channels (15 hz which is the 31st bin)
- cd
- % use SaveAvgFile to create file to use in emegs for heads
- AvgMat = BFmap_singleSpec_linear;
- SaveAvgFile('BF_singleSpec_linear.at',AvgMat,[],[], 1,[],[],[],[],1)
- log10_BFssVEP_linear = log10(BFmap_singleSpec_linear);
- SaveAvgFile('log10_BFssVEP_linear.at', log10_BFssVEP_linear,[],[], 1,[],[],[],[],1)
- log10_BFssVEP_linear(75, 31)
- figure, plot(BFmap_singleSpec_linear(:, 31)) %select frequency of interest for all channels (15 hz which is the 31st bin)
- size(repmatsingleSpec)
- plot(squeeze(repmatsingleSpec(83, 31, :, :)))
- plot(squeeze(repmatsingleSpec(83, 31, :, :))')
- plot(squeeze(repmatsingleSpec(83, 31, :, 1))-squeeze(repmatsingleSpec(83, 31, :, 4)))
- bar(squeeze(repmatsingleSpec(83, 31, :, 1))-squeeze(repmatsingleSpec(83, 31, :, 4)))
- bar(mean(squeeze(repmatsingleSpec(75, 31, :, :)))')
- %% selective ssvep single trial spectra, bayes bootstrapping for single-trial spectra
- clear
- clc
- cd
- % uses the repmatsingleSpec: 129 channels, 500 freqs, 22 people, 4 conds
- load('repmatsingleSpec.mat')
- selectBootstrap =[];
- size(repmatsingleSpec)
- nsubjects = size(repmatsingleSpec, 3);
- % make distributions of effects
- selecteffect = [3 -1 -1 -1];
- % the all or nothing effect distribution
- for elec = 1:size(repmatsingleSpec,1)
- for frequency = 1:size(repmatsingleSpec,2)
- for draw = 1:2000
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- selectBootstrap(elec, frequency, draw) = mean(squeeze(repmatsingleSpec(elec, frequency, bootstrapvec, : )), 1) * selecteffect';
- end
- end
- disp(['elec ', num2str(elec)])
- end
- %% selective pattern
- % the null distribution permutation
- selectBootstrapPerm = [];
- for perm = 1:2000
- repeatmatperm_singleSpec = repmatsingleSpec;
- for subject = 1:nsubjects
- repeatmatperm_singleSpec(: , :, subject, 1:4) = repmatsingleSpec(: , :, subject, randperm(4));
- end
- for elec = 1:size(repmatsingleSpec,1)
- for frequency = 1:size(repmatsingleSpec,2)
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- selectBootstrapPerm(elec, frequency, perm) = mean(squeeze(repeatmatperm_singleSpec(elec, frequency, bootstrapvec, : )), 1) * lineareffect';
- end
- end
- disp(['draw ', num2str(perm)])
- end
- %saved as selectBootstrapPerm_singleSpec.mat
- %% Compare the bootstrapped with permuted data
- for elec = 1:size(repmatsingleSpec,1)
- for frequency = 1:size(repmatsingleSpec,2)
- BFmap_singleSpec_select(elec, frequency) = bootstrap2BF_z(squeeze(selectBootstrap(elec, frequency, :)),squeeze(selectBootstrapPerm(elec, frequency, :)), 0);
- end
- disp(['elec', num2str(elec)])
- end
- faxisFFT = 0:.5:250;
- faxisFFT(31) %15 hz
- figure, plot(BFmap_singleSpec_select(:, 31)) %select frequency of interest for all channels (15 hz which is the 31st bin)
- %
- SaveAvgFile('BF_singleSpec_select.at',BFmap_singleSpec_select,[],[], 1,[],[],[],[],1)
- %need to make heads for single trial spec;
- emegs2d
- log10_BFssVEP_select = log10(BFmap_singleSpec_select);
- SaveAvgFile('log10_BFssVEP_select.at', log10_BFssVEP_select,[],[], 1,[],[],[],[],1)
- log10_BFssVEP_select(75, 31)
- %% Alpha Wavelet Analysis
- clear
- clc
- % Set working directory
- cd
- % Define frequency and time axes for wavelet analysis
- faxisall = 0:1000/3600:250; % full frequency axis for wavelets
- faxis = faxisall(11:4:110); % frequency axis used for plotting
- taxis = (-598:2:3000); % time axis in ms
- % Run wavelet analysis on trial files (returns power, phase-locking index, etc.)
- filemat = getfilesindir(pwd, 'gabor*trls.2*.mat');
- [WaPower, PLI, PLIdiff] = wavelet_app_matfiles(filemat, 500, 11, 110, 4, 200:300, []); %baseline corr but not an issue bc its before waveletting
- % Process power files and group by condition:
- filematpow = getfilesindir(pwd, 'gabor*pow3.mat');
- filematpow21 = filematpow(1:4:end, :);
- filematpow22 = filematpow(2:4:end, :);
- filematpow23 = filematpow(3:4:end, :);
- filematpow24 = filematpow(4:4:end, :);
- % Compute grand means for each condition
- GM22pow3_21 = avgmats_mat(filematpow21, 'GM22.at21.pow3.mat');
- GM22pow3_22 = avgmats_mat(filematpow22, 'GM22.at22.pow3.mat');
- GM22pow3_23 = avgmats_mat(filematpow23, 'GM22.at23.pow3.mat');
- GM22pow3_24 = avgmats_mat(filematpow24, 'GM22.at24.pow3.mat');
- gm22 = getfilesindir(pwd, 'GM22.at2*'); %all except CS+ condition
- GM22_all = avgmats_mat(gm22, 'GM22_all.mat');
- % GM22_all = permute(GM22_all,[2 1 3]);
- SaveAvgFile('GM22_all.at',GM22_all,[],[], 1,[],[],[],[],1)
- %% time-freq plot for paper for channel 75 avg over all except cs+
- % filematGM = getfilesindir(pwd, 'GM22.at2*.pow3.mat')
- % GM22_all = avgmats_mat(filematGM, 'GM22_all.mat');
- load('GM22_all.mat')
- GM22_all_bsl = bslcorrWAMat_percent(GM22_all, 125:240);
- % Define frequency and time axes for wavelet analysis
- faxisall = 0:1000/3600:250; % full frequency axis for wavelets
- faxis = faxisall(11:4:110); % frequency axis used for plotting
- taxis = -598:2:3000; % time axis in ms
- % Plot baseline-corrected contours
- figure
- subplot(2,1,1), contourf(taxis, faxis, squeeze(GM22_all(sensor,:,:))'), colorbar
- subplot(2,1,2), contourf(taxis, faxis, squeeze(GM22_all_bsl(sensor,:,:))'), colorbar
- %%
- %load grand means for each condition
- GM22pow3_21 = importdata('GM22.at21.pow3.mat', 'avgmat');
- GM22pow3_22 = importdata('GM22.at22.pow3.mat', 'avgmat');
- GM22pow3_23 = importdata('GM22.at23.pow3.mat', 'avgmat');
- GM22pow3_24 = importdata('GM22.at24.pow3.mat', 'avgmat');
- GM22pow3_21 = GM22pow3_21(:, :, 8);
- GM22pow3_22 = GM22pow3_22(:, :, 8);
- GM22pow3_23 = GM22pow3_23(:, :, 8);
- GM22pow3_24 = GM22pow3_24(:, :, 8);
- %save as at files for emegs
- SaveAvgFile('GM22powAlpha_21_alpha.at',GM22pow3_21,[],[], 1,[],[],[],[],1)
- SaveAvgFile('GM22powAlpha_22_alpha.at',GM22pow3_22,[],[], 1,[],[],[],[],1)
- SaveAvgFile('GM22powAlpha_23_alpha.at',GM22pow3_23,[],[], 1,[],[],[],[],1)
- SaveAvgFile('GM22powAlpha_24_alpha.at',GM22pow3_24,[],[], 1,[],[],[],[],1)
- emegs2d
- % Plot contour plots for a selected sensor
- sensor = 75;
- faxisindex = 4:20;
- figure
- subplot(4,1,1), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_21(sensor,50:end-50, faxisindex))', 15)%, caxis([.4 5]),colorbar
- subplot(4,1,2), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_22(sensor,50:end-50, faxisindex))', 15)%, caxis([.4 5]),colorbar
- subplot(4,1,3), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_23(sensor,50:end-50, faxisindex))', 15)%, caxis([.4 5]),colorbar
- subplot(4,1,4), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_24(sensor,50:end-50, faxisindex))', 15)%, caxis([.4 5]),colorbar
- sgtitle(['Average Power by Condition: Sensor ' num2str(sensor)])%
- alphagm21 = GM22pow3_21(75,450:800);
- alphagm22 = GM22pow3_22(75,450:800);
- alphagm23 = GM22pow3_23(75,450:800);
- alphagm24 = GM22pow3_24(75,450:800);
- alpha_gm = [alphagm21; alphagm22; alphagm23; alphagm24]';
- alpha_mean = mean(alpha_gm, 1); % Mean across participants
- alpha_sem = std(alpha_gm, 0, 1) / sqrt(size(alpha_gm, 1)); % Standard Error of Mean (SEM)
- % Plot with error bars
- figure;
- bar(alpha_mean);
- hold on
- errorbar(1:length(alpha_mean), alpha_mean, alpha_sem);
- xlabel('Condition');
- ylabel('Alpha Power (Grand Mean ± SEM)');
- xticks(1:length(alpha_mean));
- xticklabels({'Cond1','Cond2','Cond3','Cond4'});
- title('Alpha Power Across Conditions');
- %% Baseline-correct the grand means (using baseline indices 125:240)
- GM22pow3_21_bsl = bslcorrWAMat_percent(GM22pow3_21, 75:225);
- GM22pow3_22_bsl = bslcorrWAMat_percent(GM22pow3_22, 75:225);
- GM22pow3_23_bsl = bslcorrWAMat_percent(GM22pow3_23, 75:225);
- GM22pow3_24_bsl = bslcorrWAMat_percent(GM22pow3_24, 75:225);
- % %save as at files for emegs
- % SaveAvgFile('GM22powAlpha_21_alpha_bsl.at',GM22pow3_21,[],[], 1,[],[],[],[],1)
- % SaveAvgFile('GM22powAlpha_22_alpha_bsl.at',GM22pow3_22,[],[], 1,[],[],[],[],1)
- % SaveAvgFile('GM22powAlpha_23_alpha_bsl.at',GM22pow3_23,[],[], 1,[],[],[],[],1)
- % SaveAvgFile('GM22powAlpha_24_alpha_bsl.at',GM22pow3_24,[],[], 1,[],[],[],[],1)
- % Plot baseline-corrected contoursfor alpha frequencies
- figure
- % faxisindex = 6:18;
- faxisindex = 8;
- sensor = 75;%
- subplot(4,1,1), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_21_bsl(sensor,50:end-50,faxisindex))')%, colorbar%, caxis([-15 100])
- subplot(4,1,2), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_22_bsl(sensor,50:end-50,faxisindex))')%, colorbar%, caxis([-15 100])
- subplot(4,1,3), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_23_bsl(sensor,50:end-50,faxisindex))')%, colorbar%, caxis([-15 100])
- subplot(4,1,4), contourf(taxis(50:end-50), faxis(faxisindex), squeeze(GM22pow3_24_bsl(sensor,50:end-50,faxisindex))')%, colorbar%, caxis([-15 100])
- sgtitle(['Average Power by Condition: Sensor ' num2str(sensor)])
- time = 1050:1125;
- %plot alpha differences by condition over time
- figure
- plot(taxis(time), squeeze(GM22pow3_21_bsl(75, time)))
- hold on
- plot(taxis(time), squeeze(GM22pow3_22_bsl(75, time)))
- plot(taxis(time), squeeze(GM22pow3_23_bsl(75, time)))
- plot(taxis(time), squeeze(GM22pow3_24_bsl(75, time)))
- %% we used ttest3d to easily obtain 4-D arrays
- % [ttestmat21_22, ~, mat4d22] = ttest3d(filematpow21, filematpow22, 1, []);
- % [ttestmat21_23, ~, mat4d23] = ttest3d(filematpow21, filematpow23, 1, []);
- % [ttestmat21_24, mat4d21, mat4d24] = ttest3d(filematpow21, filematpow24, 1, []);
- %load in 4-d arrays
- load('mat4d21_csplus.mat')
- load('mat4d22_gs1.mat')
- load('mat4d23_gs2.mat')
- load('mat4d24_gs3.mat')
- repeatmat_alpha = cat(5, mat4d21(:, 1:10:end, :, :), mat4d22(:, 1:10:end, :, :), mat4d23(:, 1:10:end, :, :), mat4d24(:, 1:10:end, :, :));
- [ttestmat21_22, ~, mat4d22_bsl] = ttest3d(filematpow21, filematpow22, 1, [75:225]);
- [ttestmat21_23, ~, mat4d23_bsl] = ttest3d(filematpow21, filematpow23, 1, [75:225]);
- [ttestmat21_24, mat4d21_bsl, mat4d24_bsl] = ttest3d(filematpow21, filematpow24, 1, [75:225]);
- repeatmat_alpha_bsl = cat(5, mat4d21_bsl(:, 1:10:end, :, :), mat4d22_bsl(:, 1:10:end, :, :), mat4d23_bsl(:, 1:10:end, :, :), mat4d24_bsl(:, 1:10:end, :, :));
- % F test across time for the alpha band (averaging across 25 frequencies)
- for time = 1:180
- for frequency = 1:25
- [Fcontmat_linearWavelet(:, time, frequency),rcontmat,~,MScs, dfcs]=contrast_rep_sign(squeeze(repeatmat_alpha(:, time, frequency, :, :)),[-2 -1 1 2]);
- [Fcontmat_CSselectWavelet(:, time, frequency),rcontmat,MScont,MScs, dfcs]=contrast_rep_sign(squeeze(repeatmat_alpha(:, time, frequency, :, :)),[-3 1 1 1]);
- end
- if mod(time,100)==0, fprintf('.'); end
- end
- % Plot F-test results for alpha at selected sensors
- figure
- contourf(taxis(1:10:end), faxis, squeeze(Fcontmat_CSselectWavelet(72,:,:))'), colorbar
- title('F tests for alpha - Sensor 72')
- figure
- plot(taxis(1:10:end), Fcontmat_CSselectWavelet(72,:,8))
- title('F tests for alpha - Sensor 72')
- % Decimate and average data for further alpha statistics
- % first, we out the data into an array to have an easier time
- % to make this happen, we decimate the time dimension and the frequemcy
- % dimension
- mat4d4stats = squeeze(cat(5, mat4d21(:,1:10:1800,8,:), ...
- mat4d22(:,1:10:1800,8,:), ...
- mat4d23(:,1:10:1800,8,:), ...
- mat4d24(:,1:10:1800,8,:)));
- % from 550- to 1300 sample points is 500 post stimulus to 2000 ms post
- % stimulus
- % in decimated points that is 55 to 130
- outmat4statsalpha = squeeze(mean(mean(mat4d4stats([75 62 55 81 72],55:130,:,:))));
- %% do the bayesian bootstrap for Alpha Power;
- % uses the repeatmat
- linearBootstrap =[];
- size(repeatmat_alpha)
- nsubjects = size(repeatmat_alpha, 4);
- % make distributions of effects
- lineareffect = [-2 -1 1 2]; %expect this direction of effect
- % the linear effect distribution
- for draw = 1:2000
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- for elec = 1:size(repeatmat_alpha,1)
- for timepoint = 1:size(repeatmat_alpha,2)
- for frequency = 1:size(repeatmat_alpha,3)
- linearBootstrap(elec, timepoint, frequency, draw) = ...
- mean(squeeze(repeatmat_alpha(elec, timepoint, frequency, bootstrapvec, : ))) * lineareffect';
- end
- end
- end
- disp(['draw ', num2str(draw)])
- end
- %%
- % the null distribution permutation
- linearBootstrapPerm = [];
- for perm = 1:2000
- repeatmat_alphaperm = repeatmat_alpha;
- for subject = 1:nsubjects
- repeatmat_alphaperm(:, :, :, subject, :) = repeatmat_alphaperm(:, :, :, subject, randperm(4));
- end
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- for elec = 1:size(repeatmat_alpha,1)
- for timepoint = 1:size(repeatmat_alpha,2)
- for frequency = 1:size(repeatmat_alpha,3)
- linearBootstrapPerm(elec, timepoint, frequency, perm) = ...
- mean(squeeze(repeatmat_alphaperm(elec,timepoint, frequency, bootstrapvec, : ))) * lineareffect';
- end
- end
- end
- disp(['permutation ', num2str(perm)])
- end
- %% comparison between wavelet and permuted values
- % BFmap_alpha results in 129 channels x 180 timepoints x 25 frequencies
- for elec = 1:size(repeatmat_alpha,1)
- for timepoint = 1:size(repeatmat_alpha,2) %180 timepoints, decimated earlier
- for frequency = 1:size(repeatmat_alpha,3) %25 frequencies, decimated earlier (8th is alpha)
- BFmap_alpha(elec, timepoint, frequency) = bootstrap2BF_z(squeeze(linearBootstrap(elec,timepoint, frequency, :)), ...
- squeeze(linearBootstrapPerm(elec,timepoint, frequency, :)), 0);
- end
- end
- disp(['elec', num2str(elec)])
- end
- %%
- plot(BFmap_alpha(75,:,8)) %faxis shows alpha is now 8th in 3rd dimension
- %[75 62 55 81 72]
- %%
- alphaBF = BFmap_alpha(:,:,8);
- SaveAvgFile('alphaBF.at', alphaBF, [], [],1,[],[],[],[],1)
- emegs2d
- %% do the bayesian bootstrap for Alpha Power - selective pattern;
- % uses the repeatmat
- selectBootstrap_alpha =[];
- size(repeatmat_alpha)
- nsubjects = size(repeatmat_alpha, 4);
- % make distributions of effects
- selecteffect = [-3 1 1 1]; %expect this direction of effect
- % the linear effect distribution
- for draw = 1:2000
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- for elec = 1:size(repeatmat_alpha,1)
- for timepoint = 1:size(repeatmat_alpha,2)
- for frequency = 1:size(repeatmat_alpha,3)
- selectBootstrap_alpha(elec, timepoint, frequency, draw) = ...
- mean(squeeze(repeatmat_alpha(elec, timepoint, frequency, bootstrapvec, : ))) * selecteffect';
- end
- end
- end
- disp(['draw ', num2str(draw)])
- end
- %% the null distribution permutation
- selectBootstrapPerm_alpha = [];
- for perm = 1:2000
- repeatmat_alphaperm = repeatmat_alpha;
- for subject = 1:nsubjects
- repeatmat_alphaperm(:, :, :, subject, :) = repeatmat_alphaperm(:, :, :, subject, randperm(4));
- end
- bootstrapvec = randi(nsubjects, 1,nsubjects)';
- for elec = 1:size(repeatmat_alpha,1)
- for timepoint = 1:size(repeatmat_alpha,2)
- for frequency = 1:size(repeatmat_alpha,3)
- selectBootstrapPerm_alpha(elec, timepoint, frequency, perm) = ...
- mean(squeeze(repeatmat_alphaperm(elec,timepoint, frequency, bootstrapvec, : ))) * selecteffect';
- end
- end
- end
- disp(['permutation ', num2str(perm)])
- end
- %% comparison between wavelet and permuted values
- % BFmap_alpha results in 129 channels x 180 timepoints x 25 frequencies
- for elec = 1:size(repeatmat_alpha,1)
- for timepoint = 1:size(repeatmat_alpha,2) %180 timepoints, decimated earlier
- for frequency = 1:size(repeatmat_alpha,3) %25 frequencies, decimated earlier (8th is alpha)
- BFmap_alpha_select(elec, timepoint, frequency) = bootstrap2BF_z(squeeze(selectBootstrap(elec,timepoint, frequency, :)), ...
- squeeze(selectBootstrapPerm_alpha(elec,timepoint, frequency, :)), 0);
- end
- end
- disp(['elec', num2str(elec)])
- end
- linear = ReadAvgFile('Log10TypicalLinearBFs.at');
- antilinear = ReadAvgFile('Log10AntiLinearBFs.at');
- antiallnothing = ReadAvgFile('Log10allnothingBFs.at');
- allnothing = antiallnothing* -1;
- SaveAvgFile('Log10allnothingBF_typical.at',allnothing,[],[], ...
- [],[],[],[],[],[],[],[],[],[],[])
- early_bfmap_linear = squeeze(mean(linear (75, 30:65), 2))
- middle_bfmap_linear = squeeze(mean(linear(75, 65:95), 2))
- late_bfmap_linear = squeeze(mean(linear (75, 95:130), 2))
- % antilinear : [129 × 180] matrix of log10 Bayes factors
- % (129 electrodes, 180 decimated time-samples)
- %% Channel 70/75, three time windows; BFs
- % early_bfmap_linear = mean(linear(75, 31:63)) % 0–660 ms
- % middle_bfmap_linear = mean(linear(75, 64:97)) % 670–1330 ms
- % late_bfmap_linear = mean(linear(75, 98:130)) % 1340–2000 ms
- early_bfmap_allnothing = mean(allnothing(70, 30:65)) % ~0–700 ms
- middle_bfmap_allnothing = mean(allnothing(70, 65:95)) % ~700–1300 ms
- late_bfmap_allnothing = mean(allnothing(70, 95:130)) % ~1300–2000 ms
- %%
- alphaBF_select = BFmap_alpha_select(:,:,8);
- SaveAvgFile('alphaBF_select.at', alphaBF_select, [], [],1,[],[],[],[],1)
- emegs2d
ggtone_postpro_final.m, no license · at the source
Overview
- Department of Psychology, University of Florida,Gainesville, FL USA
- Laboratory for Brain, Body, and Behavior, Department of Psychology, University of Florida,Gainesville, USA
- Department of Psychology, University of Bremen,Bremen, Germany
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 2 matches between paragraphs and lines of code.
OSF qr37b
Availability: 1 check, the latest on 29 September 2026: the link answers (HTTP 200)
- 29 September 2026: the link answers (HTTP 200)
2 files
- Code/
experimentsetup.m , MATLAB, 957 lines - Code/
ggtone_postpro_final.m , MATLAB, 845 lines, 2 matches
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 qr37b
- it says that the code is available on request
Read it in the paper: doi.org/10.1038/s41598-026-45966-4.
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;
- 2 scripts, each with its path and the digest of its content;
- 2 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/s41598-026-45966-4.
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, 29 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 7 keywords, 11 MeSH terms, 1 funder, 55 references.
Cite
This paper
Gardy, S. M., Panitz, C., Engle, H., Gilbert, F., & Keil, A. (2026). Changes in visuocortical engagement and oscillatory brain activity during associative learning. Scientific reports, 16(1), 16766. https://
BibTeX
@article{gardy2026change
author = {Gardy, Sarah M. and Panitz, Christian and Engle, Hannah and Gilbert, Faith and Keil, Andreas},
title = {{Changes in visuocortical engagement and oscillatory brain activity during associative learning}},
journal = {Scientific reports},
year = {2026},
month = apr,
volume = {16},
number = {1},
pages = {16766},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/
url = {https://
pmid = {41957439},
pmcid = {PMC13223303}
}
RIS
TY - JOUR
AU - Gardy, Sarah M.
AU - Panitz, Christian
AU - Engle, Hannah
AU - Gilbert, Faith
AU - Keil, Andreas
TI - Changes in visuocortical engagement and oscillatory brain activity during associative learning
T2 - Scientific reports
J2 - Sci Rep
PY - 2026
DA - 2026/
VL - 16
IS - 1
SP - 16766
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Changes in visuocortical engagement and oscillatory brain activity during associative learning",
"container-title": "Scientific reports",
"author": [
{
"family": "Gardy",
"given": "Sarah M."
},
{
"family": "Panitz",
"given": "Christian"
},
{
"family": "Engle",
"given": "Hannah"
},
{
"family": "Gilbert",
"given": "Faith"
},
{
"family": "Keil",
"given": "Andreas"
}
],
"container-title-short":
"volume": "16",
"issue": "1",
"page": "16766",
"DOI": "10.1038/
"PMID": "41957439",
"PMCID": "PMC13223303",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
9
]
]
}
}
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.1152/jn.00288.2025 [code]
- The contribution of the koniocellular visual pathway to aversive learning in human visual cortex.Journal: Journal of neurophysiologyIn common: EEG, 5 references
- [2] doi:10.7554/elife.108017 [code]
- Visual working memory guides attention rhythmically in humans.Journal: eLifeIn common: Psychtoolbox, 3 references
- [3] doi:10.3389/fpsyg.2026.1819517 [code]
- Development and validation of the performance evaluation anxiety task: a computerized task to identify functionally significant test anxiety.Journal: Frontiers in psychologyIn common: EEG, 4 references
- [4] doi:10.1162/imag.a.1335 [code]
- Functionally distinct alpha components are differentially modulated by attention and affect behavior.Journal: Imaging neuroscience (Cambridge, Mass.)In common: 4 references
- [5] doi:10.1162/imag.a.1258 [code]
- Non-specific increase in alpha power during a neurofeedback session targeting its downregulation.Journal: Imaging neuroscience (Cambridge, Mass.)In common: Psychtoolbox, EEG, 2 references
- [6] doi:10.1162/imag.a.1206
- Affective face biases in visual and prefrontal cortex measured with visual entrainment.Journal: Imaging neuroscience (Cambridge, Mass.)In common: 3 references
- [7] doi:10.7554/elife.106050
- Cross-modal interaction of human alpha activity does not reflect inhibition of early sensory processing in a frequency-tagging study using EEG and MEG.Journal: eLifeIn common: EEG, 3 references
- [8] doi:10.1126/sciadv.aea3919 [code]
- Hierarchical brain dynamics supporting visual perceptual transitions.Journal: Science advancesIn common: Psychtoolbox, 2 references
- [9] doi:10.7554/elife.103689 [code]
- Dissociable dynamic effects of expectation during statistical learning.Journal: eLifeIn common: Psychtoolbox, EEG, 1 reference
- [10] doi:10.1162/imag.a.1034 [code]
- Top-down selection of visual working memory contents is supported by alpha-band phase-synchronized oscillatory networksJournal: n/aIn common: 3 references
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, 2 scripts, and 2 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:c51576487d2117f3…
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.
