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

electrodes column in misc.Units.add_unit() doesn't adhere to nwb-schema #1787

Closed
bjhardcastle opened this issue Nov 15, 2023 · 1 comment
Closed

Comments

@bjhardcastle
Copy link

If I'm looking at the right thing, then the schema specifies the column as a DynamicTableRegion and the column in the units table should be a link to the electrodes table:
https://github.com/NeurodataWithoutBorders/nwb-schema/blob/dev/core/nwb.misc.yaml#L219-L222

  - name: electrodes
    neurodata_type_inc: DynamicTableRegion
    doc: Electrode that each spike unit came from, specified using a DynamicTableRegion.
    quantity: '?'

...which doesn't match the accepted types in add_unit():

pynwb/src/pynwb/misc.py

Lines 189 to 190 in eb58506

{'name': 'electrodes', 'type': 'array_data', 'doc': 'the electrodes that each unit came from',
'default': None},

..and just to check that DynamicTableRegion isn't an 'array_data' type:

Units.add_unit: incorrect type for 'electrodes' (got 'DynamicTableRegion', expected 'ndarray, list, tuple, Dataset, Array, StrDataset, HDMFDataset or AbstractDataChunkIterator')

Presumably this is expecting a sequence of integers, which are the indices of the corresponding rows in the electrodes table, but it's not clear: the description sounds more like links to the electrodes table.

@bjhardcastle bjhardcastle changed the title electrodes column in misc.Units.add_unit() doesn't adhere to nwb-schema electrodes column in misc.Units.add_unit() doesn't adhere to nwb-schema Nov 15, 2023
@bjhardcastle
Copy link
Author

bjhardcastle commented Nov 15, 2023

Ok I see what's going on now: you pass a sequence of integers and the DynamicTableRegion is magically created for you!

It just looks like the sequence of integers when viewed as a pandas series:

>>> units['electrodes'][0]
   location                                              group  ... reference       imp
id                                                              ...                    
0       Eth  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
1       Eth  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
2       Eth  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
3        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
4        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
5        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
6        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
7        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
8        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0
9        LP  probeA pynwb.ecephys.ElectrodeGroup at 0x30363...  ...       tip  150000.0

[10 rows x 12 columns]

>>> units[0].electrodes
id
1    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Name: electrodes, dtype: object

The description could still be more helpful though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant