Skip to content

refactor(analysis): keep one plot_conditions in eegnb.analysis.utils - #342

Open
pellet wants to merge 1 commit into
NeuroTechX:masterfrom
pellet:refactor/one-plot-conditions
Open

pellet wants to merge 1 commit into
NeuroTechX:masterfrom
pellet:refactor/one-plot-conditions

Conversation

@pellet

@pellet pellet commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

eegnb/analysis/analysis_utils.py was a copy of utils.py added in #263, and its plot_conditions drifted away from the one in utils.py. #330 and #329 then fixed each copy separately, so the two still differ in what they accept. 1a5b387 pointed the N170 example at eegnb.analysis.utils and noted that "these should be merged into the same file in a future PR". This does that, keeping utils.py.

  • Keeps the Fix plot_conditions plotting a single epoch instead of the condition average #329 implementation and moves it into eegnb/analysis/utils.py. It accepts marker numbers, event names or condition keys for both conditions and diff_waveform, and an unknown event name raises ValueError instead of plotting nothing.
  • Deletes eegnb/analysis/analysis_utils.py. It has nothing that isn't already in utils.py. The examples, pipelines.py and the tests now import from eegnb.analysis.utils. Code outside the repository that imports eegnb.analysis.analysis_utils must switch to eegnb.analysis.utils.
  • Fixes channel_count of 1 or 2, which raised IndexError because plt.subplots returned a one-dimensional axes array. It now passes squeeze=False.

Both plotting test files are kept and now test the one function. The N170, P300 and cueing gallery figures render within their microvolt limits.

`eegnb/analysis/analysis_utils.py` was a copy of `utils.py` added in NeuroTechX#263, and its `plot_conditions` drifted away from the one in `utils.py`. NeuroTechX#330 and NeuroTechX#329 then fixed each copy separately, so the two still differ in what they accept. 1a5b387 pointed the N170 example at `eegnb.analysis.utils` and noted that "these should be merged into the same file in a future PR". This does that, keeping `utils.py`.

- Keeps the NeuroTechX#329 implementation and moves it into `eegnb/analysis/utils.py`. It accepts marker numbers, event names or condition keys for both `conditions` and `diff_waveform`, and an unknown event name raises `ValueError` instead of plotting nothing.
- Deletes `eegnb/analysis/analysis_utils.py`. It has nothing that isn't already in `utils.py`. The examples, `pipelines.py` and the tests now import from `eegnb.analysis.utils`. Code outside the repository that imports `eegnb.analysis.analysis_utils` must switch to `eegnb.analysis.utils`.
- Fixes `channel_count` of 1 or 2, which raised `IndexError` because `plt.subplots` returned a one-dimensional axes array. It now passes `squeeze=False`.

Both plotting test files are kept and now test the one function. The N170, P300 and cueing gallery figures render within their microvolt limits.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant