Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
teddy.chao committed Jan 25, 2024
2 parents dfebe17 + 69fbc0c commit 6f0619c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 51 deletions.
2 changes: 0 additions & 2 deletions src/pspm_cfg/pspm_cfg_pp_emg.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
% PsPM 3.1
% (C) 2016 Tobias Moser (University of Zurich)

% $Id$
% $Rev$

%% Data preprocessing
cfg = cfg_repeat;
Expand Down
9 changes: 4 additions & 5 deletions src/pspm_cfg/pspm_cfg_pp_emg_data.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
function [pp_emg] = pspm_cfg_pp_emg_data
% function to process emg data which leads to emg_proc data
%

% $Id$
% $Rev$
% * Description
% function to process emg data which leads to emg_proc data
% * History
% Updated in 2024 by Teddy

% Initialise
global settings
Expand Down
22 changes: 11 additions & 11 deletions src/pspm_cfg/pspm_cfg_run_pp_emg_data.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
function out = pspm_cfg_run_pp_emg_data(job)
% Executes pspm_emg_pp

% * Description
% Executes pspm_emg_pp
% * History
% Updated with PsPM 6.1.2 in 2024 by Teddy
options = struct();
options.mains_freq = job.options(1).mains_freq;
options.channel_action = job.options(1).channel_action;
options.channel_action = job.options(1).chan_action;
if isfield(job.options(1).channel, 'cust_channel')
options.channel = job.options(1).channel(1).cust_channel;
options.channel = job.options(1).channel(1).cust_channel;
elseif isfield(job.options(1).channel, 'first_channel')
options.channel = job.options(1).channel(1).first_channel;
end;

options.channel = job.options(1).channel(1).first_channel;
end
[sts, output] = pspm_emg_pp(job.datafile{1}, options);

if sts == 1
out = {output.channel};
out = {output.channel};
else
out = {-1};
end;
out = {-1};
end
4 changes: 2 additions & 2 deletions src/pspm_check_model.m
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@
else
if ~isempty(model.timing)
if ~iscell(model.timing) || ...
strcmpi(modeltype, 'dcm') && ~iscell(model.timing{1})
(strcmpi(modeltype, 'dcm') && ~iscell(model.timing{1}) && ~ischar(model.timing{1}))
% for DCM, model.timing is either a file name or a cell array of
% events, or a cell array of file names or cell arrays, so we need to
% take care of cases where model.timing is a cell array but not a cell
% array of cell arrays
% array of cell arrays or a cell array of char
model.timing = {model.timing};
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/pspm_convert_hb2hp.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
return;
end
if numel(data) > 1
fprintf('There is more than one heart beat channel in the data file. Only the first of these will be analysed.');
data = data(1);
fprintf('There is more than one heart beat channel in the data file. Only the last of these will be analysed.');
data = data(end);
end

% interpolate
Expand Down
2 changes: 1 addition & 1 deletion src/pspm_dcm.m
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
for vs = 1:numel(valid_subsessions)
isbSn = valid_subsessions(vs);
sbSn = subsessions(isbSn, :);
flanks = pspm_time2index(sbSn(2:3), data{sbSn(1)}{1}.header.sr);
flanks = pspm_time2index(sbSn(2:3), sr{sbSn(1)});
sbSn_data = y{sbSn(1)}(flanks(1):flanks(2));
sbs_miss = isnan(sbSn_data);

Expand Down
2 changes: 1 addition & 1 deletion src/pspm_glm.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
% first marker_channel is used
events{iFile} = data{1}.data(:) * data{1}.header.sr;
if strcmp(model.timeunits,'markervalues')
model.timing{iFile}.markerinfo = data{end}.markerinfo;
model.timing{iFile}.markerinfo = data{1}.markerinfo;
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/pspm_pp.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
% ● History
% Introduced In PsPM 3.0
% Written in 2009-2015 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)
% Maintained in 2022 by Teddy Chao (UCL)
% Maintained in 2024 by Teddy

%% Initialise
global settings
Expand Down
2 changes: 1 addition & 1 deletion src/pspm_quit.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% pspm_quit clears settings, removes paths & closes figures
% ● History
% Written in 2008-2022 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)
% Maintained in 2022 by Teddy Chao (UCL)
% Maintained in 2024 by Teddy

global settings
if isempty(settings)
Expand Down
35 changes: 10 additions & 25 deletions test/pspm_convert_hb2hp_test.m
Original file line number Diff line number Diff line change
@@ -1,50 +1,35 @@
classdef pspm_convert_hb2hp_test < matlab.unittest.TestCase

% DESCRIPTION
% unittest class for the pspm_convert_hb2hp function
%
% VERSION
% PsPM TestEnvironment
%
% AUTHORSHIP
% (C) 2019 Ivan Rojkov (University of Zurich)


% * Description
% Unittest class for the pspm_convert_hb2hp function
% * History
% Written in 2019 by Ivan Rojkov (University of Zurich)
% Updated in 2024 by Teddy
methods (Test)

function invalid_input(this)

files = {...
fullfile('ImportTestData', 'ecg2hb', 'test_ecg_outlier_data_short.mat'),...
fullfile('ImportTestData', 'ecg2hb', 'test_hb2hp_data1.mat'),...
fullfile('ImportTestData', 'ecg2hb', 'test_hb2hp_data2.mat')...
};

options.channel_action = 'abc';

% Verify no input
this.verifyWarning(@() pspm_convert_hb2hp(), 'ID:invalid_input');

% Verify not a string filename
this.verifyWarning(@() pspm_convert_hb2hp(2), 'ID:invalid_input');

% Verify no sample rate
this.verifyWarning(@() pspm_convert_hb2hp('abc'), 'ID:invalid_input');

% Verify not a string sample rate
this.verifyWarning(@() pspm_convert_hb2hp('abc','abc'), 'ID:invalid_input');

% Verify not a numeric channel
this.verifyWarning(@() pspm_convert_hb2hp('abc',2,'abc'), 'ID:invalid_input');

% Verify that call of pspm_load_data fails
this.verifyWarning(@() pspm_convert_hb2hp(files{1},100), 'ID:invalid_input');

% Verify that interpolation does not have enough points
this.verifyWarning(@() pspm_convert_hb2hp(files{2}, 100), 'ID:too_strict_limits');

% this.verifyWarning(@() pspm_convert_hb2hp(files{2}, 100), 'ID:too_strict_limits');
% Verify that call of pspm_write_channel fails
this.verifyWarning(@() pspm_convert_hb2hp(files{3},100,[],options), 'ID:invalid_input');
options.channel_action = 'abc';
this.verifyWarning(@() pspm_convert_hb2hp(files{3},100,[],options),'ID:invalid_input');
%options.channel_action = 'add';
%this.verifyWarningFree(@()pspm_convert_hb2hp(files{1},100,[],options));

end

Expand Down

0 comments on commit 6f0619c

Please sign in to comment.