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

[Bug]: EpochTags #1449

Closed
3 tasks done
TomDonoghue opened this issue Apr 7, 2022 · 2 comments · Fixed by #1935
Closed
3 tasks done

[Bug]: EpochTags #1449

TomDonoghue opened this issue Apr 7, 2022 · 2 comments · Fixed by #1935
Labels
category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of NWB users

Comments

@TomDonoghue
Copy link
Contributor

TomDonoghue commented Apr 7, 2022

What happened?

In the NWBFile.add_epoch method, the description notes that the tags input can be str, list or tuple.

Tags description:

tags (:py:class:~str or :py:class:~list or :py:class:~tuple): user-defined tags used throughout time intervals

However, if one actually passes a str, then the epoch_tags attribute doesn't preserve this as a string, but splits it up into individual elements (characters). In this situation, it makes the epoch_tags field not very useful. As far as I can tell, this is simply an issue with however epoch_tags samples the tags from the epochs data, since examining the tags within the epochs structure all looks correct.

Options:

  • I presume however epoch_tags is sampling from epochs is doing some kind of type conversion (calling set perhaps, though I'm quite sure where) which is going wrong, and this could be updated to better handle strings.
  • Alternately, perhaps the tags input is not really supposed to accept string inputs, in which case the description should be updated, and potentially a typecheck warning or error could be raised.

Steps to Reproduce

from datetime import datetime
from dateutil.tz import tzlocal
from pynwb import NWBFile

nwbfile = NWBFile(session_description='test',
                  identifier='000',
                  session_start_time=datetime.now(tzlocal()))

nwbfile.add_epoch(0., 10., tags='label1')

# This stores the tags properly in epochs
print(nwbfile.epochs.tags[:])

# However, it gets stored wrong in `epoch_tags`
print(nwbfile.epoch_tags)
# The printed output I see from this is:
# {'e', 'l', 'a', '1', 'b'}

Traceback

No response

Operating System

macOS

Python Executable

Conda

Python Version

3.8

Package Versions

I'm using pynwb version 2.0.1

Code of Conduct

@bendichter
Copy link
Contributor

@TomDonoghue thanks for reporting this. It's a bug and we'll fix it, but getting that released could take some time. As a work-around, does it work for you to just enter something like tags=('label1',)?

@TomDonoghue
Copy link
Contributor Author

@bendichter - yeh, I should have mentioned, passing in either tags=['label1'] or tags=('label1',) works properly for passing in a single tag, so in that sense there is an easy work-around such that this is not a super critical bug, so while this would be nice to fix, I don't think it's an issue if it takes a bit of time before it's in a new release.

@stephprince stephprince added category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of NWB users labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of NWB users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants