NeurodataWithoutBorders/pynwb

[Bug]: nwbfile.add_trial_column does not allow extra kwargs

Closed this issue · 3 comments

rly commented

What happened?

NWBFile.add_trial_column is a shortcut for nwbfile.trials.add_column. nwbfile.trials.add_column allows extra keyword args to be passed, which are then passed to the constructor of col_cls. This is useful when the custom VectorData subclass has additional arguments. NWBFile.add_trial_column does not allow extra keyword args to be passed, so certain custom VectorData subclasses cannot be initialized.

Steps to Reproduce

nwbfile.add_trial_column(name="HED", hed_version="8.2.0", description="temp", col_cls=HedTags, data=[])

Traceback

TypeError: NWBFile.add_trial_column: unrecognized argument: 'hed_version'

Operating System

macOS

Python Executable

Conda

Python Version

lower version (unsupported)

Package Versions

No response

Code of Conduct

rly commented

This affects not just add_trial_column but all convenience add_column methods in NWBFile:

  • add_epoch_column
  • add_electrode_column
  • add_unit_column
  • add_trial_column
  • add_invalid_times_column

I was curious as to why the add_column wasn't a method of DynamicTable and the ability to add fields housed there. Thx.

I was curious as to why the add_column wasn't a method of DynamicTable and the ability to add fields housed there

As @rly mentioned in the issue, the NWBFile.add_trial_column and others are convenience methods that under the hood add the column to the appropriate table, e.g., nwbfile.trials.add_column. I.e., add_column indeed lives on DynamicTable. It's a matter of allowing the additional arguments to be passed.