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

Fixing topomaps. #130

Merged
merged 10 commits into from
Oct 26, 2023
Merged

Fixing topomaps. #130

merged 10 commits into from
Oct 26, 2023

Conversation

christian-oreilly
Copy link
Collaborator

Fix #129

@christian-oreilly christian-oreilly linked an issue Jun 2, 2023 that may be closed by this pull request
@christian-oreilly
Copy link
Collaborator Author

These modifs seems to fix most of the problem... but there appear to still have some issues. Comparing with MNE topomaps using:

import mne
fname = "/Users/christian/Code/pylossless/pylossless/assets/test_data/sub-s02/eeg/sub-s02_task-faceO_ica1_ica.fif"
ica =  mne.preprocessing.read_ica(fname)
ica.plot_components()

we obtain:
image

Compared to what we get with TopoViz:

image

The first 5 seem to be the same, with an inversion in the camp (red becomes blue)... then, some seem to correspond but not all, and not for the same index...

Rebased with main, fixed conflicts from changes in this PR. I always accepted the changes in THIS PR, and formated with black after accepting the change.
These last couple fixes will make our topomaps look like MNEs. It mainly had to
do with some logic to handle the cmap and vmin/vmax
@scott-huberty
Copy link
Member

scott-huberty commented Sep 17, 2023

I pushed a couple commits to get this PR over the line, our topoplots now match those produced by MNE. Using one of our pylossless test files:

fpath = Path(".") / "pylossless" / "pylossless" / "assets" / "test_data" / "sub-s01" / "eeg"
ica_fpath = fpath / "sub-s01_task-faceO_ica2_ica.fif"
ica = mne.preprocessing.read_ica(ica_fpath)
ica.plot_components(slice(0,20))

MNE:

components

and then selecting sub-s01_task-faceO_eeg.edf from the dropdown menu of the dashboard launched by pylossless_qc:
Screen Shot 2023-09-17 at 11 45 55 AM

@christian-oreilly just give me a thumbs up if you agree that this looks like it solves the problem. FYI see commit 3dd5988 for the code I added.

Then there's just a failure in test_GridTopoPlot that needs to get worked out, and maybe we should try to add a specific test that assures that a topo of one component looks like one produced by MNE.

Copy link
Member

@scott-huberty scott-huberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestions

pylossless/dash/topo_viz.py Outdated Show resolved Hide resolved
pylossless/dash/topo_viz.py Outdated Show resolved Hide resolved
pylossless/dash/topo_viz.py Outdated Show resolved Hide resolved
@scott-huberty
Copy link
Member

Note: that there is also a typo here (color should be "black" not "back") that we should fix before merging.

We should initiate the cmap as None instead of "Red_bl" (sic), so that
our code logic can handle the color scheme based on the IC values just like
MNE does
@christian-oreilly
Copy link
Collaborator Author

Nice job. Yes, I agree, these topomaps now seem to be identical. I suspect that the CI issue is the same one discussed in the context of the "rejection policy" PR, which seems to have nothing to do with either PR.

@scott-huberty
Copy link
Member

Nice job. Yes, I agree, these topomaps now seem to be identical. I suspect that the CI issue is the same one discussed in the context of the "rejection policy" PR, which seems to have nothing to do with either PR.

The test failure is related to this PR: It was caused by the change committed to pylossless/dash/tests/test_topo_viz.py, here

@christian-oreilly
Copy link
Collaborator Author

The test failure is related to this PR: It was caused by the change committed to pylossless/dash/tests/test_topo_viz.py, here

Oh... sorry about that. I just assumed. I should not have assumed without taking some time to check.

I must say that I don't remember why I changed it that way. I think our tests should guide us there... I'd go with your reverting of this change if it allows all tests to pass. We can always change this back later (adding corresponding tests) if we come up with a use case that requires this change...

@scott-huberty
Copy link
Member

The test failure is related to this PR: It was caused by the change committed to pylossless/dash/tests/test_topo_viz.py, here

Oh... sorry about that. I just assumed. I should not have assumed without taking some time to check.

I must say that I don't remember why I changed it that way. I think our tests should guide us there... I'd go with your reverting of this change if it allows all tests to pass. We can always change this back later (adding corresponding tests) if we come up with a use case that requires this change...

No worries, it has been quite some time since we worked on this! I already checked, and reverting the specific change to test_topo_viz fixes the failure. Per my comment above, it makes since to me that the input to GridTopoPlot should be a list of dict, so the code as it was before makes since to me. I'll revert the change.

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #130 (f264469) into main (662d837) will decrease coverage by 9.30%.
Report is 3 commits behind head on main.
The diff coverage is 63.63%.

@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
- Coverage   77.63%   68.33%   -9.30%     
==========================================
  Files          12       14       +2     
  Lines         921      960      +39     
==========================================
- Hits          715      656      -59     
- Misses        206      304      +98     
Files Coverage Δ
pylossless/dash/utils.py 100.00% <100.00%> (ø)
pylossless/dash/topo_viz.py 55.20% <50.00%> (-28.49%) ⬇️

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@scott-huberty
Copy link
Member

I'm trying to get our code coverage to be ever increasing and there are missed lines in the added code. Will have to loop back to this when we have time.

@christian-oreilly
Copy link
Collaborator Author

@scott-huberty Can we merge this? I need it to be merged before forking this repo to start splitting the dash components into CONIE.

@scott-huberty
Copy link
Member

@christian-oreilly sure, but can you commit my suggestions before?

Note that dash/tests/test_topoviz/test_TopoViz is failing, IIRC it was a chrome driver issue. I marked it for skip in #144

Copy link
Collaborator Author

@christian-oreilly christian-oreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed and committed suggestions.

@christian-oreilly christian-oreilly merged commit 0927ded into main Oct 26, 2023
3 of 5 checks passed
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.

Bug in topomaps
2 participants