Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* Dropped Python 3.9 and middle Python versions (3.11, 3.12) from CI; now testing only Python 3.10 and 3.13. [#632](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/632)
* Updated macOS CI runner from `macos-13` to `macos-latest`. [#639](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/639)

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,8 @@ known-first-party = ["nwbinspector"]
skip = '.git*,*.pdf,*.css'
check-hidden = true
ignore-words-list = 'assertin'

[dependency-groups]
dev = [
"pytest>=8.4.2",
]
8 changes: 6 additions & 2 deletions src/nwbinspector/checks/_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ 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"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. "
f"Current shape: {data_shape}. "
f"Suggestion: Transpose your data so the first dimension is {data_shape[longest_axis]}."
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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: 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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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: 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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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: 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'.
Expand All @@ -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: 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: 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.
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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: 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'.
Expand All @@ -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: 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: 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.
46 changes: 33 additions & 13 deletions tests/test_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ 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."
"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."
),
importance=Importance.CRITICAL,
severity=Severity.LOW,
Expand Down Expand Up @@ -312,8 +315,11 @@ 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."
"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."
),
importance=Importance.CRITICAL,
severity=Severity.LOW,
Expand Down Expand Up @@ -388,8 +394,11 @@ 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."
"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."
),
importance=Importance.CRITICAL,
check_function_name="check_data_orientation",
Expand Down Expand Up @@ -422,8 +431,11 @@ 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."
"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."
),
importance=Importance.CRITICAL,
check_function_name="check_data_orientation",
Expand Down Expand Up @@ -456,8 +468,11 @@ 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."
"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."
),
importance=Importance.CRITICAL,
check_function_name="check_data_orientation",
Expand Down Expand Up @@ -622,7 +637,9 @@ def test_inspect_nwbfile_dandi_config(self):
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."
"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",
Expand Down Expand Up @@ -777,8 +794,11 @@ 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."
"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."
),
importance=Importance.BEST_PRACTICE_VIOLATION,
severity=Severity.LOW,
Expand Down
4 changes: 3 additions & 1 deletion tests/unit_tests/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def test_check_data_orientation():
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."
"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",
Expand Down
Loading