Skip to content

Commit

Permalink
Merge pull request #327 from jpgill86/allow-empty-epoch_encoder_possi…
Browse files Browse the repository at this point in the history
…ble_labels

Show epoch encoder even when no labels are given (as long as a file is)
  • Loading branch information
jpgill86 committed Dec 12, 2022
2 parents 661e1d7 + 96c59cf commit f848b4e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
6 changes: 3 additions & 3 deletions docs/metadata.rst
Expand Up @@ -475,9 +475,9 @@ to display "the past" and the last 70% to display "the future".
Epoch Encoder Parameters
------------------------

The labels available to the epoch encoder must be specified ahead of time using
``epoch_encoder_possible_labels`` (this is a current limitation of ephyviewer
that may eventually be improved upon).
The labels available to the epoch encoder can be specified using
``epoch_encoder_possible_labels``. (Additionally, they may be created on the
fly using the "New label" button in the epoch encoder.)

For example:

Expand Down
38 changes: 15 additions & 23 deletions neurotic/gui/config.py
Expand Up @@ -690,32 +690,24 @@ def create_ephyviewer_window(self, theme='light', ui_scale='medium', support_inc
if label not in possible_labels:
possible_labels.append(label)

if not possible_labels:
writable_epoch_source = NeuroticWritableEpochSource(
filename = _abs_path(self.metadata, 'epoch_encoder_file'),
possible_labels = possible_labels,
)

# an empty epoch encoder file and an empty list of possible
# labels were provided
logger.warning('Ignoring epoch_encoder_file because epoch_encoder_possible_labels was unspecified')
epoch_encoder = ephyviewer.EpochEncoder(source = writable_epoch_source, name = 'Epoch encoder')
epoch_encoder.params['exclusive_mode'] = False
win.add_view(epoch_encoder)

else:

writable_epoch_source = NeuroticWritableEpochSource(
filename = _abs_path(self.metadata, 'epoch_encoder_file'),
possible_labels = possible_labels,
)

epoch_encoder = ephyviewer.EpochEncoder(source = writable_epoch_source, name = 'Epoch encoder')
epoch_encoder.params['exclusive_mode'] = False
win.add_view(epoch_encoder)

# set the theme
if theme != 'original':
epoch_encoder.params['background_color'] = self.themes[theme]['background_color']
epoch_encoder.params['vline_color'] = self.themes[theme]['vline_color']
epoch_encoder.params['label_fill_color'] = self.themes[theme]['label_fill_color']
# TODO add support for combo_cmap
# set the theme
if theme != 'original':
epoch_encoder.params['background_color'] = self.themes[theme]['background_color']
epoch_encoder.params['vline_color'] = self.themes[theme]['vline_color']
epoch_encoder.params['label_fill_color'] = self.themes[theme]['label_fill_color']
# TODO add support for combo_cmap

epoch_encoder.params['xratio'] = self.metadata.get('past_fraction', 0.3)
epoch_encoder.params['label_size'] = ui_scales[ui_scale]['channel_label_size']
epoch_encoder.params['xratio'] = self.metadata.get('past_fraction', 0.3)
epoch_encoder.params['label_size'] = ui_scales[ui_scale]['channel_label_size']

########################################################################
# VIDEO
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,5 +1,5 @@
# av # required but typically not installable via pip, try `conda install -c conda-forge av`
ephyviewer>=1.3.0
ephyviewer>=1.4.0
neo>=0.7.2
numpy
packaging
Expand Down

0 comments on commit f848b4e

Please sign in to comment.