Skip to content

Commit

Permalink
Add "in_mm", add example usage, update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Apr 21, 2024
1 parent d08b2cb commit 2a0d0ff
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 48 deletions.
26 changes: 13 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ authors = [
]
description = "NWB extension for storing extracellular probe and channels metadata"
readme = "README.md"
# requires-python = ">=3.8"
requires-python = ">=3.8"
license = {text = "BSD-3"}
classifiers = [
# TODO: add classifiers before release
# "Programming Language :: Python",
# "Programming Language :: Python :: 3.8",
# "Programming Language :: Python :: 3.9",
# "Programming Language :: Python :: 3.10",
# "Programming Language :: Python :: 3.11",
# "Programming Language :: Python :: 3.12",
# "Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
Expand All @@ -44,12 +43,12 @@ dependencies = [
]

# TODO: add URLs before release
# [project.urls]
# "Homepage" = "https://github.com/organization/package"
[project.urls]
"Homepage" = "https://github.com/catalystneuro/ndx-extracellular-channels"
# "Documentation" = "https://package.readthedocs.io/"
# "Bug Tracker" = "https://github.com/organization/package/issues"
"Bug Tracker" = "https://github.com/catalystneuro/ndx-extracellular-channels/issues"
# "Discussions" = "https://github.com/organization/package/discussions"
# "Changelog" = "https://github.com/organization/package/blob/main/CHANGELOG.md"
"Changelog" = "https://github.com/catalystneuro/ndx-extracellular-channels/blob/main/CHANGELOG.md"

[tool.hatch.build]
include = [
Expand Down Expand Up @@ -116,6 +115,7 @@ line-length = 120
[tool.ruff.per-file-ignores]
"src/pynwb/ndx_extracellular_channels/__init__.py" = ["E402", "F401"]
"src/spec/create_extension_spec.py" = ["T201"]
"src/pynwb/tests/test_example_usage_all.py" = ["T201"]

[tool.ruff.mccabe]
max-complexity = 17
8 changes: 4 additions & 4 deletions spec/ndx-extracellular-channels.extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ groups:
doc: Metadata about the contacts of a probe, compatible with the ProbeInterface
specification.
datasets:
- name: relative_position
- name: relative_position_in_mm
neurodata_type_inc: VectorData
dtype: float
dims:
Expand All @@ -18,7 +18,7 @@ groups:
- 2
- - null
- 3
doc: Relative position of the contact
doc: Relative position of the contact in millimeters, relative to `reference`.
attributes:
- name: reference
dtype: text
Expand Down Expand Up @@ -179,7 +179,7 @@ groups:
doc: The filter used on the raw (wideband) voltage data from this contact, including
the filter name and frequency cutoffs, e.g., 'High-pass filter at 300 Hz.'
quantity: '?'
- name: estimated_position
- name: estimated_position_in_mm
neurodata_type_inc: VectorData
dtype:
- name: ap
Expand Down Expand Up @@ -207,7 +207,7 @@ groups:
dtype: text
doc: The brain area of the estimated contact position, e.g., 'CA1'.
quantity: '?'
- name: actual_position
- name: actual_position_in_mm
neurodata_type_inc: VectorData
dtype:
- name: ap
Expand Down
54 changes: 27 additions & 27 deletions src/pynwb/tests/test_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_constructor_add_row(self):

# for testing, mix and match different shapes. np.nan means the radius/width/height does not apply
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
contact_id="C1",
shank_id="shank0",
Expand All @@ -46,7 +46,7 @@ def test_constructor_add_row(self):
)

ct.add_row(
relative_position=[20.0, 10.0],
relative_position_in_mm=[20.0, 10.0],
shape="square",
contact_id="C2",
shank_id="shank0",
Expand All @@ -59,13 +59,13 @@ def test_constructor_add_row(self):

# TODO might be nice to put this on the constructor of ContactsTable as relative_position__reference
# without using a custom mapper
ct["relative_position"].reference = "The bottom tip of the probe"
ct["relative_position_in_mm"].reference = "The bottom tip of the probe"

assert ct.name == "ContactsTable"
assert ct.description == "Test contacts table"
assert ct["relative_position"].reference == "The bottom tip of the probe"
assert ct["relative_position_in_mm"].reference == "The bottom tip of the probe"

assert ct["relative_position"].data == [[10.0, 10.0], [20.0, 10.0]]
assert ct["relative_position_in_mm"].data == [[10.0, 10.0], [20.0, 10.0]]
assert ct["shape"].data == ["circle", "square"]
assert ct["contact_id"].data == ["C1", "C2"]
assert ct["shank_id"].data == ["shank0", "shank0"]
Expand All @@ -89,7 +89,7 @@ def addContainer(self):

# for testing, mix and match different shapes. np.nan means the radius/width/height does not apply
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
contact_id="C1",
shank_id="shank0",
Expand All @@ -101,7 +101,7 @@ def addContainer(self):
)

ct.add_row(
relative_position=[20.0, 10.0],
relative_position_in_mm=[20.0, 10.0],
shape="square",
contact_id="C2",
shank_id="shank0",
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_constructor(self):
description="Test contacts table",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)

Expand Down Expand Up @@ -162,7 +162,7 @@ def addContainer(self):
description="Test contacts table",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)

Expand Down Expand Up @@ -191,7 +191,7 @@ def test_constructor_minimal(self):
description="Test contacts table",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)

Expand Down Expand Up @@ -219,7 +219,7 @@ def test_constructor(self):
description="Test contacts table",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)

Expand Down Expand Up @@ -252,7 +252,7 @@ def addContainer(self):
description="Test contacts table",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)

Expand Down Expand Up @@ -283,15 +283,15 @@ def _create_test_probe():
description="Test contacts table",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)
ct.add_row(
relative_position=[10.0, 10.0],
relative_position_in_mm=[10.0, 10.0],
shape="circle",
)

Expand Down Expand Up @@ -419,26 +419,26 @@ def test_constructor_add_row(self):
contact=0,
reference_contact=2,
filter="High-pass at 300 Hz",
estimated_position=[-1.5, 2.5, -2.5],
estimated_position_in_mm=[-1.5, 2.5, -2.5],
estimated_brain_area="CA3",
actual_position=[-1.5, 2.4, -2.4],
actual_position_in_mm=[-1.5, 2.4, -2.4],
actual_brain_area="CA3",
)

ct.add_row(
contact=1,
reference_contact=2,
filter="High-pass at 300 Hz",
estimated_position=[-1.5, 2.5, -2.4],
estimated_position_in_mm=[-1.5, 2.5, -2.4],
estimated_brain_area="CA3",
actual_position=[-1.5, 2.4, -2.3],
actual_position_in_mm=[-1.5, 2.4, -2.3],
actual_brain_area="CA3",
)

# TODO might be nice to put this on the constructor of ContactsTable as relative_position__reference
# without using a custom mapper
ct["estimated_position"].reference = "Bregma at the cortical surface"
ct["actual_position"].reference = "Bregma at the cortical surface"
ct["estimated_position_in_mm"].reference = "Bregma at the cortical surface"
ct["actual_position_in_mm"].reference = "Bregma at the cortical surface"

# TODO
assert ct.name == "Neuropixels1ChannelsTable"
Expand Down Expand Up @@ -477,27 +477,27 @@ def addContainer(self):
contact=0,
reference_contact=2,
filter="High-pass at 300 Hz",
estimated_position=[-1.5, 2.5, -2.5],
estimated_position_in_mm=[-1.5, 2.5, -2.5],
estimated_brain_area="CA3",
actual_position=[-1.5, 2.4, -2.4],
actual_position_in_mm=[-1.5, 2.4, -2.4],
actual_brain_area="CA3",
)

ct.add_row(
contact=1,
reference_contact=2,
filter="High-pass at 300 Hz",
estimated_position=[-1.5, 2.5, -2.4],
estimated_position_in_mm=[-1.5, 2.5, -2.4],
estimated_brain_area="CA3",
actual_position=[-1.5, 2.4, -2.3],
actual_position_in_mm=[-1.5, 2.4, -2.3],
actual_brain_area="CA3",
)

# TODO might be nice to put this on the constructor of ContactsTable as relative_position__reference
# without using a custom mapper
# TODO does matching this happen in the container equals roundtrip test?
ct["estimated_position"].reference = "Bregma at the cortical surface"
ct["actual_position"].reference = "Bregma at the cortical surface"
ct["estimated_position_in_mm"].reference = "Bregma at the cortical surface"
ct["actual_position_in_mm"].reference = "Bregma at the cortical surface"

# put this in nwbfile.acquisition for testing
self.nwbfile.add_acquisition(ct)
Expand Down
Loading

0 comments on commit 2a0d0ff

Please sign in to comment.