BouchardLab / nsds_lab_to_nwb

Python package to convert NSDS Lab data to NWB files.
https://nsds-lab-to-nwb.readthedocs.io/en/latest/
0 stars 4 forks source link

Fixed extra_meta error #110

Closed jthermiz closed 3 years ago

jthermiz commented 3 years ago

Description and related issues

Simple fix for issue #109

Make any value item a list

Checklist:

jihyunbak commented 3 years ago

@jthermiz Thanks for catching this error! Instead of wrapping all data type into a list, how about specifically changing any boolean to string? I'm sure text data can go into scratch.

Something like

for key, value in extra_meta.items():
    if isinstance(value, bool):                  <<<<< ADDED
        value = str(value)                           <<<<< ADDED
    nwb_content.add_scratch(data=value,
                            name=key, notes=f'extra metadata {key}')
jihyunbak commented 3 years ago

@jthermiz I've implemented my suggestion above by committing directly to this branch - I hope you don't mind. Please go ahead and merge if this fixes your issue!

jthermiz commented 3 years ago

@jihyunbak values aren't allowed to be strings either. Your suggestion generates this error. I'm not sure why nwb wants this to be a sequence like data type.

Exception has occurred: TypeError
NWBFile.add_scratch: incorrect type for 'data' (got 'str', expected 'ndarray, list, tuple, DataFrame, DynamicTable, NWBContainer or ScratchData')
  File "/home/jhermiz/software/nsds_lab_to_nwb/nsds_lab_to_nwb/nwb_builder.py", line 186, in _add_extra_metadata
    name=key, notes=f'extra metadata {key}')
  File "/home/jhermiz/software/nsds_lab_to_nwb/nsds_lab_to_nwb/nwb_builder.py", line 234, in build
    self._add_extra_metadata(nwb_content)
  File "/home/jhermiz/software/nsds_lab_to_nwb/scripts/generate_nwb_john.py", line 59, in <module>
    nwb_content = nwb_builder.build()
jthermiz commented 3 years ago

Also resolves #96. Merge after technical lunch this Thursday