Closed jthermiz closed 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}')
@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!
@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()
Also resolves #96. Merge after technical lunch this Thursday
Description and related issues
Simple fix for issue #109
Make any value item a list
Checklist:
pytest --basetemp=tmp -sv -n 8 tests
on catscan from the root directory (passes local test)docs/source
has been updated for any added, moved, or removed filesmake clean & make html
from thedocs
folderflake8 nsds_lab_to_nwb tests
from the root directory