From 24eacabfd2537dd1c0a73b06d54d5578d90bdb23 Mon Sep 17 00:00:00 2001 From: Lawrence Date: Wed, 4 Mar 2020 17:03:52 -0500 Subject: [PATCH] Fixed DataPipe not setting Dimensions correctly DataPipe originally did not account for an initial allocation case, causing errors when appending. This has been resolved. --- +types/+untyped/DataPipe.m | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/+types/+untyped/DataPipe.m b/+types/+untyped/DataPipe.m index 3f79bc5c..b44aecea 100644 --- a/+types/+untyped/DataPipe.m +++ b/+types/+untyped/DataPipe.m @@ -213,15 +213,29 @@ function append(obj, data) rank = length(obj.maxSize); stride_coords = size(data); if length(stride_coords) > rank && ~all(stride_coords(rank+1:end) == 1) - warning('Nwb:Types:Untyped:DataPipe:InvalidRank',... + warning('NWB:Types:Untyped:DataPipe:InvalidRank',... ['Expected rank %d not expected for data of size %s. '... 'Data may be lost on write.'],... rank, mat2str(size(stride_coords))); end + if length(stride_coords) < rank + new_coords = ones(1, rank); + new_coords(1:length(stride_coords)) = stride_coords; + stride_coords = new_coords; + end stride_coords = stride_coords(1:rank); - new_extents = fliplr(h5_dims); - new_extents(obj.axis) = obj.offset; - new_extents = new_extents + stride_coords; + + if any(0 == h5_dims) + new_extents = stride_coords; + else + new_extents = fliplr(h5_dims); + non_axis_map = true(1, rank); + non_axis_map(obj.axis) = false; + assert(all(stride_coords(non_axis_map) == new_extents(non_axis_map)),... + 'NWB:Types:Untyped:DataPipe:InvalidSize',... + 'Stride size must match non-axis dimensions.'); + new_extents(obj.axis) = obj.offset + stride_coords(obj.axis); + end h5_extents = fliplr(new_extents); H5D.set_extent(did, h5_extents);