Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
teddychao committed Dec 18, 2023
1 parent 1a78e81 commit 7264cab
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
68 changes: 37 additions & 31 deletions src/pspm_cfg/pspm_cfg_run_artefact_rm.m
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
function out = pspm_cfg_run_artefact_rm(job)
% Executes pspm_pp

% $Id$
% $Rev$

% Reviewed and updated on 18-Dec-2023 by Teddy
options = struct;
options.overwrite = job.overwrite;

filtertype = fieldnames(job.filtertype);
filtertype = filtertype{1};
datafile = job.datafile;
datafile = datafile{1};
channelnumber = job.chan_nr;

switch filtertype
case 'median'
n = job.filtertype.(filtertype).nr_time_pt;
out = pspm_pp(filtertype, datafile, n, channelnumber, options);
case 'butter'
freq = job.filtertype.(filtertype).freq;
out = pspm_pp(filtertype, datafile, freq, channelnumber, options);
case 'scr_pp'
scr_job = job.filtertype.(filtertype);
% Option structure sent to pspm_simple_qa
scr = struct();
if isfield(scr_job, 'min'), scr.min = scr_job.min; end % Check if min is defined
if isfield(scr_job, 'max'), scr.max = scr_job.max; end % Check if max is defined
if isfield(scr_job, 'slope'), scr.slope = scr_job.slope; end % Check if slope is defined
if isfield(scr_job.missing_epochs, 'write_to_file') % Check if missing_epochs is defined
if isfield(scr_job.missing_epochs.write_to_file,'filename') && isfield(scr_job.missing_epochs.write_to_file,'outdir')
scr.missing_epochs_filename = fullfile(scr_job.missing_epochs.write_to_file.outdir{1}, scr_job.missing_epochs.write_to_file.filename);
end
end
if isfield(scr_job, 'deflection_threshold'), scr.deflection_threshold = scr_job.deflection_threshold; end % Check if deflection_threshold is defined
if isfield(scr_job, 'data_island_threshold'), scr.data_island_threshold = scr_job.data_island_threshold; end % Check if data_island_threshold is defined
if isfield(scr_job, 'expand_epochs'), scr.expand_epochs = scr_job.expand_epochs; end % Check if expand_epochs is defined
if isfield(scr_job, 'change_data'), scr_job.change_data = scr_job.change_data; else, scr_job.change_data = "replace"; end % Check if data will be changed

[~, out] = pspm_scr_pp(datafile, scr);
end
case 'median'
n = job.filtertype.(filtertype).nr_time_pt;
out = pspm_pp(filtertype, datafile, n, channelnumber, options);
case 'butter'
freq = job.filtertype.(filtertype).freq;
out = pspm_pp(filtertype, datafile, freq, channelnumber, options);
case 'scr_pp'
scr_job = job.filtertype.(filtertype);
% Option structure sent to pspm_simple_qa
if isfield(scr_job, 'min'), options.min = scr_job.min; end
if isfield(scr_job, 'max'), options.max = scr_job.max; end
if isfield(scr_job, 'slope'), options.slope = scr_job.slope; end
if isfield(scr_job.missing_epochs, 'write_to_file')
if isfield(scr_job.missing_epochs.write_to_file,'filename') && ...
isfield(scr_job.missing_epochs.write_to_file,'outdir')
options.missing_epochs_filename = fullfile(...
scr_job.missing_epochs.write_to_file.outdir{1}, ...
scr_job.missing_epochs.write_to_file.filename);
end
end
if isfield(scr_job, 'deflection_threshold')
options.deflection_threshold = scr_job.deflection_threshold;
end
if isfield(scr_job, 'data_island_threshold')
options.data_island_threshold = scr_job.data_island_threshold;
end
if isfield(scr_job, 'expand_epochs')
options.expand_epochs = scr_job.expand_epochs;
end
if isfield(scr_job, 'change_data')
options.channel_action = 'add';
else
options.channel_action = 'replace';
end
[~, out] = pspm_scr_pp(datafile, options);
end
11 changes: 2 additions & 9 deletions src/pspm_cfg/pspm_cfg_run_interpolate.m
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
function out = pspm_cfg_run_interpolate(job)

% Updated 18-12-2023 by Teddy

options = struct();
fn = job.datafiles;

if isfield(job.mode, 'file')
options.overwrite = job.mode.file.overwrite;
options.newfile = true;
elseif isfield(job.mode, 'channel')
options.channels = cell(size(job.datafiles));
options.channels{:} = job.mode.channel.source_chan;
options.newfile = false;

if isfield(job.mode.channel.mode, 'new_chan')
options.channel_action = 'add';
elseif isfield(job.mode.channel.mode, 'replace_chan')
options.channel_action = 'replace';
end;

end;

end
end
options.extrapolate = job.extrapolate;

[~, out] = pspm_interpolate(fn, options);

0 comments on commit 7264cab

Please sign in to comment.