New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify function output #689
Conversation
Hi Dom,
Thank you for the update.
My flight is tomorrow and I am preparing for several stuffs. Is it ok if I review this next week?
Best wishes
Teddy
From: Dominik Bach ***@***.***>
Date: Friday, 19 April 2024 at 09:29
To: bachlab/PsPM ***@***.***>
Cc: Teddy ***@***.***>, Review requested ***@***.***>
Subject: Re: [bachlab/PsPM] Unify function output (PR #689)
@dominikbach<https://github.com/dominikbach> requested your review on: #689<#689> Unify function output.
—
Reply to this email directly, view it on GitHub<#689 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA5W62TSH2LVJPQBERKYIDLY6DIX5AVCNFSM6AAAAABGL33LHKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGUZTINZWHA2DMMQ>.
You are receiving this because your review was requested.Message ID: ***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed some functions.. I try to finish them in these two days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Line 24--27 may not work as fully expected, because the channel action does not have a fallback. Users cannot avoid creating a channel. To fix this, I suggest to change line 24--27 to be
if isfield(d.create_corrected_chan, 'yes')
options.channel_action = 'add';
options.channel_output = 'corrected';
else
options.channel_action = 'none';
end
And in pspm_options
, it should be modified in line 217, to be
options = autofill_channel_action(options, 'add', {'replace', 'none'} );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new design is to always create a channel (i.e. never give the GUI user the option not to). But this was incorrectly implemented in the GUI. It should be fixed now.
infos = cell(2,1); | ||
data = cell(2,1); | ||
for iNum = 1:2 | ||
[sts_load_data, infos, data] = pspm_load_data(infile{iNum}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this; pspm_cfg_run_merge
is fixed now.
src/pspm_cfg/pspm_cfg_run_rename.m
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this file is working. I checked and saw it reported error when I tried to rename a file. The job.file
did not exist in this occasion. My understanding of what has been updated to pspm_cfg_run_merge
is to make it consistent to the output from other functions, so it is not expecting to change the functionality of "rename". Maybe you could have a look and see if any unexpected update has caused this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this is fixed now.
@@ -1,26 +1,29 @@ | |||
function sts = pspm_combine_markerchannels(datafile, options) | |||
function [sts, outchannel] = pspm_combine_markerchannels(datafile, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be useful to update pspm_cfg_run_combine_markerchannels
and add output at its line 11. Similarly, for pspm_combine_markerchannels_test
, the lines 22, 28, 48, 66 may need to be updated to add the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GUI dependencies & tests will be updated in future PR, no change required for now.
if sts == 1 | ||
out = {output.channel}; | ||
out = {outchannel}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw other functions, such as pspm_cfg_run_merge
has removed out={out}
if it is not a cell. I am not sure if this is still necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GUI dependencies will be updated in a future PR.
@@ -82,30 +75,16 @@ function scr_pp_test_missing(this, channels) | |||
'deflection_threshold', 0, ... | |||
'expand_epochs', 0, ... | |||
'channel_action', 'add'); | |||
options6 = struct('change_data', 0); | |||
% Verifying the situation with missing epochs filename option without | |||
% saving to datafile | |||
pspm_testdata_gen(channels, this.duration, this.fn); | |||
[~, out] = pspm_scr_pp(this.fn, options4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the test here, options4
shall include the channel_action
, in this case shall be set to be none
or withdraw
. If not set, this channel_action
will use the default fallback, which is add
. It is better to sort it to be none
which means the processed data will not be saved to the original file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests can be updated later.
% ● Description | ||
% pspm_convert_ecg2hb identifies the position of QRS complexes in ECG data and | ||
% writes them as heart beat channel into the datafile. This function | ||
% implements the algorithm by Pan & Tompkins (1985) with some adjustments. | ||
% ● Format | ||
% sts = pspm_convert_ecg2hb(fn, options) | ||
% [sts, channel_index, quality_info] = pspm_convert_ecg2hb(fn, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it is useful to say outchannel
and debug_info
here, since they are named in the code..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistic issue, no change required.
@@ -9,8 +9,8 @@ | |||
% it will either replace an existing heartbeat channel or add it as a new | |||
% channel to the provided file. | |||
% ● Format | |||
% [sts, out_channel] = pspm_convert_ecg2hb_amri(fn) | |||
% [sts, out_channel] = pspm_convert_ecg2hb_amri(fn, options) | |||
% [sts, channel_index] = pspm_convert_ecg2hb_amri(fn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, both channel_index
and out_channel
can be used, but better to choose one of them and rename the variables to it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just stylistic.
test/pspm_convert_gaze_test.m
Outdated
this.fn = pspm_import(this.raw_input_filename, 'eyelink', import, options); | ||
this.fn = this.fn{1}; | ||
[sts, this.fn] = pspm_import(this.raw_input_filename, 'eyelink', import, options); | ||
this.fn = this.fn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this line can be just deleted...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -23,20 +23,20 @@ | |||
{'semi', 'twthresh'}); | |||
options = pspm_update_struct(options, job, 'channel_action'); | |||
% call function | |||
[sts, winfo] = pspm_convert_ecg2hb(fn, options); | |||
[sts, outchannel] = pspm_convert_ecg2hb(fn, options); | |||
case 'ecg2hb_amri' | |||
options = pp_field.opt; | |||
options.channel = chan; | |||
options = pspm_update_struct(options, job, 'channel_action'); | |||
winfo = struct(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this line can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
% ● Description | ||
% pspm_find_sounds finds and if required analyzes sound events in a pspm file. | ||
% A sound is accepted as event if it is longer than 10 ms and events are | ||
% recognized as different if they are at least 50 ms appart. | ||
% ● Format | ||
% [sts, infos] = pspm_find_sounds(file,options) | ||
% [sts, channel_index, info] = pspm_find_sounds(fn, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consistent variable naming is required here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just stylistic.
Fixes #624. Fixes #519. Fixes #421.
Changes proposed in this pull request:
[sts, channel_index]
and potentially further output arguments.[sts, newfilename]
and potentially further output arguments.pspm_exp
).pspm_write_channel
is always called with an index of the channels that were used to create the new channel data.pspm_write_channel
will then check whether these channels will be overwritten (if action isreplace
and the channels have the same type and units) or whether new channels are created.varargout
was removed wherever possible. Some widely used helper functions remain (e.g.pspm_overwrite
andpspm_prepdata
) and will be addressed in new pull requests.cfg_run
functions and will be addressed in new PR.Summaries:
Function output was changed:
Write channel behaviour changed
Option to work on multiple files removed
Varargout removed
Function output unchanged
Bugs fixed
Other changes
pspm_ren
was renamed topspm_rename
for enhanced transparencypspm_rename
now usespspm_load_data
to save data and checks whether new file already exists, viaoptions.overwrite
pspm_write_channel
, now usespspm_select_channels
for checkspspm_check_data
, used inpspm_load_data
andpspm_write_channel
pspm_select_channels