Skip to content

Commit

Permalink
Merge load_mat_style changes to @DataStub
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-mbf committed Sep 5, 2023
2 parents 286d6b5 + e05ab5b commit 969af61
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions +types/+untyped/@DataStub/load_mat_style.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
dataDimensions = obj.dims;
spaceId = obj.get_space();
userSelection = varargin;

selectionErrorId = 'NWB:DataStub:Load:InvalidSelection';
for iDimension = 1:min(obj.ndims, length(userSelection))
selection = userSelection{iDimension};
if ischar(selection)
continue;
end
assert(all(isreal(selection) & isfinite(selection) & selection > 0 & selection == floor(selection)) ...
, selectionErrorId ...
, 'DataStub indices for dimension %u must be positive integer values' ...
, iDimension);

if iDimension == length(userSelection)
dimensionSize = prod(dataDimensions(iDimension:end));
else
dimensionSize = dataDimensions(iDimension);
end
assert(all(dimensionSize >= selection) ...
, selectionErrorId ...
, ['DataStub indices for dimension %u must be less than or equal to ' ...
'dimension size %u'] ...
, iDimension, dimensionSize);
end

if isscalar(userSelection) && ~ischar(userSelection{1})
% linear index into the fast dimension.
Expand Down

0 comments on commit 969af61

Please sign in to comment.