Skip to content

MRG: Add .baseline attribute to mne.Evoked - #8156

Merged
larsoner merged 48 commits into
mne-tools:masterfrom
hoechenberger:baseline
Sep 14, 2020
Merged

larsoner merged 48 commits into
mne-tools:masterfrom
hoechenberger:baseline

Conversation

@hoechenberger

Copy link
Copy Markdown
Member

Add Evoked.baseline. x-ref #8147

This is in an early proof-of-concept stage: I haven't even run / adjusted the tests yet…

@hoechenberger

Copy link
Copy Markdown
Member Author

Maybe @larsoner wants to share some early comments: "That's good, keep on going" / "💩, you got it all wrong!"

@cbrnr

cbrnr commented Aug 25, 2020

Copy link
Copy Markdown
Contributor

Can you make the plot as @agramfort suggested here? Maybe this isn't necessary after all.

@hoechenberger

hoechenberger commented Aug 25, 2020 •

Copy link
Copy Markdown
Member Author

@cbrnr

Maybe this isn't necessary after all.

Sorry for misleadingly referencing #8147 here: I just meant to imply that while working on #8147, the idea that Evoked.baseline should exist got sparked. I didn't mean to imply that this PR was a fix to #8147

Comment thread mne/evoked.py Resolved
@hoechenberger hoechenberger added this to the 0.21 milestone Sep 2, 2020
@larsoner

larsoner commented Sep 9, 2020

Copy link
Copy Markdown
Member

@hoechenberger 0.21 is getting closer. Need help pushing this one over the line? Looks like it's close already

@hoechenberger

Copy link
Copy Markdown
Member Author

@larsoner I will pick up working on this tomorrow, so I'm confident it can be included in the next release

@hoechenberger

Copy link
Copy Markdown
Member Author

@larsoner I've started adding some tests, will add more tonight. I/O roundtrip is still failing. Will ring you up if I cannot get this sorted out ;)

@hoechenberger

hoechenberger commented Sep 11, 2020 •

Copy link
Copy Markdown
Member Author

Currently finishing this up, got I/O working.

But now I'm wondering:
For whatever reason, I (we?) decided to deprecate the baseline param of read_evokeds(). I'm not so sure anymore whether this is a wise idea… imagine you have several Evokeds stored in a single file, want to read them all and apply a custom baseline, you'd then have to do:

evokeds = read_evokeds(...)
evokeds = [e.apply_baseline(...) for e in evokeds]

instead of just

evokeds = read_evokeds(..., baseline=...)

But then again, one typically baseline-corrects on the Epochs level already, right? And the new Evoked.baseline attribute would tell one whether and which baseline correction has been applied.

For a single Evoked, one can simply chain the methods:

evoked = read_evokeds(..., condition='foo').apply_baseline(...)

Still, I wanted to ask again: do you think it's okay to deprecate the baseline argument of read_evokeds()?

@larsoner

Copy link
Copy Markdown
Member

I'm okay with reverting the deprecation. It's pretty low-burden to keep it around, and the code is super old so the deprecation pain is pretty high for little gain.

@hoechenberger

Copy link
Copy Markdown
Member Author

I'm okay with reverting the deprecation. It's pretty low-burden to keep it around, and the code is super old so the deprecation pain is pretty high for little gain.

And what to do in cases where a baseline is stored on disk, and the user passes a baseline param? The param takes precedence, and we issue a warning?

Would you see any advantages in removing the param?

@larsoner

Copy link
Copy Markdown
Member

And what to do in cases where a baseline is stored on disk, and the user passes a baseline param? The param takes precedence, and we issue a warning?

I don't see a need to issue a warning, we allow re-baselining. We can just say in the docstring that passing a baseline param is equivalent to doing evoked.apply_baseline(baseline) afterward.

Would you see any advantages in removing the param?

Only that ideally there should be one clear way to do things, and all of our instances having an apply_baseline could be that way. But I'm not convinced pushing in this direction is worth it in this case, all things considered.

@larsoner

Copy link
Copy Markdown
Member

Failures are real:

FAILED mne/inverse_sparse/tests/test_gamma_map.py::test_gamma_map - RuntimeWa...
FAILED mne/inverse_sparse/tests/test_gamma_map.py::test_gamma_map_vol_sphere
FAILED mne/inverse_sparse/tests/test_mxne_inverse.py::test_mxne_inverse_standard
FAILED mne/inverse_sparse/tests/test_mxne_inverse.py::test_mxne_vol_sphere - ...
FAILED mne/utils/tests/test_logging.py::test_logging_options - AssertionError...

@hoechenberger hoechenberger changed the title MRG: Add .baseline attribute to mne.Evoked WIP: Add .baseline attribute to mne.Evoked Sep 12, 2020
@hoechenberger

Copy link
Copy Markdown
Member Author

I believe I have addressed all comments. Documentation build will probably still fail, but code tests should come back positive.

@agramfort agramfort left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@larsoner merge if you're happy

@hoechenberger

Copy link
Copy Markdown
Member Author

I'm still fighting with the docstrings, I simply cannot get all tests to pass locally 😭

@hoechenberger hoechenberger changed the title WIP: Add .baseline attribute to mne.Evoked MRG: Add .baseline attribute to mne.Evoked Sep 13, 2020
@hoechenberger

hoechenberger commented Sep 13, 2020 •

Copy link
Copy Markdown
Member Author

This is Good To Merge from my end. Travis finished successfully on the last commit before those docstring wars.

@larsoner
larsoner merged commit 7f34517 into mne-tools:master Sep 14, 2020
@larsoner

Copy link
Copy Markdown
Member

Thanks for working through this @hoechenberger !

@hoechenberger
hoechenberger deleted the baseline branch September 14, 2020 13:50
hoechenberger added a commit to hoechenberger/mne-python that referenced this pull request Sep 15, 2020
larsoner pushed a commit that referenced this pull request Sep 15, 2020
* Revert "MRG: Add .baseline attribute to mne.Evoked (#8156)"

This reverts commit 7f34517.

* Restore verbose kwarg
hoechenberger added a commit to hoechenberger/mne-python that referenced this pull request Sep 16, 2020
For more consistency with Epochs.

This was originally a part of mne-toolsGH-8156.
larsoner pushed a commit that referenced this pull request Sep 16, 2020
* ENH: Add Evoked.tmin, Evoked.tmax

For more consistency with Epochs.

This was originally a part of GH-8156.

* Comma
marsipu pushed a commit to marsipu/mne-python that referenced this pull request Oct 14, 2020
* Add .baseline attribute to mne.Evoked

* Add some tests

* Fix tmin, tmax handling

* Add tmin, tmax properties

* Fix test

* Fix tests, Dipole I/O

* Fix docstring

* Fix topomap plotting test

* Fix typo in docstring

* Fix LCMV tests

* Fix inverse test

* Fix bug in average_movements, add Epochs tests

* Fix Report test

* Fix I/O roundtrip and remove deprecation

* Better documentation, add changelog entry

* Hopefully fix remaining tests

* Only set Evoked.baseline if it has changed

* BF: Only update Epochs.baseline on actual rescale

* Better comment

* Doc build

* Fix docstring

* Add versionadded

* Update doc/changes/latest.inc

* Fix docstring formatting

* Enable I/O roundtrip tests

* Rearrange code to make it easier to understand

* Be more specific about which exceptions to catch

* Use tuples

* Typo

* Fix logging and tests

* Better documentation

* Disallow removal of applied baseline

* Fix logging

* Add changelog entry

* Fix docstrings

* Fix docstrings

* Re-raise exception if we did not expect it

* Better logging & fix

* Typos

* Uses rounded times

* Amend changelong

* Docstrings [skip travis]

* Better docstring [skip travis]

* Docstrings [skipt travis]

* Hopefully fix docstrings!!!! 🤬💩😵 [skip travis]

* Revert debugging changes [skip travis]
marsipu pushed a commit to marsipu/mne-python that referenced this pull request Oct 14, 2020
* Revert "MRG: Add .baseline attribute to mne.Evoked (mne-tools#8156)"

This reverts commit 7f34517.

* Restore verbose kwarg
marsipu pushed a commit to marsipu/mne-python that referenced this pull request Oct 14, 2020
* ENH: Add Evoked.tmin, Evoked.tmax

For more consistency with Epochs.

This was originally a part of mne-toolsGH-8156.

* Comma
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.

4 participants