Skip to content

Commit

Permalink
Merge branch 'dev' into add_dandi_inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Sep 3, 2024
2 parents 1528086 + a642a3c commit 078fbb3
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 81 deletions.
20 changes: 10 additions & 10 deletions docs/api/checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ Check Functions

NWBFile Metadata
----------------
.. automodule:: nwbinspector.checks.nwbfile_metadata
.. automodule:: nwbinspector.checks._nwbfile_metadata

NWB Containers
--------------
.. automodule:: nwbinspector.checks.nwb_containers
.. automodule:: nwbinspector.checks._nwb_containers

Time Series
-----------
.. automodule:: nwbinspector.checks.time_series
.. automodule:: nwbinspector.checks._time_series

Tables
------
.. automodule:: nwbinspector.checks.tables
.. automodule:: nwbinspector.checks._tables

Behavior
--------
.. automodule:: nwbinspector.checks.behavior
.. automodule:: nwbinspector.checks._behavior

Intracellular Electrophysiology (icephys)
-----------------------------------------
.. automodule:: nwbinspector.checks.icephys
.. automodule:: nwbinspector.checks._icephys

Extracellular Electrophysiology (ecephys)
-----------------------------------------
.. automodule:: nwbinspector.checks.ecephys
.. automodule:: nwbinspector.checks._ecephys

Optical Electrophysiology (ophys)
---------------------------------
.. automodule:: nwbinspector.checks.ophys
.. automodule:: nwbinspector.checks._ophys

Optogenetics (ogen)
-------------------
.. automodule:: nwbinspector.checks.ogen
.. automodule:: nwbinspector.checks._ogen

ImageSeries
-----------
.. automodule:: nwbinspector.checks.image_series
.. automodule:: nwbinspector.checks._image_series
6 changes: 3 additions & 3 deletions docs/best_practices/behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SpatialSeries Dimensionality

:ref:`nwb-schema:sec-SpatialSeries` should have 1 column (x), 2 columns (x, y), or 3 columns (x, y, z).

Check function: :py:meth:`~nwbinspector.checks.behavior.check_spatial_series_dims`
Check function: :py:meth:`~nwbinspector.checks._behavior.check_spatial_series_dims`


.. _best_practice_spatial_series_units:
Expand All @@ -25,7 +25,7 @@ SpatialSeries Units
When a :ref:`nwb-schema:sec-SpatialSeries` is in a :ref:`nwb-schema:sec-CompassDirection`, the units should either be
"degrees" or "radians".

Check function: :py:meth:`~nwbinspector.checks.behavior.check_compass_direction_unit`
Check function: :py:meth:`~nwbinspector.checks._behavior.check_compass_direction_unit`


.. _best_practice_spatial_series_values:
Expand All @@ -37,4 +37,4 @@ When a :ref:`nwb-schema:sec-SpatialSeries` has units "radians", it should have d
:ref:`nwb-schema:sec-SpatialSeries` has units "degrees", it should have data values between -360 and 360.

Check functions: :py:meth:`~nwbinspector.checks.behavior.check_spatial_series_radians_magnitude`,
:py:meth:`~nwbinspector.checks.behavior.check_spatial_series_degrees_magnitude`
:py:meth:`~nwbinspector.checks._behavior.check_spatial_series_degrees_magnitude`
4 changes: 2 additions & 2 deletions docs/best_practices/ecephys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ All spike times should be greater than zero. Being less than zero implies the sp
should therefore be aligned to the ``timestamps_reference_time`` of the :ref:`nwb-schema:sec-NWBFile`) or the
``timestamps_reference_time`` itself is not set to the earliest recording time during the session.

Check function: :py:meth:`~nwbinspector.checks.ecephys.check_negative_spike_times`
Check function: :py:meth:`~nwbinspector.checks._ecephys.check_negative_spike_times`



Expand All @@ -88,4 +88,4 @@ Observation Intervals

The ``obs_intervals`` field of the :ref:`nwb-schema:sec-units-src` table is used to indicate periods of time where the underlying electrical signal(s) were not observed. This can happen if the recording site moves away from the unit, or if the recording is stopped. Since the channel is not observed, it is not determinable whether a spike occurred during this time. Therefore, there should not be any identified spike times for units matched to those electrical signal(s) occurring outside of the defined ``obs_intervals``. If this variable is not set, it is assumed that all time is observed.

Check function: :py:meth:`~nwbinspector.checks.ecephys.check_spike_times_not_in_unobserved_interval`
Check function: :py:meth:`~nwbinspector.checks._ecephys.check_spike_times_not_in_unobserved_interval`
4 changes: 2 additions & 2 deletions docs/best_practices/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Slash characters ``'/'`` and ``'\'`` should not be used in the ``name`` of an o

For mathematical expressions, instead of including the special character in the name, please use an English equivalent instead. *E.g.*, instead of "Df/f" use "DfOverF".

Check function: :py:meth:`~nwbinspector.checks.general.check_name_slashes`
Check function: :py:meth:`~nwbinspector.checks._general.check_name_slashes`



Expand All @@ -55,7 +55,7 @@ The :py:attr:`name` of an object is for identifying that object within the file;

It is acceptable to name an object something like ``ElectricalSeriesFromProbe1`` as per the uniqueness requirement of :ref:`best_practice_object_names`, however the name alone is not sufficient documentation of the signal source. In this case, the source of the signal will be clear from the :ref:`nwb-schema:devices` linkage in the rows of the passed :ref:`hdmf-schema:sec-dynamictableregion` subsetting the full ``ElectrodeTable``, so you would not need to add any explicit metadata explaining these details.

Check function: :py:meth:`~nwbinspector.checks.general.check_description`
Check function: :py:meth:`~nwbinspector.checks._general.check_description`



Expand Down
4 changes: 2 additions & 2 deletions docs/best_practices/image_series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ an external file. That is, the file should be packaged together with the nwb fil
This can be accomplished by using the ``external_file`` file option to store the path instead. This is preferred for
videos because it allows the usage of video compression codecs that are lossy and highly optimized for such videos.

Check function: :py:meth:`~nwbinspector.checks.image_series.check_image_series_data_size`
Check function: :py:meth:`~nwbinspector.checks._image_series.check_image_series_data_size`


Use internal dataset for videos of neurophysiological data
Expand All @@ -32,4 +32,4 @@ Use relative path for external mode

When using ``external_file`` the paths passed in the ``external_file`` option should be relative to the location of the nwb file.

Check function: :py:meth:`~nwbinspector.checks.image_series.check_image_series_external_file_relative`
Check function: :py:meth:`~nwbinspector.checks._image_series.check_image_series_external_file_relative`
28 changes: 14 additions & 14 deletions docs/best_practices/nwbfile_metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ value. Default values should generally not be used for this field. If the true d
best guess. If the exact start time is unknown, then it is fine to simply set it to midnight on that date.


Check functions: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_session_start_time_old_date`,
:py:meth:`~nwbinspector.checks.nwbfile_metadata.check_session_start_time_future_date`,
:py:meth:`~nwbinspector.checks.time_series.check_timestamp_of_the_first_sample_is_not_negative`
:py:meth:`~nwbinspector.checks.tables.check_table_time_columns_are_not_negative`
Check functions: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_session_start_time_old_date`,
:py:meth:`~nwbinspector.checks._nwbfile_metadata.check_session_start_time_future_date`,
:py:meth:`~nwbinspector.checks._time_series.check_timestamp_of_the_first_sample_is_not_negative`
:py:meth:`~nwbinspector.checks._tables.check_table_time_columns_are_not_negative`



Expand Down Expand Up @@ -65,7 +65,7 @@ The name of any given processing module should be chosen from the following type
modalities. It also helps distinguish components of a given experiment, such as decoupling the intermediate data from
neural acquisition systems from behavioral ones.

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_processing_module_name`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_processing_module_name`



Expand Down Expand Up @@ -103,7 +103,7 @@ Experimenter

The ``experimenter`` field of an :ref:`nwb-schema:sec-NWBFile` should be specified as any of the accepted forms: 'LastName, Firstname', 'LastName, FirstName MiddleInitial.' or 'LastName, FirstName MiddleName'.

Check functions: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_experimenter_exists` and :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_experimenter_form`
Check functions: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_experimenter_exists` and :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_experimenter_form`



Expand All @@ -115,7 +115,7 @@ Experiment Description
The ``experiment_description`` field of an :ref:`nwb-schema:sec-NWBFile` should be specified. This helps provide
context for understanding the contents of the file.

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_experiment_description`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_experiment_description`



Expand All @@ -127,7 +127,7 @@ Institution
The ``institution`` field should be specified. This allows metadata collection programs, such as those on the
:dandi-archive:`DANDI archive <>` to easily scan NWBFiles to deliver summary statistics.

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_institution`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_institution`



Expand Down Expand Up @@ -159,7 +159,7 @@ of the form ``'doi: ###'`` or as an external link of the form ``'http://dx.doi.o
This allows metadata collection programs, such as those on the :dandi-archive:`DANDI archive <>` to easily form direct
hyperlinks to the publications.
Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_doi_publications`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_doi_publications`
Expand All @@ -171,7 +171,7 @@ Subject
It is recommended to always include as many details about the experimental subject as possible. If the data is
simulated, a simple ID of "simulated_subject" would be sufficient.
Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_subject_exists`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_subject_exists`
Expand All @@ -186,7 +186,7 @@ not intended for DANDI upload, if the :ref:`nwb-schema:sec-Subject` is specified

In the special case of *in vitro* studies where the 'subject' of scientific interest was not a tissue sample obtained from a living subject but was instead a purified protein, this will be annotated by prepending the keyphrase "protein" to the subject ID; *e.g*, "proteinCaMPARI3". In the case where the *in vitro* experiment is performed on an extracted or cultured biological sample, the other subject attributes (such as age and sex) should be specified as their values at the time the sample was collected.

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_subject_id_exists`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_subject_id_exists`



Expand All @@ -200,7 +200,7 @@ following four possibilities: "M" (male), "F" (female), "U" (unknown), or "O" (o

C. elegans are an exception to this rule. For C. elegans, the sex should either be "XO" (male) or "XX" (hermaphrodite).

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_subject_sex`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_subject_sex`



Expand All @@ -211,7 +211,7 @@ Subject Species

The ``species`` of a :ref:`nwb-schema:sec-Subject` should be set to the proper :wikipedia:`Latin binomial <Binomial_nomenclature>` or otherwise a full link to the Term IRI for the :ncbi:`NCBI Taxonomy <>`, which can be easily found at the :ontobee:`Ontobee <>` database. *E.g.*, a rat would be "Rattus norvegicus" or "http://purl.obolibrary.org/obo/NCBITaxon_10116".

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_subject_species_form`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_subject_species_form`



Expand All @@ -235,7 +235,7 @@ If the precise age is unknown, an age range can be given by "[lower bound]/[uppe
that the age is in between 10 and 20 days. If only the lower bound is known, then including only the slash after that lower bound can be used to indicate a
missing bound. For instance, "P90Y/" would indicate that the age is 90 years or older.

Check function: :py:meth:`~nwbinspector.checks.nwbfile_metadata.check_subject_age`
Check function: :py:meth:`~nwbinspector.checks._nwbfile_metadata.check_subject_age`



Expand Down
2 changes: 1 addition & 1 deletion docs/best_practices/ogen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ OptogeneticSeries
Each :ref:`nwb-schema:sec-OptogeneticStimulusSite` object should be referenced by at least one
:ref:`nwb-schema:sec-OptogeneticSeries` in the same file.

Check function: :py:meth:`~nwbinspector.checks.ogen.check_optogenetic_stimulus_site_has_optogenetic_series`
Check function: :py:meth:`~nwbinspector.checks._ogen.check_optogenetic_stimulus_site_has_optogenetic_series`
8 changes: 4 additions & 4 deletions docs/best_practices/tables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Table Values

String-valued table entries should not contain :wikipedia:`JSON <JSON>`. Instead, these values should be unpacked and used as additional columns of that table.

Check function: :py:meth:`~nwbinspector.checks.tables.check_table_values_for_dict`
Check function: :py:meth:`~nwbinspector.checks._tables.check_table_values_for_dict`



Expand All @@ -32,7 +32,7 @@ Tables With Only a Single Row

It is not common to save a table with only a single row entry. Consider other ``neurodata_types``, such as a one-dimensional :ref:`nwb-schema:sec-TimeSeries`.

Check function: :py:meth:`~nwbinspector.checks.tables.check_single_row`
Check function: :py:meth:`~nwbinspector.checks._tables.check_single_row`



Expand All @@ -44,7 +44,7 @@ Tables With an Entire Column as ``NaN``
If an entire column of a :ref:`hdmf-schema:sec-dynamictable` would be filled with ``NaN`` values, then it should not be written.


Check function: :py:meth:`~nwbinspector.checks.tables.check_col_not_nan`
Check function: :py:meth:`~nwbinspector.checks._tables.check_col_not_nan`



Expand All @@ -56,7 +56,7 @@ Table Region Data
Store data with long columns rather than long rows. When constructing dynamic tables, keep in mind that the data is
stored by column, so it will be less efficient to store data in a table that has many more columns than rows.

Check function :py:meth:`~nwbinspector.checks.tables.check_dynamic_table_region_data_validity`
Check function :py:meth:`~nwbinspector.checks._tables.check_dynamic_table_region_data_validity`



Expand Down
20 changes: 10 additions & 10 deletions docs/best_practices/time_series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Keep in mind that the dimensions are reversed in MatNWB, so in memory in MatNWB

In PyNWB the order of the dimensions is the same in memory as on disk, so the time index should be first.

Check functions: :py:meth:`~nwbinspector.checks.time_series.check_data_orientation` and
:py:meth:`~nwbinspector.checks.time_series.check_timestamps_match_first_dimension`
Check functions: :py:meth:`~nwbinspector.checks._time_series.check_data_orientation` and
:py:meth:`~nwbinspector.checks._time_series.check_timestamps_match_first_dimension`



Expand All @@ -35,7 +35,7 @@ Every :ref:`nwb-schema:sec-TimeSeries` instance has ``unit`` as an attribute, wh
measurement for that data, using the appropriate type from the
:wikipedia:`International System of Units (SI) <International_System_of_Units>`.

Check function: :py:meth:`~nwbinspector.checks.time_series.check_missing_unit`
Check function: :py:meth:`~nwbinspector.checks._time_series.check_missing_unit`



Expand Down Expand Up @@ -82,7 +82,7 @@ A primary implication is that the values in :ref:`nwb-schema:TimeSeries.timestam
corresponding ordering of their indices in the :ref:`nwb-schema:TimeSeries.data <sec-TimeSeries>` array, should always
be strictly increasing.

Check function: :py:meth:`~nwbinspector.checks.time_series.check_timestamps_ascending`
Check function: :py:meth:`~nwbinspector.checks._time_series.check_timestamps_ascending`



Expand All @@ -98,7 +98,7 @@ Ensure that all timestamps are valid numerical values. If gaps in time need to b
data into separate :ref:`nwb-schema:sec-TimeSeries` objects with appropriate ``starting_time`` or use the ``timestamps``
vector to explicitly represent time gaps.

Check function: :py:meth:`~nwbinspector.checks.time_series.check_timestamps_without_nans`
Check function: :py:meth:`~nwbinspector.checks._time_series.check_timestamps_without_nans`



Expand All @@ -120,7 +120,7 @@ For segmented data, refer to the section covering :ref:`best_practice_timestamps
2. Even if the sampling rate is constant within each segment, a single :ref:`nwb-schema:sec-TimeSeries` can be
written using the ``timestamps`` vector to appropriately indicate the gaps between segments.

Check function: :py:meth:`~nwbinspector.checks.time_series.check_regular_timestamps`
Check function: :py:meth:`~nwbinspector.checks._time_series.check_regular_timestamps`



Expand Down Expand Up @@ -161,8 +161,8 @@ chunk individually. This is especially important when writing NWBFiles that are
:pynwb-docs:`PyNWB tutorial <tutorials/advanced_io/h5dataio.html#compression-and-other-i-o-filters>` or the
`MatNWB instructions <https://neurodatawithoutborders.github.io/matnwb/tutorials/html/dataPipe.html#2>`_

Check functions: :py::meth:`~nwbinspector.checks.nwb_containers.check_large_dataset_compression`,
:py::meth:`~nwbinspector.checks.nwb_containers.check_small_dataset_compression`
Check functions: :py::meth:`~nwbinspector.checks._nwb_containers.check_large_dataset_compression`,
:py::meth:`~nwbinspector.checks._nwb_containers.check_small_dataset_compression`



Expand All @@ -173,7 +173,7 @@ Unknown Resolution

If the ``resolution`` of a :ref:`nwb-schema:sec-TimeSeries` is unknown, use ``-1.0`` or ``NaN`` to indicate this.

Check function: :py::meth:`~nwbinspector.checks.time_series.check_resolution`
Check function: :py::meth:`~nwbinspector.checks._time_series.check_resolution`



Expand All @@ -184,4 +184,4 @@ Zero Rate

If the ``data`` field of :ref:`nwb-schema:sec-TimeSeries` has more than one frame, and according to :ref:`best_practice_data_orientation` this axis ought to be time, then the ``rate`` field should not be ``0.0``.

Check function: :py::meth:`~nwbinspector.checks.time_series.check_rate_is_not_zero`
Check function: :py::meth:`~nwbinspector.checks._time_series.check_rate_is_not_zero`
30 changes: 0 additions & 30 deletions docs/best_practices/todo.rst

This file was deleted.

6 changes: 5 additions & 1 deletion src/nwbinspector/checks/_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def check_electrical_series_dims(electrical_series: ElectricalSeries):

@register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=ElectricalSeries)
def check_electrical_series_reference_electrodes_table(electrical_series: ElectricalSeries):
"""Check that the 'electrodes' of an ElectricalSeries references the ElectrodesTable."""
"""
Check that the 'electrodes' of an ElectricalSeries references the ElectrodesTable.
Best Practice: TODO
"""
if electrical_series.electrodes.table.name != "electrodes":
return InspectorMessage(message="electrodes does not reference an electrodes table.")

Expand Down
6 changes: 5 additions & 1 deletion src/nwbinspector/checks/_icephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

@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."""
"""
Check if the IntracellularElectrode contains a cell_id.
Best Practice: TODO
"""
if hasattr(intracellular_electrode, "cell_id") and intracellular_electrode.cell_id is None:
return InspectorMessage(message="Please include a unique cell_id associated with this IntracellularElectrode.")
Loading

0 comments on commit 078fbb3

Please sign in to comment.