Skip to content

Commit

Permalink
[bug] allow to store true 1D vector with ndim=1, fix #16, fNIRS/snirf…
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jul 7, 2024
1 parent a88c2e1 commit 01e5e53
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions saveh5.m
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ function saveh5(data, fname, varargin)

opt = varargin{1};

if (opt.dotranspose)
dims = size(item);
force1d = (ndims(item) == 6 && all(dims(1:5) == 1));

if (opt.dotranspose && force1d == 0)
item = permute(item, ndims(item):-1:1);
end

Expand Down Expand Up @@ -298,7 +301,11 @@ function saveh5(data, fname, varargin)
elseif (isnumeric(item) && numel(item) == 1 && ndims(item) == 2 && opt.scalar)
itemsize = H5S.create('H5S_SCALAR');
else
itemsize = H5S.create_simple(ndims(item), fliplr(size(item)), fliplr(size(item)));
if(force1d)
itemsize = H5S.create_simple(1, dims(end), dims(end));
else
itemsize = H5S.create_simple(ndims(item), fliplr(size(item)), fliplr(size(item)));
end
end
try
oid = H5D.create(handle, name, itemtype, itemsize, pd);
Expand Down

0 comments on commit 01e5e53

Please sign in to comment.