Skip to content

Commit

Permalink
Merge pull request #29 from VisLab/check-issues
Browse files Browse the repository at this point in the history
Resolved parfor issue and updateNoisyChannels issue
  • Loading branch information
VisLab authored Aug 1, 2021
2 parents 3ed337e + d3a050f commit 9ac9ea0
Show file tree
Hide file tree
Showing 12 changed files with 1,319 additions and 1,298 deletions.
Binary file not shown.
94 changes: 47 additions & 47 deletions PrepPipeline/eegplugin_prepPipeline.m
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
% eegplugin_prepPipeline() - a wrapper to the prepPipeline, which does early stage
%
% Usage:
% >> eegplugin_prepPipeline(fig, try_strings, catch_strings);
%
% see also: prepPipeline

% Author: Kay Robbins, with contributions from Nima Bigdely-Shamlo, Tim Mullen, Christian Kothe, and Cassidy Matousek.

% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

%function eegplugin_clean_rawdata(fig,try_strings,catch_strings)

% create menu
% toolsmenu = findobj(fig, 'tag', 'tools');
% uimenu( toolsmenu, 'label', 'Clean continuous data using ASR', 'separator','on',...
% 'callback', 'EEG = pop_clean_rawdata(EEG); [ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG); eeglab redraw');

% eegplugin_prepPipeline() - the PREP pipeline plugin
function vers = eegplugin_prepPipeline(fig, trystrs, catchstrs)

%% Add path to prepPipeline subdirectories if not in the list
tmp = which('getPrepDefaults');
if isempty(tmp)
myPath = fileparts(which('prepPipeline'));
addpath(genpath(myPath));
end;
vers = getPrepVersion();

% create menu
comprep = [trystrs.no_check '[EEG LASTCOM] = pop_prepPipeline(EEG);' catchstrs.new_and_hist];
menu = findobj(fig, 'tag', 'tools');
uimenu( menu, 'Label', 'Run PREP pipeline', 'callback', comprep, ...
'separator', 'on');

% eegplugin_prepPipeline() - a wrapper to the prepPipeline, which does early stage
%
% Usage:
% >> eegplugin_prepPipeline(fig, try_strings, catch_strings);
%
% see also: prepPipeline

% Author: Kay Robbins, with contributions from Nima Bigdely-Shamlo, Tim Mullen, Christian Kothe, and Cassidy Matousek.

% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

%function eegplugin_clean_rawdata(fig,try_strings,catch_strings)

% create menu
% toolsmenu = findobj(fig, 'tag', 'tools');
% uimenu( toolsmenu, 'label', 'Clean continuous data using ASR', 'separator','on',...
% 'callback', 'EEG = pop_clean_rawdata(EEG); [ALLEEG EEG CURRENTSET] = eeg_store(ALLEEG, EEG); eeglab redraw');

% eegplugin_prepPipeline() - the PREP pipeline plugin
function vers = eegplugin_prepPipeline(fig, trystrs, catchstrs)

%% Add path to prepPipeline subdirectories if not in the list
tmp = which('getPrepDefaults');
if isempty(tmp)
myPath = fileparts(which('prepPipeline'));
addpath(genpath(myPath));
end
vers = getPrepVersion();

% create menu
comprep = [trystrs.no_check '[EEG LASTCOM] = pop_prepPipeline(EEG);' catchstrs.new_and_hist];
menu = findobj(fig, 'tag', 'tools');
uimenu( menu, 'Label', 'Run PREP pipeline', 'callback', comprep, ...
'separator', 'on');

101 changes: 50 additions & 51 deletions PrepPipeline/examples/runVEPPrepPipeline.m
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
%% Example: Running the pipeline on a directory of EEG files

%% Set up the input and the output directories
basename = 'vep';
indir = 'F:\DataPool\CTADATA\VEP\BiosemiOriginalSetCorrected';
outdir = 'D:\TempCTA';

%% Make the output directory if needed
if ~exist(outdir, 'dir')
mkdir(outdir)
end

%% Set up the params structure
params = struct();
params.lineFrequencies = [60, 120, 180, 212, 240];
params.referenceChannels = 1:64;
params.evaluationChannels = 1:64;
params.rereferencedChannels = 1:70;
params.detrendChannels = 1:70;
params.lineNoiseChannels = 1:70;

params.detrendType = 'high pass';
params.detrendCutoff = 1;
params.referenceType = 'robust';
params.meanEstimateType = 'median';
params.interpolationOrder = 'post-reference';
params.removeInterpolatedChannels = true;
params.keepFiltered = false;
basenameOut = [basename 'robust_1Hz_post_median_unfiltered'];


%% Get the filelist
fileList = getFileList('FILES', indir);
%% Run the pipeline
for k = 1:length(fileList)
[~, thisName, ~] = fileparts(fileList{k});
EEG = pop_loadset(fileList{k});
params.name = thisName;
[EEG, params, computationTimes] = prepPipeline(EEG, params);
fprintf('Computation times (seconds):\n %s\n', ...
getStructureString(computationTimes));
fprintf('Post-process\n')
EEG = prepPostProcess(EEG, params);
fname = [outdir filesep thisName '.set'];
save(fname, 'EEG', '-mat', '-v7.3');
if strcmpi(params.errorMsgs, 'verbose')
outputPrepParams(params, 'Prep parameters (non-defaults)');
outputPrepErrors(EEG.etc.noiseDetection, 'Prep error status');
end

end
%% Example: Running the pipeline on a directory of EEG files

%% Set up the input and the output directories
basename = 'vep';
indir = 'F:\DataPool\CTADATA\VEP\BiosemiOriginalSetCorrected';
outdir = 'F:\TempData';

%% Make the output directory if needed
if ~exist(outdir, 'dir')
mkdir(outdir)
end

%% Set up the params structure
params = struct();
params.lineFrequencies = [60, 120, 180, 212, 240];
params.referenceChannels = 1:64;
params.evaluationChannels = 1:64;
params.rereferencedChannels = 1:70;
params.detrendChannels = 1:70;
params.lineNoiseChannels = 1:70;

params.detrendType = 'high pass';
params.detrendCutoff = 1;
params.referenceType = 'robust';
params.meanEstimateType = 'median';
params.interpolationOrder = 'post-reference';
params.removeInterpolatedChannels = true;
params.keepFiltered = false;
basenameOut = [basename 'robust_1Hz_post_median_unfiltered'];

%% Get the filelist
fileList = getFileList('FILES', indir);
%% Run the pipeline
for k = 1:length(fileList)
[~, thisName, ~] = fileparts(fileList{k});
EEG = pop_loadset(fileList{k});
params.name = thisName;
[EEG, params, computationTimes] = prepPipeline(EEG, params);
fprintf('Computation times (seconds):\n %s\n', ...
getStructureString(computationTimes));
fprintf('Post-process\n')
EEG = prepPostProcess(EEG, params);
fname = [outdir filesep thisName '.set'];
save(fname, 'EEG', '-mat', '-v7.3');
if strcmpi(params.errorMsgs, 'verbose')
outputPrepParams(params, 'Prep parameters (non-defaults)');
outputPrepErrors(EEG.etc.noiseDetection, 'Prep error status');
end

end
71 changes: 35 additions & 36 deletions PrepPipeline/examples/runVEPPrepReport.m
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
%% Read in the file and set the necessary parameters

% dataDir = 'O:\ARL_Data\VEP\VEP_Robust_1Hz';
% summaryFolder = 'O:\ARL_Data\VEP\VEP_Robust_1Hz_New_Report_B';

dataDir = 'D:\TempCTA';
summaryFolder = 'D:\TempCTA';
publishOn = true;
%% Get the directory list
inList = dir(dataDir);
inNames = {inList(:).name};
inTypes = [inList(:).isdir];
inNames = inNames(~inTypes);

%%
basename = 'vep';
summaryReportName = [basename '_summary.html'];
sessionFolder = '.';
summaryFileName = [summaryFolder filesep summaryReportName];
if exist(summaryFileName, 'file')
delete(summaryFileName);
end

%% Run the pipeline

for k = 1:length(inNames)
[~, theName, theExt] = fileparts(inNames{k});
if ~strcmpi(theExt, '.set') && ~strcmpi(theExt, '.mat')
continue;
end
sessionReportName = [theName '.pdf'];
fname = [dataDir filesep inNames{k}];
load(fname, '-mat');
sessionFileName = [summaryFolder filesep sessionReportName];
consoleFID = 1;
publishPrepReport(EEG, summaryFileName, sessionFileName, consoleFID, publishOn);
%% This script takes a directory of files that have been processed by PREP
% and produces reports.

%% Read in the file and set the necessary parameters
dataDir = 'F:\TempData';
summaryFolder = 'F:\TempDataReports';
publishOn = true;

%% Get the directory list
inList = dir(dataDir);
inNames = {inList(:).name};
inTypes = [inList(:).isdir];
inNames = inNames(~inTypes);

%% Setup up the names
basename = 'vep';
summaryReportName = [basename '_summary.html'];
sessionFolder = '.';
summaryFileName = [summaryFolder filesep summaryReportName];
if exist(summaryFileName, 'file')
delete(summaryFileName);
end

%% Publish the reports
for k = 1:length(inNames)
[~, theName, theExt] = fileparts(inNames{k});
if ~strcmpi(theExt, '.set') && ~strcmpi(theExt, '.mat')
continue;
end
sessionReportName = [theName '.pdf'];
fname = [dataDir filesep inNames{k}];
load(fname, '-mat');
sessionFileName = [summaryFolder filesep sessionReportName];
consoleFID = 1;
publishPrepReport(EEG, summaryFileName, sessionFileName, consoleFID, publishOn);
end
Loading

0 comments on commit 9ac9ea0

Please sign in to comment.