Skip to content

Conversation

@alexrockhill
Copy link
Contributor

Fixes #4480

Adds a current source density estimate function that converts EEG data using the Laplacian of the sensor data.

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

ok I stopped. Tell me when ready to review

@codecov
Copy link

codecov bot commented Oct 4, 2019

Codecov Report

Merging #6910 into master will increase coverage by 0.02%.
The diff coverage is 98.7%.

@@            Coverage Diff             @@
##           master    #6910      +/-   ##
==========================================
+ Coverage   89.72%   89.75%   +0.02%     
==========================================
  Files         438      440       +2     
  Lines       77484    77715     +231     
  Branches    12579    12607      +28     
==========================================
+ Hits        69523    69751     +228     
- Misses       5155     5157       +2     
- Partials     2806     2807       +1

@alexrockhill
Copy link
Contributor Author

@sherdim, thanks for the gist, I used it to base the example of off.
https://gist.github.com/sherdim/28b069c8ebca17073f24322e8e721e1f
Would you like your name and email there as an author?

@alexrockhill
Copy link
Contributor Author

@agramfort now would be okay to review

@sherdim
Copy link

sherdim commented Oct 5, 2019

@alexrockhill

Would you like your name and email there as an author?

I do not mind. It is honorable for me

I had to do it myself, but I didn’t. So go ahead!

@alexrockhill
Copy link
Contributor Author

@alexrockhill

Would you like your name and email there as an author?

I do not mind. It is honorable for me

I had to do it myself, but I didn’t. So go ahead!

@sherdim I can add it but I don't know your name and email...

@alexrockhill

This comment has been minimized.

@drammock
Copy link
Member

drammock commented Oct 6, 2019 via email

@alexrockhill
Copy link
Contributor Author

Thanks, I could have figured that out my bad

@larsoner
Copy link
Member

@alexrockhill somehow you have a bunch of conflicts in unrelated files

@alexrockhill alexrockhill changed the title [WIP] Current Source Density Feature Add [MRG] Current Source Density Feature Add Oct 29, 2019
@alexrockhill alexrockhill force-pushed the csd branch 2 times, most recently from 8c708de to 37b75cd Compare October 29, 2019 01:18
@alexrockhill
Copy link
Contributor Author

alexrockhill commented Oct 29, 2019

I'm having some weird issues with tests failing... I'm not sure why files not related to the files being changed for this PR weirdly but I think I fixed that. When I run "make test" most of the tests pass but I get a few errors like

E FileNotFoundError: [Errno 2] No such file or directory: 'mne_compensate_data': 'mne_compensate_data'

/Users/alexrockhill/software/mne-python/mne/preprocessing/_peak_finder.py:45: DocTestFailure

E AssertionError: SNR (worst 2.55) < 3.50 for 18/306 channels (/Users/alexrockhill/mne_data/MNE-testing-data/SSS/test_move_anon_raw.fif)

I'm not sure what these are about. Using a fresh install of the mnedev environment. Here's just the first part of the stack trace:

(mnedev) alexrockhill@Alexs-MacBook-Pro mne-python % make test
python setup.py build_ext -i
running build_ext
rm -f .coverage
py.test -m 'not ultraslowtest' mne
Test session starts (platform: darwin, Python 3.7.4, pytest 5.2.1, pytest-sugar 0.9.2)
rootdir: /Users/alexrockhill/software/mne-python, inifile: setup.cfg
plugins: sugar-0.9.2, timeout-1.3.3, cov-2.7.1, mock-1.10.4
collecting ...
mne/annotations.py s 0%
mne/dipole.py s 0%
mne/epochs.py ss 0%
mne/event.py s✓ 0% ▏
mne/filter.py ✓ 0% ▏

―――――――――――――――――― [doctest] mne.filter.construct_iir_filter ―――――――――――――――――――
103 >>> iir_params = construct_iir_filter(iir_params, 40, 50, 1000, 'low') # doctest:+SKIP
104 >>> print((2 * len(iir_params['sos']), iir_params['padlen'])) # doctest:+SKIP
105 (6, 439)
106
107 Padding and/or filter coefficients can also be manually specified. For
108 a 10-sample moving window with no padding during filtering, for example,
109 one can just do:
110
111 >>> iir_params = dict(b=np.ones((10)), a=[1, 0], padlen=0)
112 >>> iir_params = construct_iir_filter(iir_params, return_copy=False)
Expected nothing
Got:

/Users/alexrockhill/software/mne-python/mne/filter.py:112: DocTestFailure

mne/filter.py ⨯ 1% ▏

――――――――――――――――――――――――― [doctest] mne.filter.detrend ―――――――――――――――――――――――――

cc @jasmainak @larsoner @drammock

@agramfort
Copy link
Member

@alexrockhill are all the changes here related to this PR?

@alexrockhill
Copy link
Contributor Author

They are or should be now. For some reason there were other files changed but I checked the file change diffs and that should be fixed. Now they are all just the files I had to change for csd

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

There are changes to what's new and to _optical_density.py that appear unrelated at first glance. Also maybe the spline stuff? Can you double check?

@larsoner
Copy link
Member

larsoner commented Nov 8, 2019

Tests pass locally now, it was missing a ref_meg=False

@alexrockhill
Copy link
Contributor Author

I saw that it had to do with a false positive meg_ref, I just couldn't figure out at which level (tests, epochs, viz.epochs or viz.utils) so I'm glad you figured it out :)

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

sorry for taking so long to review

for t, rules in get_channel_types().items():
# go in order from most specific (most rules entries) to least specific
channel_types = sorted(
get_channel_types().items(), key=lambda x: len(x[1]))[::-1]
Copy link
Member

Choose a reason for hiding this comment

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

I add a comment here to explain this.

Alex Rockhill and others added 14 commits November 12, 2019 08:51
added some tests

WIP CSD MVP example

working with example

weird cherry-picking error again

Update examples/preprocessing/plot_csd.py

Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org>

Update examples/preprocessing/plot_csd.py

Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org>

Update examples/preprocessing/plot_csd.py

Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org>

Update mne/preprocessing/_csd.py

Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org>

Update examples/preprocessing/plot_csd.py

Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org>

typos/small fixes

incorporated Eric comments

more Eric comments

refactoring core comp per Eric

realized I did that wrong

Eric comments 3

plot fix

Fix julian date conversions (mne-tools#6911)

* Fix julian date conversions

* remove tabs

* use UTC and private functions.

closes mne-tools#6901 [skip travis][skip azp] (mne-tools#6914)

ENH: Add source space SNR estimate (mne-tools#6908)

* source-snr-edit

* FIX move estimate_snr to be a method

* ENH: name change

* Make it work

* SNR works, now clean up code

* fixed unnecessary stc copy, returns stc object

* added plot source space SNR tutorial file

* updated author names

* fixed period for pydocsty and suggested documenation edit

* edits suggested from @drammock

* made edits suggested by reviewers

* made edits suggested by reviewers

* N -> n_channels

* Fixed formatting of Reference in comment

* fixed formatting in doc and in code

* fixed snr_stc creation

* further minor edits

* fixed formatting issues and colormap choice in eg

* removed colon after Reference

* Corrected SNR calculation to take unwhitened sensor signal b instead of whitened, updated tutorial file

* Minor changes to formatting

* FIX: transparent

* FIX: Rename

* FIX?

Added dSPM (mne-tools#6913)

* Added dSPM

* removed term signal covariance

* Minor modification of dSPM definition

* Corrected according to Mattis suggestions

[MRG]: read *.dat electrode position files (mne-tools#6909)

* ADD: channels.read_dig_dat()

* DOC

* DOC

* TEST

* DOC, __all__

* DOC: intro

* DOC

* pep & py3.5 compatibility

* py3.5

MRG: allow users to annotate epochs with colors (mne-tools#6855)

* ENH: copy over diff from autoreject

* Make it work

* More fixes

* More fixes

* Make horizontal patch

* Cleanup

* TST: add tests

* Address Eric's comments

* Address alex comments

* DOC: update whats new

* FIX travis + circle

* FIX For ICA plot

Fix infomax (mne-tools#6921)

* fix extended infomax

* update whats new

* cleaner way, using setdefault

DOC: Document authors better [ci skip]

FIX: Comments and order

umlauts

MRG, MAINT: Simplify code for vol ravel (mne-tools#6920)

* MAINT: Simplify code for vol ravel

* STY: Flake

ENH: Convert NIRS raw data to optical density (mne-tools#6827)

* Initial framework for fnirs raw to optical density conversion

* Add optical density to docs

* Update mne/preprocessing/tests/test_optical_density.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

* Update mne/preprocessing/tests/test_optical_density.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

* Import testing

* Put optical density docs in preprocessing section

* Implement optical density conversion

* Fix optical density code style issues

* Add plotting of optical density data

* Add defaults for optical density plotting

* Update mne/preprocessing/optical_density.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

* Handle negative intensities in optical density conversion

* Add in -1* that was removed in previous commit

* Add tests and fix imports for optical density

* Add tests for optical density conversion

* Use assert_allclose for testing optical density

* Update test_optical_density.py

* Update mne/preprocessing/_optical_density.py

Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org>

* Do not operate in place for optical density

* Force data to load and modify test to include preload=False condition

import fix

tidying up

weird file conflict errors

more unexpected file changes

fix weird off target changes

doc

docstring fixes

docstyle

reformatted plots

changes formatting fix

Update mne/preprocessing/_csd.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

Update examples/preprocessing/plot_csd.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

Update mne/preprocessing/tests/test_csd.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

Update mne/preprocessing/_csd.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

Update mne/preprocessing/_csd.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

Update mne/preprocessing/_csd.py

Co-Authored-By: Eric Larson <larson.eric.d@gmail.com>

halfway through Eric suggested changes getting on plane

WIP Eric comments almost done

testing fixes

updated fif constants

csd formatting small change

references
@alexrockhill
Copy link
Contributor Author

@agramfort I'm not sure if there was a versioning issue but there weren't any evo in the last one, they had all been changed to evoked... not sure what happened there. Anyway, I did as you suggested, and it should be good to go now.

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

we've never been so close ! thx for your patience and energy @alexrockhill !

"""Test stim_channel."""
TYPE_LUT = {v[0]: k for k, v in _KIND_DICT.items()}
# This is fragile for EEG/EEG-CSD, so just omit csd
TYPE_LUT = {v[0]: k for k, v in _KIND_DICT.items() if k != 'csd'}
Copy link
Member

Choose a reason for hiding this comment

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

having to change something outside seems like a code smell. @larsoner any thought? why is this needed?

for t, rules in get_channel_types().items():
# go in order from most specific (most rules entries) to least specific
channel_types = sorted(
get_channel_types().items(), key=lambda x: len(x[1]))[::-1]
Copy link
Member

Choose a reason for hiding this comment

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

what specific means in this context was not clear to me.

@agramfort agramfort merged commit 3fafe43 into mne-tools:master Nov 13, 2019
@agramfort
Copy link
Member

thx heaps @alexrockhill for leading this effort !

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.

Current Source Density (CSD) with mne-python?

5 participants