Skip to content

Refactor pspm_interpolate#684

Merged
dominikbach merged 12 commits intodevelopfrom
fix-673
Apr 19, 2024
Merged

Refactor pspm_interpolate#684
dominikbach merged 12 commits intodevelopfrom
fix-673

Conversation

@dominikbach
Copy link
Copy Markdown
Contributor

@dominikbach dominikbach commented Apr 10, 2024

Fixes #673 : refactors pspm_interpolate.

Changes proposed in this pull request:

  1. Remove option to work on multiple data files at a time, as this is not used in other pre-processing functions.
  2. Remove option to work on several channels at a time: either work on all continuous channels (and write new file) or work on one channel only (and write to same file).
  3. Use pspm_load_channel for single channel option, and pspm_select_channels for all channel option.
  4. Remove option to work on struct input - this is not supported by other PsPM functions and makes the code more clunky. (It is straightforward to deal with struct input as pspm_load_data gracefully handles this, but producing the output is more complex.)
  5. Change channel selector in GUI is changed in reflection of step 2 from many to any. Also, file selector is changed to allowing just one file at a time.
  6. Extrapolate handling is changed. Previously, if there were NaNs at beginning or end of file, options.extrapolate was forced to 1. However, then the option does not make sense, as it would always be enforced whenever it is relevant. Thus, this is no longer enforced, but a warning is still given that NaN remain in the data.
  7. pspm_options is changed to deal with the larger number of methods allowed.
  8. pspm_load_channel is changed to allow detecting whether a channel is a wave or events channel.

@dominikbach dominikbach self-assigned this Apr 10, 2024
@dominikbach dominikbach added the In Progress Currently being worked on label Apr 10, 2024
@dominikbach dominikbach requested a review from teddphil April 11, 2024 16:43
@dominikbach dominikbach added Completed & Waiting for Review Completed and waiting for review and removed In Progress Currently being worked on labels Apr 11, 2024
@dominikbach dominikbach added In Progress Currently being worked on and removed Completed & Waiting for Review Completed and waiting for review labels Apr 11, 2024
@dominikbach dominikbach added Completed & Waiting for Review Completed and waiting for review and removed In Progress Currently being worked on labels Apr 12, 2024
@dominikbach dominikbach changed the title Fix 673 Refactor pspm_interpolate Apr 12, 2024
@teddphil teddphil added Under Review and removed Completed & Waiting for Review Completed and waiting for review labels Apr 15, 2024
Copy link
Copy Markdown

@teddphil teddphil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just made some minor suggestions. The updates to the functionality do not have issues to me. Thank you.

Comment thread src/pspm_interpolate.m
% ● Arguments
% indata: [struct/char/numeric] or [cell array of struct/char/numeric]
% contains the data to be interpolated
% indata: [char/numeric] contains the data to be interpolated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think the description of indata shall be updated to make it inline with above for avoiding confusion...

Comment thread src/pspm_interpolate.m

if isnumeric(indata)
if nargin >= 2
options = varargin{1};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no issue for this situation, but I have a feeling that this refers to indata=numeric_array and channel does not exist in this case, so nargin can be only 1 or 2. ">2" is a situation that is unexpected.

Comment thread src/pspm_interpolate.m

%% 2 work on data
% 2.1 load data
if method == 1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this method is different from options.method that is explained in help text. Maybe it is useful to explain the meaning of method 1, 2, 3 for future maintaining purposes.

Comment thread src/pspm_interpolate.m
% indata: [struct/char/numeric] or [cell array of struct/char/numeric]
% contains the data to be interpolated
% indata: [char/numeric] contains the data to be interpolated
% channel: a single channel identifier accepted by pspm_load_channel
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think accepting only one channel will be better because (1) it is simpler and can avoid bugs better (2) users can simply repeating this function in their script if they want to process multiple channels.

Comment thread src/pspm_interpolate.m
end
if s_overlap || e_overlap
if ~options.extrapolate
warning('ID:option_disabled', ...
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand option_disabled, does this mean options.extrapolate must be true? It seems to be option_invalid which can be in line with input_invalid.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add some help text to cm. For example, it can just let users know "only one channel will be processed under channel mode".

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the channel action is renamed to mode here. I do not have a preference, but I think consistency can make users feel less confused about what they mean.
image

Comment thread src/pspm_options.m
'previous', ...
'next'} );

options = autofill(options, 'newfile', 0, 1 );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this newfile is no longer used, I suggest to remove this line.

@teddphil teddphil added Approved The pull request has been approved and can be checked and then merged. and removed Under Review labels Apr 19, 2024
@dominikbach dominikbach merged commit e444987 into develop Apr 19, 2024
@dominikbach dominikbach deleted the fix-673 branch April 19, 2024 05:36
@teddphil teddphil removed the Approved The pull request has been approved and can be checked and then merged. label Jun 3, 2024
@teddphil teddphil added this to the v7.0 milestone Aug 25, 2024
@teddphil teddphil mentioned this pull request Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor pspm_interpolate

2 participants