Skip to content

Commit c3c26c7

Browse files
committed
Fixes data conversion and validation
Addresses issues in data conversion from double format by correcting a conditional check for sampling frequency. Also, this commit enhances input validation in the Struct data type checker by ensuring that the correct fieldname is retrieved, preventing potential errors when processing data structures.
1 parent 1c4af72 commit c3c26c7

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

+datareader/+convert/Double.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% function [Dout,TrialTime,nUnits,nTrial,Condition,Area] = Double(Din,opts)
33
%
44
% Convert a double array to the standard format for the NeuralEmbedding
5-
% class.
5+
% class. Double input is interpreted as MUA spectral estimation activity.
66
%
77
% Input:
88
% Din (double): Input data in the format nUnits x TrialL x nTrials
@@ -22,7 +22,7 @@
2222
optsDefault = structfun(@isempty,opts,'UniformOutput',false);
2323

2424
% TODO check for fs
25-
if ~optsDefault.fs
25+
if optsDefault.fs
2626
error('fs field is missing in opts structure.\nIt is required when converting data from double format.\nPlease input the sampling frequency (in Hz) in opts.fs.');
2727
end
2828

+datareader/+is/Double.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function ValidateArgs(Din,opts)
4545
% area (string): Area labels ( 1 x nUnits )
4646
% condition (string): Condition labels ( 1 x nTrials )
4747
%
48-
48+
optsDefault = structfun(@isempty,opts,'UniformOutput',false);
4949
[nUnits,Time,nTrials] = size(Din);
5050

5151
% Checks if the time vector matches the input data second dimension

+datareader/+is/Struct.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
% If required field is not present, checks in opts
9595
for ff = [fields2check; fieldType]
9696
% retrieve the correct fieldname between those accepted
97-
thisFieldName = fnames(ismember(fnames,datareader.is.Struct(ff(1))));
97+
thisFieldName = fnames(find(ismember(fnames,datareader.is.Struct(ff(1))),1,'first'));
9898
if isempty(thisFieldName) && optsDefault.(ff(1))
9999
error("No field %s provided in opts struct.\n",ff(1));
100100
elseif ~isempty(thisFieldName) &&...

0 commit comments

Comments
 (0)