diff --git a/src/pynwb/epoch.py b/src/pynwb/epoch.py index 9cccc5db5..b14729c2c 100644 --- a/src/pynwb/epoch.py +++ b/src/pynwb/epoch.py @@ -33,8 +33,10 @@ def __init__(self, **kwargs): @docval({'name': 'start_time', 'type': float, 'doc': 'Start time of epoch, in seconds'}, {'name': 'stop_time', 'type': float, 'doc': 'Stop time of epoch, in seconds'}, - {'name': 'tags', 'type': (str, list, tuple), 'doc': 'user-defined tags used throughout time intervals', - 'default': None}, + {'name': 'tags', 'type': (str, list, tuple), + 'doc': ('User-defined tags used throughout time intervals. If list or tuple each element is treated as ' + 'a separate tag. If str, can be a single tag, or comma-separated entries that will be parsed ' + 'into individual tags.'), 'default': None}, {'name': 'timeseries', 'type': (list, tuple, TimeSeries), 'doc': 'the TimeSeries this epoch applies to', 'default': None}, allow_extra=True) diff --git a/src/pynwb/file.py b/src/pynwb/file.py index e8f422c57..69aa31f70 100644 --- a/src/pynwb/file.py +++ b/src/pynwb/file.py @@ -591,7 +591,12 @@ def add_epoch(self, **kwargs): """ self.__check_epochs() if kwargs['tags'] is not None: - self.epoch_tags.update(kwargs['tags']) + # If a str is passed into epoch_tags directly, it gets split into characters + # This processing needs to match tags parsing in `epoch.TimeIntervals.add_interval` + tmp = kwargs['tags'] + if isinstance(kwargs['tags'], str): + tmp = [s.strip() for s in kwargs['tags'].split(",") if not s.isspace()] + self.epoch_tags.update(tmp) self.epochs.add_interval(**kwargs) def __check_electrodes(self):