From 5aa27d92cba1b9136612cc8ab80d0c1791975997 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Mon, 4 Nov 2024 20:28:45 +0100 Subject: [PATCH] Update load_mat_style.m (#602) * Update load_mat_style.m * Update PynwbTutorialTest.m Add plot_read_basics to list of tutorials to skip. This tutorial does not produce NWB files that can be read with matnwb. * Simplify fix for load_mat_style --- +tests/+unit/PynwbTutorialTest.m | 5 +++-- +types/+untyped/@DataStub/load_mat_style.m | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/+tests/+unit/PynwbTutorialTest.m b/+tests/+unit/PynwbTutorialTest.m index 6f687c15..93113a56 100644 --- a/+tests/+unit/PynwbTutorialTest.m +++ b/+tests/+unit/PynwbTutorialTest.m @@ -21,6 +21,7 @@ properties (Constant) % SkippedTutorials - Tutorials from pynwb to skip SkippedTutorials = {... + 'plot_read_basics.py', ... % Downloads file from dandi archive, does not export nwb file 'streaming.py', ... % Requires that HDF5 library is installed with the ROS3 driver enabled which is not a given 'object_id.py', ... % Does not export nwb file 'plot_configurator.py', ... % Does not export nwb file @@ -31,7 +32,7 @@ SkippedFiles = {'family_nwb_file_0.nwb'} % requires family driver from h5py % PythonDependencies - Package dependencies for running pynwb tutorials - PythonDependencies = {'hdmf-zarr', 'dataframe-image', 'matplotlib', 'dandi'} + PythonDependencies = {'hdmf-zarr', 'dataframe-image', 'matplotlib'} end properties (Access = private) @@ -101,7 +102,7 @@ function testTutorial(testCase, tutorialFile) pythonPath = tests.util.getPythonPath(); - cmd = sprintf('"%s" %s', pythonPath, tutorialFile ); + cmd = sprintf('%s %s', pythonPath, tutorialFile); [status, cmdout] = system(cmd); if status == 1 diff --git a/+types/+untyped/@DataStub/load_mat_style.m b/+types/+untyped/@DataStub/load_mat_style.m index a6fa1f16..f32312c0 100644 --- a/+types/+untyped/@DataStub/load_mat_style.m +++ b/+types/+untyped/@DataStub/load_mat_style.m @@ -46,6 +46,18 @@ end points = cell(length(dataDimensions), 1); + + if isscalar(dataDimensions) + % Starting in MATLAB R2024b, the input argument for the size + % of an array in ind2sub must be a vector of positive integers + % with two or more elements. This fix replicates the behavior of + % older MATLAB versions, where it was assumed that the a scalar + % size referred to the row dimension. For scalar dimensions + % (i.e., row or column vectors), we can still assume this + % to be true in matnwb. + dataDimensions = [dataDimensions, 1]; + end + [points{:}] = ind2sub(dataDimensions, orderedSelection); readSpaceId = H5S.copy(spaceId); H5S.select_none(readSpaceId); @@ -187,4 +199,4 @@ indexKeyIndex(indexKeyIndexNextIndex) = indexKeyIndex(indexKeyIndexNextIndex) + 1; indexKeyIndex((indexKeyIndexNextIndex+1):end) = 1; end -end \ No newline at end of file +end