Skip to content

Commit

Permalink
Add new func for spatial series
Browse files Browse the repository at this point in the history
  • Loading branch information
khl02007 committed Jan 19, 2024
1 parent 0089d5e commit 0f03af8
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/spyglass/utils/nwb_helper_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,28 @@ def get_data_interface(nwbfile, data_interface_name, data_interface_class=None):
return None


def get_position_obj(nwbfile):
"""Return the Position object from the behavior processing module.
Meant to find position spatial series that are not found by
`get_data_interface(nwbfile, 'position', pynwb.behavior.Position)`.
The code returns the first `pynwb.behavior.Position` object (technically
there should only be one).
Parameters
----------
nwbfile : pynwb.NWBFile
The NWB file object.
Returns
-------
pynwb.behavior.Position object
"""
for obj in nwbfile.processing["behavior"].data_interfaces.values():
if isinstance(obj, pynwb.behavior.Position):
return obj
return None


def get_raw_eseries(nwbfile):
"""Return all ElectricalSeries in the acquisition group of an NWB file.
Expand Down Expand Up @@ -459,9 +481,7 @@ def get_all_spatial_series(nwbf, verbose=False, incl_times=True) -> dict:
the file. The 'raw_position_object_id' is the object ID of the
SpatialSeries object.
"""
pos_interface = get_data_interface(
nwbf, "position", pynwb.behavior.Position
)
pos_interface = get_position_obj(nwbf)

if pos_interface is None:
return None
Expand Down

0 comments on commit 0f03af8

Please sign in to comment.