Multivariate Pattern Analysis Identifies Potential Intertrial Resting-State EEG Biomarkers in Fibromyalgia.
2 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 2 matches
- [1] § Materials and Methods › Paradigm and Data Acquisition › EEG Data Acquisition and Preprocessing ↔ eegPreproc.m, lines 375 to 418 · score 0.68 · pop_eegfiltnew, Independent Component, preprocessing, filtered, event, rejection · block
oscr:b:ZGW1PBZQTZWTT-P· Report a mismatch - [2] § Materials and Methods › Paradigm and Data Acquisition › EEG Data Acquisition and Preprocessing ↔ unfoldERPData.m, lines 39 to 163 · score 0.63 · voltage thresholds, artifacts, filtered, event, rejection, stimuli · block
oscr:b:ANBCSEYGG4F7P-D· Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
MATLAB · 898 lines · 37 KB · MIT · 1 match
- %
- % This script processes EEG data exported from BrainVision in .dat or .eeg format
- % to MVPAlab format. It requires corresponding .vhdr, .dat/.eeg, and .vmrk files for.
- % The script can handle segmented data and allows the user to specify various
- % cleaning and preprocessing steps, including channel removal, resampling,
- % filtering, epoching, baseline correction, ICA, interpolation, and more.
- % The final data can be saved in .set (EEGLAB format), .mat (MATLAB format), or both.
- %
- % If channel coordinates are detected to be missing, the user can load them
- % from a BrainVision .bvef or .vhdr file, or use layouts present in EEGLAB or
- % FieldTrip source files. This requires the additional eegImportChanlocs.m
- % script available in the same github repository.
- %
- % Once the data is saved in either .set or .mat it can be inputed once
- % again into the script to perform additional steps if needed.
- %
- % The script performs the following steps:
- % 1. Prompts the user to select cleaning steps.
- % 2. Prompts the user for necessary parameters for the selected steps.
- % 3. Selects files for processing.
- % 4. Processes each selected file according to the specified steps.
- % 5. Saves the processed data in the specified format.
- %
- % Note: If ICA and/or automatic rejection are selected, a checkpoint save
- % will be created in the selected format for each one before rejecting
- % components/trials.
- %
- % Ensure you have EEGLAB installed and added to the MATLAB path.
- %
- % Author: Dino Soldic
- % Email: [email hidden]
- % Date: 2026-04-24
- %
- % See also: eegPlotERP
- %% Clean Matlab
- clear; clc;
- %% Ask user for parameters
- cleanoptions = {'Resample', 'Single EEG filter', 'Multi EEG filter', 'ERP epoch data', 'RS epoch data', 'Correct baseline', 'Reject with ICA', ...
- 'Interpolate', 'Reject voltage outliers', 'Reject abnormal spectra', 'Re-reference', 'Plot ERPs', 'Transform to Fieldtrip', ...
- 'Transform to LORETA (RS)', 'Transform to BV'};
- [cleanselection, ~] = listdlg('ListString', cleanoptions, 'PromptString', 'Select cleaning steps:', 'SelectionMode', 'multiple');
- if isempty(cleanselection), fprintf('Operation canceled. Shutting down\n'); return, end
- if any(cleanselection == 1)
- % Enter new fsample
- resampleValue = inputdlg('Enter new sampling frequency', 'Sampling Frequency', 1, "250");
- resampleValue = str2double(resampleValue);
- if isempty(resampleValue) || any(isnan(resampleValue))
- fprintf('Enter valid numeric value. Shutting down\n');
- return
- end
- end
- if any(cleanselection == 2)
- % Prompt filter type
- filterTypeOptions = {'Low-pass', 'High-pass', 'Pass band', 'Notch'};
- [filterType, ~] = listdlg('ListString', filterTypeOptions, 'PromptString', {'Select the filter that you want to', 'apply to your EEG data:'}, 'SelectionMode', 'single');
- if isempty(filterType), fprintf('Operation canceled. Shutting down\n'); return, end
- doNotchFilter = false;
- while true
- % Enter filter freq value
- switch filterType
- case 1
- filterVal = inputdlg('Enter frequency cutoff (Hz)', 'Low-Pass Filter', 1)';
- filterVal = str2double(filterVal);
- filterValues.low = [];
- filterValues.high = filterVal;
- case 2
- filterVal = inputdlg('Enter frequency cutoff (Hz)', 'High-Pass Filter', 1)';
- filterVal = str2double(filterVal);
- filterValues.low = filterVal;
- filterValues.high = [];
- case 3
- filterVal = inputdlg({'Enter low frequency cutoff (Hz)', 'Enter high frequency cutoff (Hz)'}, 'Pass Band Filter', 1)';
- filterVal = str2double(filterVal);
- filterValues.low = filterVal(1);
- filterValues.high = filterVal(2);
- case 4
- filterVal = inputdlg({'Enter low frequency cutoff (Hz)', 'Enter high frequency cutoff (Hz)'}, 'Notch Filter', 1)';
- filterVal = str2double(filterVal);
- filterValues.low = filterVal(1);
- filterValues.high = filterVal(2);
- doNotchFilter = true;
- end
- % Check values
- if ~isnumeric(filterVal) || any(isnan(filterVal)) || isempty(filterVal) || any(filterVal < 0)
- fprintf('Enter valid values for filtering\n');
- else
- break
- end
- end
- end
- if any(cleanselection == 6)
- baselineThreshold = inputdlg({'Enter baseline correction start point in milliseconds (ms)', 'Enter baseline correction end point in milliseconds (ms)'}, 'Baseline Correction', 1, {'-200', '0'});
- baselineThreshold = str2double(baselineThreshold);
- if isempty(baselineThreshold) || any(isnan(baselineThreshold))
- fprintf('Enter valid numeric value. Shutting down\n');
- return
- end
- end
- if any(cleanselection == 7)
- icaTypeOptions = {'runica', 'SOBI'};
- [icaType, ~] = listdlg('ListString', icaTypeOptions, 'PromptString', {'Select the ICA algorithm that you', 'want to apply to your EEG data:'}, 'SelectionMode', 'single');
- if isempty(icaType), fprintf('Operation canceled. Shutting down\n'); return, end
- end
- if any(cleanselection == 9)
- amplitudeThreshold = inputdlg('Enter maximum voltage threshold for automatic voltage epoch rejection', 'Voltage Threshold', 1, "75");
- amplitudeThreshold = str2double(amplitudeThreshold);
- if isempty(amplitudeThreshold) || isnan(amplitudeThreshold)
- fprintf('Enter valid numeric value. Shutting down\n');
- return
- end
- end
- if any(cleanselection == 10)
- rejSpecSettings = cell(1);
- spectraIdx = 1;
- while true
- while true
- % Set spectrum settings
- spectraOptions = {'Enter power rejection threshold (dB)', ...
- 'Enter low frequency limit (Hz)', 'Enter high frequency limit (Hz)'};
- rejSpecValues = inputdlg(spectraOptions, 'Spectra Thresholds', 1, {'50', '0', '2'});
- rejSpecValues = str2double(rejSpecValues);
- % Check values
- if isempty(rejSpecValues) || any(isnan(rejSpecValues))
- fprintf('Enter valid values for epoching\n');
- else
- break
- end
- end
- % Save values to cell
- rejSpecSettings{spectraIdx} = rejSpecValues;
- spectraIdx = spectraIdx + 1;
- % Prompt to redo spectra with other options
- addSpectra = questdlg('Do you wish to add more spectra reject options?', 'Reject spectra', 'Yes', 'No', 'No');
- if strcmpi(addSpectra, 'no'), break, end
- end
- end
- % Select files to load
- [loadfiles, loadpath] = uigetfile({'*.vhdr;*.ahdr', 'Brain Vision files (*.vhdr, *.ahdr)'; '*.mat;*.set', 'MATLAB-EEGLAB files (*.mat, *.set)'}, 'Select files with raw EEG data to load', 'MultiSelect', 'on');
- if loadpath == 0, fprintf('Operation canceled. Shutting down\n'); return, end
- filelist = fullfile(loadpath, loadfiles);
- if ~iscell(filelist), filelist = {filelist}; end
- % Define savepath
- rawSavepath = uigetdir(pwd, 'Select path to save the data');
- if rawSavepath == 0, fprintf('Operation canceled. Shutting down\n'); return, end
- % make mat ft folder if selected
- if any(cleanselection == 13)
- % Set save path
- savepath_ft = fullfile(rawSavepath, 'ft_mat_files');
- % Check folder
- if ~exist(savepath_ft, 'dir'), mkdir(savepath_ft); end
- end
- % Prompt save format
- saveformat = questdlg('Do you want to save as .set (EEGLAB dataset), .mat (MATLAB data) file or both?', 'Choose format', 'set', 'mat', 'both', 'mat');
- % Check the user's response
- if strcmpi(saveformat, 'set')
- fprintf('Data will be saved as .set file.\n');
- % Set save path
- savepath_set = fullfile(rawSavepath, 'set_files');
- icaSaveFolderPath = fullfile(savepath_set, 'preIca');
- rejSaveFolderPath = fullfile(savepath_set, 'preRej');
- % Check folder
- if ~exist(savepath_set, 'dir'), mkdir(savepath_set); end
- if ~exist(icaSaveFolderPath, 'dir'), mkdir(icaSaveFolderPath); end
- if ~exist(rejSaveFolderPath, 'dir'), mkdir(rejSaveFolderPath); end
- % Update the savepath
- savepath = savepath_set;
- elseif strcmpi(saveformat, 'mat')
- fprintf('Data will be saved as .mat file.\n');
- % Set save path
- savepath_mat = fullfile(rawSavepath, 'mat_files');
- icaSaveFolderPath = fullfile(savepath_mat, 'preIca');
- rejSaveFolderPath = fullfile(savepath_mat, 'preRej');
- % Check folder
- if ~exist(savepath_mat, 'dir'), mkdir(savepath_mat); end
- if ~exist(icaSaveFolderPath, 'dir'), mkdir(icaSaveFolderPath); end
- if ~exist(rejSaveFolderPath, 'dir'), mkdir(rejSaveFolderPath); end
- % Update savepath
- savepath = savepath_mat;
- elseif strcmpi(saveformat, 'both')
- fprintf('Data will be saved as both .set and .mat file.\n');
- % Set save path
- savepath_mat = fullfile(rawSavepath, 'mat_files');
- savepath_set = fullfile(rawSavepath, 'set_files');
- % Update savepath
- savepath = struct();
- icaSaveFolderPath = struct();
- rejSaveFolderPath = struct();
- savepath.mat = savepath_mat;
- savepath.set = savepath_set;
- icaSaveFolderPath.mat = fullfile(savepath.mat, 'preIca');
- icaSaveFolderPath.set = fullfile(savepath.set, 'preIca');
- rejSaveFolderPath.mat = fullfile(savepath.mat, 'preRej');
- rejSaveFolderPath.set = fullfile(savepath.set, 'preRej');
- % Check folder
- if ~exist(savepath.mat, 'dir'), mkdir(savepath.mat); end
- if ~exist(icaSaveFolderPath.mat, 'dir'), mkdir(icaSaveFolderPath.mat); end
- if ~exist(rejSaveFolderPath.mat, 'dir'), mkdir(rejSaveFolderPath.mat); end
- if ~exist(savepath.set, 'dir'), mkdir(savepath.set); end
- if ~exist(icaSaveFolderPath.set, 'dir'), mkdir(icaSaveFolderPath.set); end
- if ~exist(rejSaveFolderPath.set, 'dir'), mkdir(rejSaveFolderPath.set); end
- end
- % set warning for missing chanlocs
- warnMissChan = true;
- % disable new eeglab version check to run faster
- eeglab('nogui');
- pop_editoptions('option_checkversion', false);
- %% Process data
- while true
- for i = 1:numel(filelist)
- try
- %% Load data
- % Get the file
- file = filelist{i};
- % Get filename to save it later
- [ogFolderpath, ogfilename, ogExtension] = fileparts(file);
- fileNameSave = ogfilename;
- % Run EEGlab in the background and call it again for each iteration
- % so it clears previous unnecesary data.
- eeglab;
- close all
- % Load EEG data from .vhdr or .ahdr file or other
- if strcmp(ogExtension, '.vhdr') || strcmp(ogExtension, '.ahdr')
- EEG = pop_loadbv(ogFolderpath, [ogfilename, ogExtension], [], []);
- else
- EEG = pop_loadset(file);
- end
- % Check chanlocs
- if warnMissChan
- isChanLocsEmpty = isempty([EEG.chanlocs.X]) || isempty([EEG.chanlocs.Y]) || isempty([EEG.chanlocs.Z]) || isempty([EEG.chanlocs.theta]);
- if isChanLocsEmpty
- doLoadCoords = questdlg('The coordinates for your channels/electrodes are missing. Do you wish to load a file with their coordinates?', 'Missing Coordinates', 'Yes', 'No', 'Yes');
- % get file and extension
- if strcmp(doLoadCoords, 'Yes')
- [chanlocsFile, chanlocsDir] = uigetfile('*.*', 'Select file containing EEG layout', 'MultiSelect', 'off');
- chanlocsPath = fullfile(chanlocsDir, chanlocsFile);
- [~, ~, chanlocsExt] = fileparts(chanlocsPath);
- end
- end
- warnMissChan = false;
- end
- % import chanlocs
- if exist('doLoadCoords', 'var')
- if strcmp(doLoadCoords, 'Yes')
- while true
- try
- fprintf('Loading channel coordinates...\n');
- EEG = eegImportChanlocs(EEG, chanlocsPath, chanlocsExt);
- fprintf('Channel coordinates loaded successfully.\n');
- break
- catch
- reChanlocsLoad = questdlg('Channels could not be loaded. Try again?', 'Channel Error', 'Yes', 'No', 'Yes');
- if ~strcmp(reChanlocsLoad, 'Yes'), fprintf('Proceeding without loading channel coordinates...\n'); break, end
- end
- end
- else
- dialToWait = warndlg('The data will be processed without channel locations. Please note that you will not be able to use functions that require channel coordinates, such as "Topoplot".', 'Channel Omission');
- uiwait(dialToWait);
- end
- end
- %% Clean EEG data using EEGLAB functions
- while true
- % Step 1 visualize raw data
- pop_eegplot(EEG, 1, 0, 0); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- % Step 2 Remove channels before cleaning data
- if ~exist('doRemoveChans', 'var')
- doRemoveChans = questdlg('Do you wish to remove channels from your data?', 'Remove Channels', 'Yes', 'No', 'Yes');
- if strcmpi(doRemoveChans, 'yes'), doRemoveChans = true; else, doRemoveChans = false; end
- end
- if doRemoveChans
- if ~exist('selectChansToRemove', 'var')
- [selectChansToRemove, ~] = listdlg('ListString', {EEG.chanlocs.labels}, 'PromptString', 'Select channels to remove:', 'SelectionMode', 'multiple');
- % Find chanlabels from indices
- chansToRemove = {EEG.chanlocs(selectChansToRemove).labels};
- end
- % Use EEGLAB function to remove them
- EEG = pop_select(EEG, 'nochannel', selectChansToRemove);
- % Update EEG
- EEG = eeg_checkset(EEG);
- % Completion msg
- fprintf('Removed channel(s) {%s} from EEG data.\n', strjoin(chansToRemove, ', '));
- else
- fprintf('No channels removed from EEG data.\n');
- end
- % Step 3 Resample
- if any(cleanselection == 1)
- % Resample
- EEG = pop_resample(EEG, resampleValue);
- % Plot
- pop_eegplot(EEG, 1, 0, 0); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- end
- % Step 4 filter data and visualize
- % Single
- if any(cleanselection == 2)
- EEG = pop_eegfiltnew(EEG, 'locutoff', filterValues.low, 'hicutoff', filterValues.high, 'revfilt', doNotchFilter);
- end
- % Multi
- if any(cleanselection == 3)
- while true
- try
- EEG = pop_eegfiltnew(EEG);
- pop_eegplot(EEG, 1, 0, 0); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- catch
- warning('Input at least one value valid numeric value to filter the data.')
- end
- % Ask to filter again
- refilter = questdlg('Do you wish to filter again your data?', 'Filter data', 'Yes', 'No', 'No');
- if strcmpi(refilter, 'No'), break, end
- end
- end
- % Step 5.1 Split data in epochs for ERPs
- if any(cleanselection == 4)
- if ~exist('epochSettings', 'var')
- while true
- % Select stimulus
- selectStimuli = unique({EEG.event.type});
- [epochSettings.stimuli, ~] = listdlg('ListString', selectStimuli, 'PromptString', 'Select Stimuli for Epoch:', 'SelectionMode', 'multiple');
- % Select time window
- epochSettings.time = inputdlg({'Enter epoch start point in seconds (s)', 'Enter epoch end point in seconds (s)'}, 'Split in Epochs', 1)';
- epochSettings.time = str2double(epochSettings.time);
- % init suffix
- % Check values
- if ~isnumeric(epochSettings.time) || any(isnan(epochSettings.time)) || isempty(epochSettings.stimuli) || isempty(epochSettings.time)
- fprintf('Enter valid values for epoching\n');
- else
- break
- end
- end
- end
- % Epoch with eeglab
- EEG = pop_epoch(EEG, selectStimuli(epochSettings.stimuli), epochSettings.time);
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- end
- % Step 5.2 Split data in epochs for RS
- if any(cleanselection == 5)
- if ~exist('epochSettings', 'var')
- while true
- % Select stimulus
- selectStimuli = unique({EEG.event.type});
- [epochSettings.stimuli.start, ~] = listdlg('ListString', selectStimuli, 'PromptString', {'Select start mark for epoching:', ''}, 'SelectionMode', 'single');
- [epochSettings.stimuli.end, ~] = listdlg('ListString', selectStimuli, 'PromptString', {'Select end mark for epoching:', ''}, 'SelectionMode', 'single');
- % Select time window
- epochSettings.time = inputdlg('Enter epoch length in seconds (s)', 'RS Epoch length', 1)';
- epochSettings.time = str2double(epochSettings.time);
- % Check values
- if ~isnumeric(epochSettings.time) || isnan(epochSettings.time) || isempty(epochSettings.stimuli.start) || isempty(epochSettings.stimuli.end) || isempty(epochSettings.time)
- fprintf('Enter valid values for epoching\n');
- else
- break
- end
- end
- end
- % Find start and end for epochs in timepoints
- startEpochTmpt = EEG.event(find(strcmp({EEG.event.type}, selectStimuli(epochSettings.stimuli.start)))).latency;
- endEpochTmpt = EEG.event(find(strcmp({EEG.event.type}, selectStimuli(epochSettings.stimuli.end)))).latency;
- % First raw epoch
- EEG.data = EEG.data(:, startEpochTmpt:endEpochTmpt);
- % Get tmpts/trial
- epochTmpts = EEG.srate * epochSettings.time;
- nEpochs = floor(size(EEG.data, 2) / epochTmpts);
- % Second epoching
- EEG.data = reshape(EEG.data(:, 1:epochTmpts * nEpochs), size(EEG.data, 1), epochTmpts, nEpochs);
- % Fix EEG struct
- EEG.trials = size(EEG.data, 3);
- EEG.pnts = size(EEG.data, 2);
- EEG.xmax = epochSettings.time;
- EEG.times = EEG.times(1:epochTmpts);
- EEG.event = [];
- EEG.urevent = [];
- EEG.eventdescription = {};
- EEG = eeg_checkset(EEG);
- % Plot
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- end
- if ~exist('stimuliLabel', 'var')
- % Enter labels for epoching
- stimuliLabel = inputdlg('Enter label for file''s name', 'Epoch Labels');
- if isempty(stimuliLabel), stimuliLabel = ''; end
- end
- % Change filename for saving
- if isempty(stimuliLabel)
- fileNameSave = ogfilename;
- else
- fileNameSave = [ogfilename, '_', stimuliLabel{:}];
- end
- % Step 6 Correct baseline
- if any(cleanselection == 6)
- EEG = pop_rmbase(EEG, baselineThreshold');
- end
- % step 7(8) Remove bad channel
- if any(cleanselection == 8)
- chansToInterpolate = [];
- while true
- if ~exist('doRemoveBadChans', 'var')
- doRemoveBadChans = questdlg('Do you wish to interpolate any channels?', 'Interpolate Channels', 'Yes', 'No', 'Yes');
- if strcmpi(doRemoveBadChans, 'yes'), doRemoveBadChans = true; else, doRemoveBadChans = false; end
- end
- if ~doRemoveBadChans
- fprintf('No channels to interpolate.\n');
- break;
- end
- [selectBadChansToRemove, ~] = listdlg('ListString', {EEG.chanlocs.labels}, 'PromptString', 'Select channels to remove:', 'SelectionMode', 'multiple');
- % update chanm to interpo idx on each iteration
- chansToInterpolate = [chansToInterpolate, selectBadChansToRemove]; %#ok<AGROW>
- % Find chanlabels from indices
- chansToRemoveLabel = {EEG.chanlocs(selectBadChansToRemove).labels};
- % Update EEG
- EEG = eeg_checkset(EEG);
- % Completion msg
- fprintf('Channel(s) {%s} will be interpolated.\n', strjoin(chansToRemoveLabel, ', '));
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- % Ask to interpolate again
- interpochan = questdlg('Do you wish to interpolate more channels?', 'Interpolation', 'Yes', 'No', 'No');
- if strcmpi(interpochan, 'No'), break, end
- end
- end
- % Step 7(11) Re-reference before ICA following eeglab suggestion
- if any(cleanselection == 11)
- if ~exist('trialRef', 'var')
- while true
- trialRef = questdlg('How do you wish to re-reference the data?', 'Re-reference', 'Average', 'Channel', 'Average');
- if strcmpi(trialRef, 'channel')
- % Select channel for ref
- chanlabels = {EEG.chanlocs.labels};
- [rerefChan, ~] = listdlg('ListString', chanlabels, 'PromptString', 'Select channel for Re-reference:', 'SelectionMode', 'single');
- % Check input
- if isempty(rerefChan), fprintf('Select a valid channel.\n'), else, break, end
- end
- % Check input
- if isempty(trialRef), fprintf('Select an option.\n'), else, break, end
- end
- end
- % Re-ref func
- if strcmpi(trialRef, 'average')
- EEG = pop_reref(EEG, [], 'exclude', chansToInterpolate);
- fprintf('Computing average reference of the data.\n');
- elseif strcmpi(trialRef, 'channel')
- EEG = pop_reref(EEG, rerefChan, 'exclude', chansToInterpolate);
- fprintf('Referencing data to channel "%s".\n', EEG.chanlocs(rerefChan).labels);
- end
- end
- % Step 7 run ICA
- if any(cleanselection == 7)
- while true
- try
- switch icaType
- case 1
- EEG = pop_runica(EEG, 'icatype', 'runica', 'extended', 1, 'interrupt', 'off', 'chanind', setdiff(1:EEG.nbchan, chansToInterpolate));
- case 2
- EEG = pop_runica(EEG, 'icatype', 'sobi', 'chanind', setdiff(1:EEG.nbchan, chansToInterpolate));
- end
- break
- catch
- opts = struct('WindowStyle', 'non-modal', 'Interpreter', 'tex');
- errordlg('\color{red} \fontsize{13} ICA was interrupted. Running again', 'ICA Error', opts);
- end
- end
- % Review and label ICA components
- EEG = iclabel(EEG, 'default');
- pop_viewprops(EEG, 0);
- if ~isempty(findall(0, 'Type', 'figure'))
- uiwait(gcf);
- close all
- end
- % Save checkpoint
- EEG.comments = [];
- if strcmpi(saveformat, 'mat')
- save(fullfile(icaSaveFolderPath, fileNameSave), 'EEG');
- elseif strcmpi(saveformat, 'set')
- EEG = pop_saveset(EEG, char(fileNameSave), char(icaSaveFolderPath), 'savemode', 'onefile');
- elseif strcmpi(saveformat, 'both')
- save(fullfile(icaSaveFolderPath.mat, fileNameSave), 'EEG');
- EEG = pop_saveset(EEG, char(fileNameSave), char(icaSaveFolderPath.set), 'savemode', 'onefile');
- end
- % IC Artifact Rejection
- while true
- EEG = pop_selectcomps(EEG); % Manually inspect and select
- if ~isempty(findall(0, 'Type', 'figure'))
- uiwait(gcf);
- close all
- end
- EEG = pop_subcomp(EEG, [], 1, 0); % Remove components from data
- EEG = eeg_checkset(EEG);
- % Plot channel data
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- % Ask to reject componentes again
- reICA = questdlg('Do you wish to reject ICA components once more?', 'Reject ICA', 'Yes', 'No', 'No');
- if strcmpi(reICA, 'No'), break, end
- end
- end
- % Step 8 Interpolate bad channels if necessary
- if any(cleanselection == 8)
- EEG = pop_interp(EEG, chansToInterpolate);
- end
- % Step 9 Auto Reject abnormal voltage epochs
- if any(cleanselection == 9)
- % Save checkpoint
- EEG.comments = [];
- if strcmpi(saveformat, 'mat')
- save(fullfile(rejSaveFolderPath, fileNameSave), 'EEG');
- elseif strcmpi(saveformat, 'set')
- EEG = pop_saveset(EEG, char(fileNameSave), char(rejSaveFolderPath), 'savemode', 'onefile');
- elseif strcmpi(saveformat, 'both')
- save(fullfile(rejSaveFolderPath.mat, fileNameSave), 'EEG');
- EEG = pop_saveset(EEG, char(fileNameSave), char(rejSaveFolderPath.set), 'savemode', 'onefile');
- end
- % Mark trials to reject
- EEG = pop_eegthresh(EEG, 1, 1:length(EEG.chanlocs), -abs(amplitudeThreshold), abs(amplitudeThreshold), EEG.times(1) / 1000, EEG.times(end) / 1000, 1, 0);
- % Update thresholds
- if ~isempty(EEG.reject.rejmanual)
- EEG.reject.rejmanual = EEG.reject.rejmanual | EEG.reject.rejthresh;
- EEG.reject.rejmanualE = EEG.reject.rejmanualE | EEG.reject.rejthreshE;
- else
- EEG.reject.rejmanual = EEG.reject.rejthresh;
- EEG.reject.rejmanualE = EEG.reject.rejthreshE;
- end
- % Decide epoch rej
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- end
- % Step 10 Auto reject abnormal spectra
- if any(cleanselection == 10)
- % Save checkpoint
- if ~any(cleanselection == 8)
- EEG.comments = [];
- if strcmpi(saveformat, 'mat')
- save(fullfile(rejSaveFolderPath, fileNameSave), 'EEG');
- elseif strcmpi(saveformat, 'set')
- EEG = pop_saveset(EEG, char(fileNameSave), char(rejSaveFolderPath), 'savemode', 'onefile');
- elseif strcmpi(saveformat, 'both')
- save(fullfile(rejSaveFolderPath.mat, fileNameSave), 'EEG');
- EEG = pop_saveset(EEG, char(fileNameSave), char(rejSaveFolderPath.set), 'savemode', 'onefile');
- end
- end
- % Mark trials to reject
- for spectraIdx = 1:numel(rejSpecSettings)
- rejSpecSettingsFunc = rejSpecSettings{spectraIdx};
- EEG = pop_rejspec(EEG, 1, 'elecrange', 1:length(EEG.chanlocs), 'method', 'fft', ...
- 'threshold', [-abs(rejSpecSettingsFunc(1)) abs(rejSpecSettingsFunc(1))], ...
- 'freqlimits', [rejSpecSettingsFunc(2), rejSpecSettingsFunc(3)], ...
- 'eegplotreject', 0, 'eegplotplotallrej', 1);
- % Update thresholds
- if ~isempty(EEG.reject.rejmanual)
- EEG.reject.rejmanual = EEG.reject.rejmanual | EEG.reject.rejfreq;
- EEG.reject.rejmanualE = EEG.reject.rejmanualE | EEG.reject.rejfreqE;
- else
- EEG.reject.rejmanual = EEG.reject.rejfreq;
- EEG.reject.rejmanualE = EEG.reject.rejfreqE;
- end
- % Decide epoch rej
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- end
- end
- % Step 11 Re-reference again after ICA
- if any(cleanselection == 11)
- % Re-ref func
- if strcmpi(trialRef, 'average')
- EEG = pop_reref(EEG, []);
- fprintf('Computing average reference of the data.\n');
- elseif strcmpi(trialRef, 'channel')
- EEG = pop_reref(EEG, rerefChan);
- fprintf('Referencing data to channel "%s".\n', EEG.chanlocs(rerefChan).labels);
- end
- end
- % Step 12 final data inspection
- while true
- pop_eegplot(EEG, 1, 1, 1); % [1 channel data or 0 independent components], [1 for channel interpolation, 0 to skip interpolation], [1 to allow manual rejection]
- uiwait(gcf);
- close all
- % Ask to inspect again
- re_rej = questdlg('Do you wish to inspect the data once again?', 'Data Inspection', 'Yes', 'No', 'No');
- if strcmpi(re_rej, 'No'), break, end
- end
- % Step 13 Plot ERPs
- if any(cleanselection == 12)
- topoTitle = sprintf('ERPs for %s', fileNameSave);
- pop_plottopo(EEG, 1:length(EEG.chanlocs), char(topoTitle), 0);
- uiwait(gcf);
- close all
- end
- % Ask to redo all preproc
- redoclean = questdlg('Do you wish to redo data processing or continue?', 'Finish cleaning', 'Redo', 'Finish', 'Finish');
- if ~strcmpi(redoclean, 'redo')
- fprintf('Proceeding to save data ... \n');
- break
- else
- fprintf ('Deleting current dataset and importing raw data\n');
- % Run eeglab and reset vars
- EEG = [];
- ALLEEG = [];
- ALLCOM = {};
- eeglab;
- close all
- % Load EEG data from .vhdr or .ahdr file or other
- if strcmp(ogExtension, '.vhdr') || strcmp(ogExtension, '.ahdr')
- EEG = pop_loadbv(ogFolderpath, [ogfilename, ogExtension], [], []);
- else
- EEG = pop_loadset(file);
- end
- end
- end
- % Step 14 Save data and remove comments
- EEG.comments = [];
- if strcmpi(saveformat, 'mat')
- % Save "EEG" var
- save(fullfile(savepath, fileNameSave), 'EEG');
- elseif strcmpi(saveformat, 'set')
- % Save dataset
- EEG = pop_saveset(EEG, char(fileNameSave), char(savepath), 'savemode', 'onefile');
- elseif strcmpi(saveformat, 'both')
- % Save "EEG" var
- save(fullfile(savepath.mat, fileNameSave), 'EEG');
- % Save dataset
- EEG = pop_saveset(EEG, char(fileNameSave), char(savepath.set), 'savemode', 'onefile');
- end
- % transform and save to FT
- if any(cleanselection == 13)
- fprintf('Exporting to FieldTrip...\n');
- data = eeglab2fieldtrip(EEG, 'raw', 'none');
- save(fullfile(savepath_ft, fileNameSave), 'data');
- end
- % transform and save to LORETA
- if any(cleanselection == 14)
- fprintf('Exporting to LORETA...\n');
- loretaDir = fullfile(rawSavepath, fileNameSave);
- if ~isfolder(loretaDir), mkdir(loretaDir); end
- for epIdx = 1:size(EEG.data, 3)
- writematrix(EEG.data(:, :, epIdx)', sprintf("%s\\%s_%d.asc", loretaDir, fileNameSave, epIdx), "FileType", "text", "Delimiter", "\t"); % loreta needs text tab delimited
- end
- end
- if any(cleanselection == 15)
- fprintf('Exporting to BrainVision...\n');
- bvDir = fullfile(rawSavepath, 'BrainVision');
- if ~isfolder(bvDir), mkdir(bvDir); end
- EEG = pop_writebva(EEG, fullfile(bvDir, fileNameSave), 'DataOrientation', 'MULTIPLEXED');
- end
- % Display completion
- fprintf('\n-----Subject %s finished-----\n\n', fileNameSave);
- clear doRemoveBadChans
- catch subject_loop_error
- % Display error message
- warning('Error found in %s.\n%s (line %d): \n %s\n\nSkipping to next subject...', ogfilename, subject_loop_error.stack(end).name, subject_loop_error.stack(end).line, subject_loop_error.message);
- % Skip to next subject
- continue
- end
- end
- % Display completion
- fprintf('\n-------Successfully completed %d files-------\n', numel(filelist));
- %% Ask to run script on a different condition
- askConditionRerun = questdlg('Do you wish to clean a different condition?', 'Clean new condition', 'Yes', 'No', 'No');
- if strcmpi(askConditionRerun, 'yes')
- fprintf ('Preparing to run on new condition...\n');
- clear epochSettings stimuliLabel
- else
- break
- end
- end
- % re-enable new eeglab version check
- pop_editoptions('option_checkversion', true);
- % Display completion
- fprintf('\n\t\t /\\_/\\ \t /\\_/\\ \n\t\t ( o.o )\t ( ^.^ )\n\t\t > ^ <\t\t > ^ <\n');
eegPreproc.m at commit 9697559, under MIT · at the source
Overview
- Department of Psychology, Faculty of Health Sciences, Rey Juan Carlos University, Madrid, Spain
- Research group in Cognitive Neuroscience, Pain and Rehabilitation (NECODOR), Rey Juan Carlos University, Madrid, Spain
- Mind, Brain and Behavior Research Center, University of Granada, Granada, Andalucía, Spain
- Faculty of Psychology, Autonomous University of Madrid, 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 2 matches between paragraphs and lines of code.
dinosoldic/eeg-preproc-erp
9697559bb6e9537941528cb45e3a96d183d0aded, 28 May 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
9 files
- eegImportChanlocs.m, MATLAB, 128 lines
- eegPlotERP.m, MATLAB, 836 lines
- eegPreproc.m, MATLAB, 898 lines, 1 match
- expandPlot.m, MATLAB, 102 lines
- exportERPData.m, MATLAB, 360 lines
- iIncrementWaitbar.m, MATLAB, 13 lines
- unfoldERPData.m, MATLAB, 400 lines, 1 match
- LICENSE, License, 53 lines
- README.md, Text, 57 lines
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;
- 7 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
Datasets cited
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:
- it points to a dataset: OSF gyk89
Read it in the paper: doi.org/10.1111/ejn.70521.
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 2, 28 September 2026
- Publisher: n/a → Wiley
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 9 authors, 6 keywords, 12 MeSH terms, 1 funder, 76 references.
Cite
This paper
Soldic, D., Martín‐Buro, M. C., López‐García, D., del Pino, A. B., Fernandes‐Magalhaes, R., Ferrera, D., Peláez, I., Carretié, L., & Mercado, F. (2026). Multivariate Pattern Analysis Identifies Potential Intertrial Resting-State EEG Biomarkers in Fibromyalgia. The European journal of neuroscience, 63(9), e70521. https://
BibTeX
@article{soldic2026multi
author = {Soldic, Dino and Martín‐Buro, María Carmen and López‐García, David and del Pino, Ana Belén and Fernandes‐Magalhaes, Roberto and Ferrera, David and Peláez, Irene and Carretié, Luis and Mercado, Francisco},
title = {{Multivariate Pattern Analysis Identifies Potential Intertrial Resting-State EEG Biomarkers in Fibromyalgia}},
journal = {The European journal of neuroscience},
year = {2026},
month = may,
volume = {63},
number = {9},
pages = {e70521},
publisher = {Wiley},
issn = {0953-816X},
doi = {10.1111/
url = {https://
pmid = {42045133},
pmcid = {PMC13121099}
}
RIS
TY - JOUR
AU - Soldic, Dino
AU - Martín‐Buro, María Carmen
AU - López‐García, David
AU - del Pino, Ana Belén
AU - Fernandes‐Magalhaes, Roberto
AU - Ferrera, David
AU - Peláez, Irene
AU - Carretié, Luis
AU - Mercado, Francisco
TI - Multivariate Pattern Analysis Identifies Potential Intertrial Resting-State EEG Biomarkers in Fibromyalgia
T2 - The European journal of neuroscience
J2 - Eur J Neurosci
PY - 2026
DA - 2026/
VL - 63
IS - 9
SP - e70521
SN - 0953-816X
PB - Wiley
DO - 10.1111/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1111/
"type": "article-journal",
"title": "Multivariate Pattern Analysis Identifies Potential Intertrial Resting-State EEG Biomarkers in Fibromyalgia",
"container-title": "The European journal of neuroscience",
"author": [
{
"family": "Soldic",
"given": "Dino"
},
{
"family": "Martín‐Buro",
"given": "María Carmen"
},
{
"family": "López‐García",
"given": "David"
},
{
"family": "del Pino",
"given": "Ana Belén"
},
{
"family": "Fernandes‐Magalhaes",
"given": "Roberto"
},
{
"family": "Ferrera",
"given": "David"
},
{
"family": "Peláez",
"given": "Irene"
},
{
"family": "Carretié",
"given": "Luis"
},
{
"family": "Mercado",
"given": "Francisco"
}
],
"container-title-short":
"volume": "63",
"issue": "9",
"page": "e70521",
"DOI": "10.1111/
"PMID": "42045133",
"PMCID": "PMC13121099",
"ISSN": "0953-816X",
"publisher": "Wiley",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
1
]
]
}
}
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.3389/fnhum.2022.943976
- Electrophysiological indices of pain expectation abnormalities in fibromyalgia patients.Journal: Frontiers in human neuroscienceIn common: pain, EEG, clinical / translational, 4 references, 2 authors
- [2] doi:10.1371/journal.pone.0288830
- Modulation of neural networks and symptom correlated in fibromyalgia: A randomized double-blind multi-group explanatory clinical trial of home-based transcranial direct current stimulation.Journal: PloS oneIn common: pain, EEG, 7 references
- [3] doi:10.1111/jon.70118
- Disrupted Sensorimotor Network Integration in Women With Fibromyalgia Revealed by Resting-State Functional MRI.Journal: Journal of neuroimaging : official journal of the American Society of NeuroimagingIn common: pain, 6 references
- [4] doi:10.1002/hbm.70467
- Cerebellar Tissue Properties Alterations in Fibromyalgia: A T1w/
T2w Ratio Study. Journal: Human brain mappingIn common: pain, other condition, 6 references - [5] doi:10.1097/j.pain.0000000000002565 [code]
- Longitudinal resting-state electroencephalography in patients with chronic pain undergoing interdisciplinary multimodal pain therapy.Journal: PainIn common: pain, EEG, clinical / translational, 6 references
- [6] doi:10.1038/s42003-022-03395-9 [code]
- Neocortical localization and thalamocortical modulation of neuronal hyperexcitability contribute to Fragile X Syndrome.Journal: Communications biologyIn common: ICLabel, EEGLAB, other condition, 5 references
- [7] doi:10.1073/pnas.2114171118 [code]
- The hippocampus as the switchboard between perception and memory.Journal: Proceedings of the National Academy of Sciences of the United States of AmericaIn common: EEG, 3 references, author María Carmen Martín‐Buro
- [8] doi:10.1038/s41597-022-01677-9 [code]
- A behavioral and brain imaging dataset with focus on emotion regulation of women with fibromyalgia.Journal: Scientific dataIn common: pain, 5 references
- [9] doi:10.1016/j.ebiom.2025.105955 [code]
- Exploring electroencephalographic chronic pain biomarkers: a mega-analysis.Journal: EBioMedicineIn common: ICLabel, EEGLAB, pain, EEG, clinical / translational, 3 references
- [10] doi:10.1002/ejp.70331
- Structural and Functional Neuroimaging Findings in Fibromyalgia: A Systematic Review.Journal: European journal of pain (London, England)In common: pain, 4 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, 7 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:524662706442f573…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1111/ejn.70521)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1111/ejn.70521.svg
:target: https://openscicode.org/badge/doi/10.1111/ejn.70521
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1111/ejn.70521"><img src="https://openscicode.org/badge/doi/10.1111/ejn.70521.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
