[Documentation]: Remove label key in add_electrode function
What would you like changed or added to the documentation and why?
The tutorial "Extracelllular Electrophysiological Data" contains a section that references the add_electrodes function here.
nwbfile.add_electrode(
group=electrode_group,
label="shank{}elec{}".format(ishank, ielec),
location="brain area",
)
The keyword "label" doesn't exist however. I guess this is from an old version? I think the label keyword is actually quite useful to add exactly the info that is mentioned in the example. Is the idea here to use only the xyz localization as an identifier?
Currently though adding the label keyword results in an exception:
nwbfile.add_electrode( group=electrode_group, label=f"{contact_names[lead_idx]}", location=f"{Location}_{hemisphere}", reference="REFERENCE?" ) Traceback (most recent call last): File "
", line 1, in File "/Users/Timon/Documents/Houston/OCD_RCS/OCD_RCS/.venv/lib/python3.12/site-packages/hdmf/utils.py", line 578, in func_call return func(args[0], **pargs) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/Timon/Documents/Houston/OCD_RCS/OCD_RCS/.venv/lib/python3.12/site-packages/pynwb/file.py", line 699, in add_electrode self.electrodes.add_row(**d) File "/Users/Timon/Documents/Houston/OCD_RCS/OCD_RCS/.venv/lib/python3.12/site-packages/hdmf/utils.py", line 578, in func_call return func(args[0], **pargs) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/Timon/Documents/Houston/OCD_RCS/OCD_RCS/.venv/lib/python3.12/site-packages/hdmf/common/table.py", line 730, in add_row self._add_extra_predefined_columns(data) File "/Users/Timon/Documents/Houston/OCD_RCS/OCD_RCS/.venv/lib/python3.12/site-packages/hdmf/common/table.py", line 706, in _add_extra_predefined_columns raise ValueError( ValueError: row data keys don't match available columns you supplied 1 extra keys: {'label'}
Do you have any interest in helping write or edit the documentation?
Yes, but I would need guidance.
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
- [x] Have you checked the Contributing document?
- [x] Have you ensured this change was not already requested?
Hi @timonmerk,
Thanks for submitting an issue. The electrophysiology tutorial includes this line earlier in the example code block you cited to demonstrate how to add custom columns, such as a label column:
nwbfile.add_electrode_column(name="label", description="label of electrode")
The nwbfile.add_electrode method allows any custom column names to then be used as a keyword argument. I agree this might not be obvious what is a custom argument if someone is glancing through the code, maybe adding a comment would be useful in this case. Thoughts on if something like this helps clarify?
nwbfile.add_electrode(
group=electrode_group,
label="shank{}elec{}".format(ishank, ielec), # custom column data can be added using keyword arguments
location="brain area",
)