Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check for existence of IntracellularElectrode.cell_id #256

Merged
merged 3 commits into from
Aug 24, 2022
Merged
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 @@ -2,3 +2,4 @@

### Improvements
* Enhanced human-readability of the return message from `check_experimenter_form`. [PR #254](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/254)
* Add check for existence of ``IntracellularElectrode.cell_id`` (#256)
1 change: 1 addition & 0 deletions nwbinspector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
from .checks.ophys import *
from .checks.tables import *
from .checks.time_series import *
from .checks.icephys import *
10 changes: 10 additions & 0 deletions nwbinspector/checks/icephys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pynwb.icephys import IntracellularElectrode

from ..register_checks import register_check, Importance, InspectorMessage


@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=IntracellularElectrode)
def check_intracellular_electrode_cell_id_exists(intracellular_electrode: IntracellularElectrode):
"""Check if the IntracellularElectrode contains a cell_id."""
if intracellular_electrode.cell_id is None:
return InspectorMessage(message="Please include a unique cell_id associated with this IntracellularElectrode.")
23 changes: 23 additions & 0 deletions tests/unit_tests/test_icephys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pynwb.icephys import IntracellularElectrode
from pynwb.device import Device

from nwbinspector import InspectorMessage, Importance, check_intracellular_electrode_cell_id_exists


def test_pass_check_intracellular_electrode_cell_id_exists():
device = Device(name="device")
ielec = IntracellularElectrode(name="ielec", cell_id="123", device=device, description="an intracellular electrode")
assert check_intracellular_electrode_cell_id_exists(ielec) is None


def test_fail_check_intracellular_electrode_cell_id_exists():
device = Device(name="device")
ielec = IntracellularElectrode(name="ielec", device=device, description="an intracellular electrode")
assert check_intracellular_electrode_cell_id_exists(ielec) == InspectorMessage(
message="Please include a unique cell_id associated with this IntracellularElectrode.",
importance=Importance.BEST_PRACTICE_VIOLATION,
check_function_name="check_intracellular_electrode_cell_id_exists",
object_type="IntracellularElectrode",
object_name="ielec",
location="/",
)