Skip to content

Commit

Permalink
Merge pull request #562 from bachlab/559-pspm_convert_ppg2hb-supports…
Browse files Browse the repository at this point in the history
…-both-optionsreplace-and-optionschannel_action
  • Loading branch information
dominikbach committed Feb 5, 2024
2 parents 01a04ab + 11fd718 commit d671bde
Show file tree
Hide file tree
Showing 56 changed files with 916 additions and 1,267 deletions.
Binary file modified doc/Figures/YY1_import.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/Figures/YY1_import_text_too_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/Figures/YY2_trim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/Figures/YY2_trim_text_too_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions doc/PsPM_Manual.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -14233,7 +14233,7 @@ status open
\begin_layout Plain Layout
\begin_inset Graphics
filename Figures/YY1_import.png
scale 40
scale 50

\end_inset

Expand Down Expand Up @@ -14283,7 +14283,7 @@ status open
\begin_layout Plain Layout
\begin_inset Graphics
filename Figures/YY2_trim.png
scale 40
scale 50

\end_inset

Expand Down
Binary file modified doc/PsPM_Manual.pdf
Binary file not shown.
64 changes: 31 additions & 33 deletions src/pspm_cfg/pspm_cfg_run_artefact_rm.m
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
function out = pspm_cfg_run_artefact_rm(job)
% Executes pspm_pp

% $Id$
% $Rev$

options = struct;
options.overwrite = job.overwrite;

% Reviewed and updated on 18-Dec-2023 by Teddy
options = struct();
options = pspm_update_struct(options, 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);
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);
options = pspm_update_struct(options, scr_job, {'min',...
'max',...
'slope',...
'deflection_threshold',...
'data_island_threshold',...
'expand_epochs'})
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, 'change_data')
options.channel_action = 'add';
else
options.channel_action = 'replace';
end
[~, out] = pspm_scr_pp(datafile, options);
end
12 changes: 8 additions & 4 deletions src/pspm_cfg/pspm_cfg_run_combine_markerchannels.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
function pspm_cfg_run_combine_markerchannels(job)
% Updated on 19-12-2023 by Teddy
%% Variables
% fn
fn = job.datafile{1};
channel_action = job.channel_action;
marker_channel_number = job.marker_chan_num;
options = struct('channel_action', channel_action, ...
'marker_chan_num', marker_channel_number);
% options
options = struct();
options = pspm_update_struct(options, job, {'channel_action',...
'marker_chan_num'})
%% Run
pspm_combine_markerchannels(fn, options);
27 changes: 10 additions & 17 deletions src/pspm_cfg/pspm_cfg_run_contrast1.m
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
function out = pspm_cfg_run_contrast1(job)
% Executes pspm_con1

% $Id$
% $Rev$

% Updated on 18-12-2023 by Teddy
%% Variables
% modelfile
modelfile = job.modelfile;

% contrast names & vectors
% connames, convec
nrCon = size(job.con,2);
for iCon=1:nrCon
for iCon = 1:nrCon
connames{1,iCon} = job.con(iCon).conname;
convec{1,iCon} = job.con(iCon).convec;
end

% delete existing contrast
deletecon = job.deletecon;

% zscore data
options.zscored = job.zscored;

% datatype
datatype = job.datatype;

% deletecon
deletecon = job.deletecon;
% options
options = struct();
options = pspm_update_struct(options, job, 'zscored')
%% Run
pspm_con1(modelfile, connames, convec, datatype, deletecon, options);

out = modelfile;
31 changes: 12 additions & 19 deletions src/pspm_cfg/pspm_cfg_run_contrast2.m
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
function out = pspm_cfg_run_contrast2(job)
% Executes pspm_con1

% $Id$
% $Rev$

% Updated on 19-12-2023 by Teddy
%% Variables
% modelfile
if isfield(job.testtype, 'one_sample')
modelfile = job.testtype.one_sample.modelfile';
modelfile = job.testtype.one_sample.modelfile';
else
modelfile{1,1} = job.testtype.two_sample.modelfile1';
modelfile{1,2} = job.testtype.two_sample.modelfile2';
modelfile{1,1} = job.testtype.two_sample.modelfile1';
modelfile{1,2} = job.testtype.two_sample.modelfile2';
end

% outfile
outfile = [job.outdir{1} filesep job.filename '.mat'];

% connames & con
% con and connames
connames = fieldnames(job.def_con_name);
connames = connames{1};
if isfield(job.def_con_name.(connames),'con_all')
con = 'all';
con = 'all';
else
con = job.def_con_name.(connames).convec;
con = job.def_con_name.(connames).convec;
end
% nrCon = size(job.def_con_name.(connames).con, 2);
% if strcmp(connames, 'name')
Expand All @@ -35,13 +30,11 @@
% con(1,iCon) = job.def_con_name.(connames).con(iCon).conval;
% end
% end

% datatype
%datatype = job.datatype;

% datatype = job.datatype;
% options
options.overwrite = job.overwrite;

options = struct();
options = pspm_update_struct(options, job, 'overwrite');
%% Run
pspm_con2(modelfile, outfile, con, connames, options);

out = {outfile};
45 changes: 19 additions & 26 deletions src/pspm_cfg/pspm_cfg_run_data_convert.m
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
function [out] = pspm_cfg_run_data_convert(job)

% $Id$
% $Rev$

channel_action = job.channel_action;
% Updated on 19-12-2023 by Teddy
fn = job.datafile{1};

for i=1:numel(job.conversion)
options = struct();
options.channel_action = channel_action;
channel = job.conversion(i).channel;
if isfield(job.conversion(i).mode, 'area2diameter')
pspm_convert_area2diameter(fn, chan, options);
end
if isfield(job.conversion(i).mode, 'pixel2unit')
width = job.conversion(i).mode.pixel2unit.width;
height = job.conversion(i).mode.pixel2unit.height;
distance = job.conversion(i).mode.pixel2unit.distance;
unit = job.conversion(i).mode.pixel2unit.unit;
pspm_convert_pixel2unit(fn, chan, unit, width, height,distance, options);
end
if isfield(job.conversion(i).mode, 'visangle2sps')
options.channels = channel;
options.eyes = job.conversion(i).mode.visangle2sps.eyes;
pspm_convert_visangle2sps(fn,options);
end
for i = 1:numel(job.conversion)
options = struct();
options = pspm_update_struct(options, job, 'channel_action');
if isfield(job.conversion(i).mode, 'area2diameter')
pspm_convert_area2diameter(fn, chan, options);
end
if isfield(job.conversion(i).mode, 'pixel2unit')
width = job.conversion(i).mode.pixel2unit.width;
height = job.conversion(i).mode.pixel2unit.height;
distance = job.conversion(i).mode.pixel2unit.distance;
unit = job.conversion(i).mode.pixel2unit.unit;
pspm_convert_pixel2unit(fn, chan, unit, width, height,distance, options);
end
if isfield(job.conversion(i).mode, 'visangle2sps')
options = pspm_update_struct(options, job.conversion(i), 'channel');
options = pspm_update_struct(options, job.conversion(i).mode.visangle2sps, 'eyes');
pspm_convert_visangle2sps(fn, options);
end
end

out = 1;
6 changes: 3 additions & 3 deletions src/pspm_cfg/pspm_cfg_run_data_editor.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function pspm_cfg_run_data_editor(job)
fn = job.datafile{1};
options = struct();
if isfield(job.outputfile, 'enabled')
options.output_file = [job.outputfile.enabled.file_path{1} filesep ...
job.outputfile.enabled.file_name];
options.output_file = [job.outputfile.enabled.file_path{1} filesep ...
job.outputfile.enabled.file_name];
end
pspm_data_editor(fn, options);
pspm_data_editor(fn, options);
Loading

0 comments on commit d671bde

Please sign in to comment.