From 198cf6a417a8158f303ecbe0cb8ec90564e42469 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 25 Nov 2025 13:18:47 -0600 Subject: [PATCH 1/6] improve time series message --- src/nwbinspector/checks/_time_series.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nwbinspector/checks/_time_series.py b/src/nwbinspector/checks/_time_series.py index dc3ea083..586145eb 100644 --- a/src/nwbinspector/checks/_time_series.py +++ b/src/nwbinspector/checks/_time_series.py @@ -56,10 +56,13 @@ def check_data_orientation(time_series: TimeSeries) -> Optional[InspectorMessage return None if any(np.array(data_shape[1:]) > data_shape[0]): + longest_axis = int(np.argmax(data_shape)) return InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, and is usually the " - "longest dimension. Here, another dimension is longer." + f"'{time_series.name}' data may be in the wrong orientation. " + f"Time should be the longest dimension, which is usually the first.\n" + f"Current shape: {data_shape}.\n" + f"Suggestion: Transpose so the first dimension is {data_shape[longest_axis]}." ), ) From d7d9bd9c6d1ac051a57e816b935ff072074b9d8e Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 25 Nov 2025 13:58:09 -0600 Subject: [PATCH 2/6] fix tests to correspond to the new change --- pyproject.toml | 5 +++++ tests/unit_tests/test_time_series.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7680e37e..9d1f0343 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -135,3 +135,8 @@ known-first-party = ["nwbinspector"] skip = '.git*,*.pdf,*.css' check-hidden = true ignore-words-list = 'assertin' + +[dependency-groups] +dev = [ + "pytest>=8.4.2", +] diff --git a/tests/unit_tests/test_time_series.py b/tests/unit_tests/test_time_series.py index ef96e312..da0d3fa7 100644 --- a/tests/unit_tests/test_time_series.py +++ b/tests/unit_tests/test_time_series.py @@ -66,9 +66,10 @@ def test_check_data_orientation(): ) ) == InspectorMessage( message=( - "Data may be in the wrong orientation. " - "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer." + "'test_time_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 100).\n" + "Suggestion: Transpose so the first dimension is 100." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", From b00a233955365ae0bd0a6d12d12905e9408e29fe Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 25 Nov 2025 14:06:39 -0600 Subject: [PATCH 3/6] improve text --- .../true_nwbinspector_default_report_hdf5.txt | 4 +- .../true_nwbinspector_default_report_zarr.txt | 4 +- ...nspector_report_with_dandi_config_hdf5.txt | 8 +++- ...nspector_report_with_dandi_config_zarr.txt | 8 +++- tests/test_inspector.py | 43 ++++++++++++------- 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt b/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt index 0b7a3896..1b39e872 100644 --- a/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt +++ b/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt @@ -16,7 +16,9 @@ Found 5 issues over 2 files: =========== 0.0 ./testing0.hdf5.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. + Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. +Current shape: (2, 3). +Suggestion: Transpose so the first dimension is 3. 0.1 ./testing0.hdf5.nwb: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: The length of the first dimension of data (4) does not match the length of timestamps (3). diff --git a/tests/expected_reports/true_nwbinspector_default_report_zarr.txt b/tests/expected_reports/true_nwbinspector_default_report_zarr.txt index 957e68ad..e6277997 100644 --- a/tests/expected_reports/true_nwbinspector_default_report_zarr.txt +++ b/tests/expected_reports/true_nwbinspector_default_report_zarr.txt @@ -16,7 +16,9 @@ Found 5 issues over 2 files: =========== 0.0 ./testing0.nwb.zarr: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. + Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. +Current shape: (2, 3). +Suggestion: Transpose so the first dimension is 3. 0.1 ./testing0.nwb.zarr: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: The length of the first dimension of data (4) does not match the length of timestamps (3). diff --git a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt index ae39abe6..1104743a 100644 --- a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt +++ b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt @@ -30,7 +30,9 @@ Found 10 issues over 2 files: Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps. 1.4 ./testing0.hdf5.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. + Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. +Current shape: (2, 3). +Suggestion: Transpose so the first dimension is 3. 1.5 ./testing0.hdf5.nwb: check_missing_unit - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. @@ -42,4 +44,6 @@ Found 10 issues over 2 files: Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. 1.8 ./testing1.hdf5.nwb: check_data_orientation - 'TimeSeries' object at location '/acquisition/my_spatial_series' - Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. + Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. +Current shape: (2, 3). +Suggestion: Transpose so the first dimension is 3. diff --git a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt index 934b7e5f..7caf6bfd 100644 --- a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt +++ b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt @@ -30,7 +30,9 @@ Found 10 issues over 2 files: Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps. 1.4 ./testing0.nwb.zarr: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. + Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. +Current shape: (2, 3). +Suggestion: Transpose so the first dimension is 3. 1.5 ./testing0.nwb.zarr: check_missing_unit - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. @@ -42,4 +44,6 @@ Found 10 issues over 2 files: Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. 1.8 ./testing1.nwb.zarr: check_data_orientation - 'TimeSeries' object at location '/acquisition/my_spatial_series' - Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. + Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. +Current shape: (2, 3). +Suggestion: Transpose so the first dimension is 3. diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 9548d8fb..f4c8e86f 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -240,8 +240,10 @@ def test_inspect_all(self): ), InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, and is usually " - "the longest dimension. Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.CRITICAL, severity=Severity.LOW, @@ -312,8 +314,10 @@ def test_inspect_all_parallel(self): ), InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, and is usually " - "the longest dimension. Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.CRITICAL, severity=Severity.LOW, @@ -388,8 +392,10 @@ def test_inspect_nwbfile(self): ), InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, and is usually the " - "longest dimension. Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -422,8 +428,10 @@ def test_inspect_nwbfile_importance_threshold_as_importance(self): true_results = [ InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, and is " - "usually the longest dimension. Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -456,8 +464,10 @@ def test_inspect_nwbfile_importance_threshold_as_string(self): true_results = [ InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, and is " - "usually the longest dimension. Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -620,9 +630,10 @@ def test_inspect_nwbfile_dandi_config(self): ), InspectorMessage( message=( - "Data may be in the wrong orientation. " - "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.BEST_PRACTICE_VIOLATION, # Normally CRITICAL, now a BEST_PRACTICE_VIOLATION check_function_name="check_data_orientation", @@ -777,8 +788,10 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): ), InspectorMessage( message=( - "Data may be in the wrong orientation. Time should be in the first dimension, " - "and is usually the longest dimension. Here, another dimension is longer." + "'my_spatial_series' data may be in the wrong orientation. " + "Time should be the longest dimension, which is usually the first.\n" + "Current shape: (2, 3).\n" + "Suggestion: Transpose so the first dimension is 3." ), importance=Importance.BEST_PRACTICE_VIOLATION, severity=Severity.LOW, From 24ed8009e16605cba88c4dd3706af12e5be78c60 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Tue, 25 Nov 2025 14:12:08 -0600 Subject: [PATCH 4/6] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 880ab649..9b2d111c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Improvements * Added documentation to API and CLI docs on how to use the dandi config option. [#624](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/624) +* Improved `check_data_orientation` error message to include the TimeSeries name, current shape, and a suggestion for transposing the data. [#1430](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/1430) # v0.6.5 (July 25, 2025) From 7a987922a5fddfdbd960a78b12630de00c258363 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 26 Nov 2025 14:25:05 -0600 Subject: [PATCH 5/6] correct test message --- src/nwbinspector/checks/_time_series.py | 7 ++- .../true_nwbinspector_default_report_hdf5.txt | 4 +- .../true_nwbinspector_default_report_zarr.txt | 4 +- ...nspector_report_with_dandi_config_hdf5.txt | 8 +-- ...nspector_report_with_dandi_config_zarr.txt | 8 +-- tests/test_inspector.py | 49 ++++++++----------- tests/unit_tests/test_time_series.py | 7 ++- 7 files changed, 33 insertions(+), 54 deletions(-) diff --git a/src/nwbinspector/checks/_time_series.py b/src/nwbinspector/checks/_time_series.py index 586145eb..4e4b2367 100644 --- a/src/nwbinspector/checks/_time_series.py +++ b/src/nwbinspector/checks/_time_series.py @@ -59,10 +59,9 @@ def check_data_orientation(time_series: TimeSeries) -> Optional[InspectorMessage longest_axis = int(np.argmax(data_shape)) return InspectorMessage( message=( - f"'{time_series.name}' data may be in the wrong orientation. " - f"Time should be the longest dimension, which is usually the first.\n" - f"Current shape: {data_shape}.\n" - f"Suggestion: Transpose so the first dimension is {data_shape[longest_axis]}." + f"'{time_series.name}': Data may be in the wrong orientation. " + f"Time should be in the first dimension, and is usually the longest dimension. " + f"Here, another dimension is longer. Current shape: {data_shape}." ), ) diff --git a/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt b/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt index 1b39e872..aee2d518 100644 --- a/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt +++ b/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt @@ -16,9 +16,7 @@ Found 5 issues over 2 files: =========== 0.0 ./testing0.hdf5.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. -Current shape: (2, 3). -Suggestion: Transpose so the first dimension is 3. + Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). 0.1 ./testing0.hdf5.nwb: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: The length of the first dimension of data (4) does not match the length of timestamps (3). diff --git a/tests/expected_reports/true_nwbinspector_default_report_zarr.txt b/tests/expected_reports/true_nwbinspector_default_report_zarr.txt index e6277997..d5be8a30 100644 --- a/tests/expected_reports/true_nwbinspector_default_report_zarr.txt +++ b/tests/expected_reports/true_nwbinspector_default_report_zarr.txt @@ -16,9 +16,7 @@ Found 5 issues over 2 files: =========== 0.0 ./testing0.nwb.zarr: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. -Current shape: (2, 3). -Suggestion: Transpose so the first dimension is 3. + Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). 0.1 ./testing0.nwb.zarr: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: The length of the first dimension of data (4) does not match the length of timestamps (3). diff --git a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt index 1104743a..006fc07d 100644 --- a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt +++ b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt @@ -30,9 +30,7 @@ Found 10 issues over 2 files: Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps. 1.4 ./testing0.hdf5.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. -Current shape: (2, 3). -Suggestion: Transpose so the first dimension is 3. + Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). 1.5 ./testing0.hdf5.nwb: check_missing_unit - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. @@ -44,6 +42,4 @@ Suggestion: Transpose so the first dimension is 3. Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. 1.8 ./testing1.hdf5.nwb: check_data_orientation - 'TimeSeries' object at location '/acquisition/my_spatial_series' - Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. -Current shape: (2, 3). -Suggestion: Transpose so the first dimension is 3. + Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). diff --git a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt index 7caf6bfd..df856862 100644 --- a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt +++ b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt @@ -30,9 +30,7 @@ Found 10 issues over 2 files: Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps. 1.4 ./testing0.nwb.zarr: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. -Current shape: (2, 3). -Suggestion: Transpose so the first dimension is 3. + Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). 1.5 ./testing0.nwb.zarr: check_missing_unit - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. @@ -44,6 +42,4 @@ Suggestion: Transpose so the first dimension is 3. Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. 1.8 ./testing1.nwb.zarr: check_data_orientation - 'TimeSeries' object at location '/acquisition/my_spatial_series' - Message: 'my_spatial_series' data may be in the wrong orientation. Time should be the longest dimension, which is usually the first. -Current shape: (2, 3). -Suggestion: Transpose so the first dimension is 3. + Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). diff --git a/tests/test_inspector.py b/tests/test_inspector.py index f4c8e86f..8c378e5c 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -240,10 +240,9 @@ def test_inspect_all(self): ), InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.CRITICAL, severity=Severity.LOW, @@ -314,10 +313,9 @@ def test_inspect_all_parallel(self): ), InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.CRITICAL, severity=Severity.LOW, @@ -392,10 +390,9 @@ def test_inspect_nwbfile(self): ), InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -428,10 +425,9 @@ def test_inspect_nwbfile_importance_threshold_as_importance(self): true_results = [ InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -464,10 +460,9 @@ def test_inspect_nwbfile_importance_threshold_as_string(self): true_results = [ InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -630,10 +625,9 @@ def test_inspect_nwbfile_dandi_config(self): ), InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.BEST_PRACTICE_VIOLATION, # Normally CRITICAL, now a BEST_PRACTICE_VIOLATION check_function_name="check_data_orientation", @@ -788,10 +782,9 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): ), InspectorMessage( message=( - "'my_spatial_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 3).\n" - "Suggestion: Transpose so the first dimension is 3." + "'my_spatial_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 3)." ), importance=Importance.BEST_PRACTICE_VIOLATION, severity=Severity.LOW, diff --git a/tests/unit_tests/test_time_series.py b/tests/unit_tests/test_time_series.py index da0d3fa7..6afe4679 100644 --- a/tests/unit_tests/test_time_series.py +++ b/tests/unit_tests/test_time_series.py @@ -66,10 +66,9 @@ def test_check_data_orientation(): ) ) == InspectorMessage( message=( - "'test_time_series' data may be in the wrong orientation. " - "Time should be the longest dimension, which is usually the first.\n" - "Current shape: (2, 100).\n" - "Suggestion: Transpose so the first dimension is 100." + "'test_time_series': Data may be in the wrong orientation. " + "Time should be in the first dimension, and is usually the longest dimension. " + "Here, another dimension is longer. Current shape: (2, 100)." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", From e48240a8bc826a2c2548a076304170331c0604c6 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 26 Nov 2025 14:40:31 -0600 Subject: [PATCH 6/6] restore --- src/nwbinspector/checks/_time_series.py | 6 ++- .../true_nwbinspector_default_report_hdf5.txt | 2 +- .../true_nwbinspector_default_report_zarr.txt | 2 +- ...nspector_report_with_dandi_config_hdf5.txt | 4 +- ...nspector_report_with_dandi_config_zarr.txt | 4 +- tests/test_inspector.py | 42 ++++++++++++------- tests/unit_tests/test_time_series.py | 6 ++- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/nwbinspector/checks/_time_series.py b/src/nwbinspector/checks/_time_series.py index 4e4b2367..2f093f13 100644 --- a/src/nwbinspector/checks/_time_series.py +++ b/src/nwbinspector/checks/_time_series.py @@ -59,9 +59,11 @@ def check_data_orientation(time_series: TimeSeries) -> Optional[InspectorMessage longest_axis = int(np.argmax(data_shape)) return InspectorMessage( message=( - f"'{time_series.name}': Data may be in the wrong orientation. " + f"Data may be in the wrong orientation. " f"Time should be in the first dimension, and is usually the longest dimension. " - f"Here, another dimension is longer. Current shape: {data_shape}." + f"Here, another dimension is longer. " + f"Current shape: {data_shape}. " + f"Suggestion: Transpose your data so the first dimension is {data_shape[longest_axis]}." ), ) diff --git a/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt b/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt index aee2d518..997127eb 100644 --- a/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt +++ b/tests/expected_reports/true_nwbinspector_default_report_hdf5.txt @@ -16,7 +16,7 @@ Found 5 issues over 2 files: =========== 0.0 ./testing0.hdf5.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). + Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). Suggestion: Transpose your data so the first dimension is 3. 0.1 ./testing0.hdf5.nwb: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: The length of the first dimension of data (4) does not match the length of timestamps (3). diff --git a/tests/expected_reports/true_nwbinspector_default_report_zarr.txt b/tests/expected_reports/true_nwbinspector_default_report_zarr.txt index d5be8a30..9dac8a3a 100644 --- a/tests/expected_reports/true_nwbinspector_default_report_zarr.txt +++ b/tests/expected_reports/true_nwbinspector_default_report_zarr.txt @@ -16,7 +16,7 @@ Found 5 issues over 2 files: =========== 0.0 ./testing0.nwb.zarr: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). + Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). Suggestion: Transpose your data so the first dimension is 3. 0.1 ./testing0.nwb.zarr: check_timestamps_match_first_dimension - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: The length of the first dimension of data (4) does not match the length of timestamps (3). diff --git a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt index 006fc07d..0f9caa3b 100644 --- a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt +++ b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_hdf5.txt @@ -30,7 +30,7 @@ Found 10 issues over 2 files: Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps. 1.4 ./testing0.hdf5.nwb: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). + Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). Suggestion: Transpose your data so the first dimension is 3. 1.5 ./testing0.hdf5.nwb: check_missing_unit - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. @@ -42,4 +42,4 @@ Found 10 issues over 2 files: Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. 1.8 ./testing1.hdf5.nwb: check_data_orientation - 'TimeSeries' object at location '/acquisition/my_spatial_series' - Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). + Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). Suggestion: Transpose your data so the first dimension is 3. diff --git a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt index df856862..99763966 100644 --- a/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt +++ b/tests/expected_reports/true_nwbinspector_report_with_dandi_config_zarr.txt @@ -30,7 +30,7 @@ Found 10 issues over 2 files: Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps. 1.4 ./testing0.nwb.zarr: check_data_orientation - 'SpatialSeries' object at location '/processing/behavior/Position/my_spatial_series' - Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). + Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). Suggestion: Transpose your data so the first dimension is 3. 1.5 ./testing0.nwb.zarr: check_missing_unit - 'TimeSeries' object at location '/acquisition/test_time_series_3' Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. @@ -42,4 +42,4 @@ Found 10 issues over 2 files: Message: Missing text for attribute 'unit'. Please specify the scientific unit of the 'data'. 1.8 ./testing1.nwb.zarr: check_data_orientation - 'TimeSeries' object at location '/acquisition/my_spatial_series' - Message: 'my_spatial_series': Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). + Message: Data may be in the wrong orientation. Time should be in the first dimension, and is usually the longest dimension. Here, another dimension is longer. Current shape: (2, 3). Suggestion: Transpose your data so the first dimension is 3. diff --git a/tests/test_inspector.py b/tests/test_inspector.py index 8c378e5c..aae8a28b 100644 --- a/tests/test_inspector.py +++ b/tests/test_inspector.py @@ -240,9 +240,11 @@ def test_inspect_all(self): ), InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.CRITICAL, severity=Severity.LOW, @@ -313,9 +315,11 @@ def test_inspect_all_parallel(self): ), InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.CRITICAL, severity=Severity.LOW, @@ -390,9 +394,11 @@ def test_inspect_nwbfile(self): ), InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -425,9 +431,11 @@ def test_inspect_nwbfile_importance_threshold_as_importance(self): true_results = [ InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -460,9 +468,11 @@ def test_inspect_nwbfile_importance_threshold_as_string(self): true_results = [ InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation", @@ -625,9 +635,11 @@ def test_inspect_nwbfile_dandi_config(self): ), InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.BEST_PRACTICE_VIOLATION, # Normally CRITICAL, now a BEST_PRACTICE_VIOLATION check_function_name="check_data_orientation", @@ -782,9 +794,11 @@ def test_inspect_nwbfile_dandi_config_violation_and_above_entire_registry(self): ), InspectorMessage( message=( - "'my_spatial_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 3)." + "Here, another dimension is longer. " + "Current shape: (2, 3). " + "Suggestion: Transpose your data so the first dimension is 3." ), importance=Importance.BEST_PRACTICE_VIOLATION, severity=Severity.LOW, diff --git a/tests/unit_tests/test_time_series.py b/tests/unit_tests/test_time_series.py index 6afe4679..dd37423c 100644 --- a/tests/unit_tests/test_time_series.py +++ b/tests/unit_tests/test_time_series.py @@ -66,9 +66,11 @@ def test_check_data_orientation(): ) ) == InspectorMessage( message=( - "'test_time_series': Data may be in the wrong orientation. " + "Data may be in the wrong orientation. " "Time should be in the first dimension, and is usually the longest dimension. " - "Here, another dimension is longer. Current shape: (2, 100)." + "Here, another dimension is longer. " + "Current shape: (2, 100). " + "Suggestion: Transpose your data so the first dimension is 100." ), importance=Importance.CRITICAL, check_function_name="check_data_orientation",