Raise ValueError if TFR freqs <= 0#6169
Merged
agramfort merged 33 commits intomne-tools:masterfrom Apr 20, 2019
DiGyt:raise_freq0_error
Merged
Raise ValueError if TFR freqs <= 0#6169agramfort merged 33 commits intomne-tools:masterfrom DiGyt:raise_freq0_error
agramfort merged 33 commits intomne-tools:masterfrom
DiGyt:raise_freq0_error
Conversation
Enable import the function _freq_mask from .numerics
Added _freq_mask function equivalent to _time_mask function, but for frequency
Added tests for _freq_mask
Enables frequency cropping with tfr.crop(fmin, fmax) for TFR objects
Enhanced test_crop to also test for frequency cropping.
fixed floating point issues in utils.numerics._freq_mask
Updated docstring for BaseTFR.crop to show fmin/fmax params
fixed floating point error in _freq_mask
Adapted test_freq_mask to error fix in freq_mask
Adapted docstring for version in BaseTFR.crop
Removed Debugging notes from test_crop
# Conflicts: # mne/time_frequency/tfr.py
correct spacing
Fixed some code for flake8
Added changes to whats_new.rst
Fixed update to whats_new.rst
# Conflicts: # mne/utils/__init__.py
eliminated merge conflicts in mne.utils.__init__.py Also edited test_freq_mask and test_time_mask mne.utils.tests.test_numerics to find errors more explicitely.
changed code format and error message.
-Removed sfreq=None argument default from mne/utils/numerics.py::_freq_mask -Adapted relevant tests and methods accordingly
-Introduced raise(ValueError) When sfreq=None -Introduced tests for sfreq=None case
- _time_mask or _freq_mask are only called, if they were defined in crop() - _time_mask, _freq_mask were changed back to save time & mem
# Conflicts: # mne/utils/__init__.py
corrected merge conflicts with mne/utils/__init__.py
corrected ```_time_mask``` and ```_freq_mask``` conditions in ```_BaseTFR.crop()```
# Conflicts: # mne/time_frequency/tests/test_tfr.py # mne/time_frequency/tfr.py # mne/utils/__init__.py
Make multitaper and morlet raise a value error if freqs include a frequency <= 0. Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at>
Codecov Report
@@ Coverage Diff @@
## master #6169 +/- ##
==========================================
+ Coverage 89.01% 89.01% +<.01%
==========================================
Files 410 410
Lines 73869 73883 +14
Branches 12253 12255 +2
==========================================
+ Hits 65752 65766 +14
Misses 5222 5222
Partials 2895 2895 |
agramfort
reviewed
Apr 18, 2019
Member
|
B
… |
convert freqs in morlet and _make_dpss to np.array for faster computation Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at>
wmvanvliet
reviewed
Apr 18, 2019
wmvanvliet
reviewed
Apr 18, 2019
changed error statements for invalid frequencies passed in mne/time_frequency/tfr.py ::morlet and ::_make_dpss Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at>
Contributor
|
It's good that there is an error message, but I still don't know if these wavelet-based methods cannot compute the power at DC or if this is just the case in our implementation. |
Contributor
Author
Oh yes, sorry! I will work on this and do another PR if i find a convenient way. Would that be okay? |
Contributor
|
Sure! |
Member
|
thx @DiGyt |
massich
pushed a commit
to massich/mne-python
that referenced
this pull request
Apr 23, 2019
* Added import _freq_mask Enable import the function _freq_mask from .numerics * Added _freq_mask function Added _freq_mask function equivalent to _time_mask function, but for frequency * Added tests for _freq_mask Added tests for _freq_mask * Added frequency cropping args to BaseTFR class Enables frequency cropping with tfr.crop(fmin, fmax) for TFR objects * Enhanced test_crop Enhanced test_crop to also test for frequency cropping. * updated documentation for BaseTFR.crop function, fixed floating point issues in utils.numerics._freq_mask * Updated docstring for BaseTFR.crop Updated docstring for BaseTFR.crop to show fmin/fmax params * Fixed _freq_mask fixed floating point error in _freq_mask * Adapted test_freq_mask to function changes Adapted test_freq_mask to error fix in freq_mask * Adapted docstring BaseTFR.crop Adapted docstring for version in BaseTFR.crop * Removed Debugging notes Removed Debugging notes from test_crop * correct spacing correct spacing * Fixed code format Fixed some code for flake8 * Updated whats_new.rst Added changes to whats_new.rst * Updated whats_new.rst Fixed update to whats_new.rst * Eliminated Conflicts with master eliminated merge conflicts in mne.utils.__init__.py Also edited test_freq_mask and test_time_mask mne.utils.tests.test_numerics to find errors more explicitely. * fixed flake8 probs * changed _time/_freq_mask code style changed code format and error message. * Removed sfreq=None from _freq_mask -Removed sfreq=None argument default from mne/utils/numerics.py::_freq_mask -Adapted relevant tests and methods accordingly * Removed support for sfreq=None from _freq_mask -Introduced raise(ValueError) When sfreq=None -Introduced tests for sfreq=None case * Made _BaseTFR.crop omit mask if not defined. - _time_mask or _freq_mask are only called, if they were defined in crop() - _time_mask, _freq_mask were changed back to save time & mem * corrected new merge conflicts once again corrected merge conflicts with mne/utils/__init__.py * corrected conditions in _BaseTFR.crop corrected ```_time_mask``` and ```_freq_mask``` conditions in ```_BaseTFR.crop()``` * Make TFR raise value error for freqs <= 0 Make multitaper and morlet raise a value error if freqs include a frequency <= 0. Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at> * convert freqs in morlet and _make_dpss to np.array convert freqs in morlet and _make_dpss to np.array for faster computation Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at> * changed error statements changed error statements for invalid frequencies passed in mne/time_frequency/tfr.py ::morlet and ::_make_dpss Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at>
jeythekey
pushed a commit
to jeythekey/mne-python
that referenced
this pull request
Apr 27, 2019
* Added import _freq_mask Enable import the function _freq_mask from .numerics * Added _freq_mask function Added _freq_mask function equivalent to _time_mask function, but for frequency * Added tests for _freq_mask Added tests for _freq_mask * Added frequency cropping args to BaseTFR class Enables frequency cropping with tfr.crop(fmin, fmax) for TFR objects * Enhanced test_crop Enhanced test_crop to also test for frequency cropping. * updated documentation for BaseTFR.crop function, fixed floating point issues in utils.numerics._freq_mask * Updated docstring for BaseTFR.crop Updated docstring for BaseTFR.crop to show fmin/fmax params * Fixed _freq_mask fixed floating point error in _freq_mask * Adapted test_freq_mask to function changes Adapted test_freq_mask to error fix in freq_mask * Adapted docstring BaseTFR.crop Adapted docstring for version in BaseTFR.crop * Removed Debugging notes Removed Debugging notes from test_crop * correct spacing correct spacing * Fixed code format Fixed some code for flake8 * Updated whats_new.rst Added changes to whats_new.rst * Updated whats_new.rst Fixed update to whats_new.rst * Eliminated Conflicts with master eliminated merge conflicts in mne.utils.__init__.py Also edited test_freq_mask and test_time_mask mne.utils.tests.test_numerics to find errors more explicitely. * fixed flake8 probs * changed _time/_freq_mask code style changed code format and error message. * Removed sfreq=None from _freq_mask -Removed sfreq=None argument default from mne/utils/numerics.py::_freq_mask -Adapted relevant tests and methods accordingly * Removed support for sfreq=None from _freq_mask -Introduced raise(ValueError) When sfreq=None -Introduced tests for sfreq=None case * Made _BaseTFR.crop omit mask if not defined. - _time_mask or _freq_mask are only called, if they were defined in crop() - _time_mask, _freq_mask were changed back to save time & mem * corrected new merge conflicts once again corrected merge conflicts with mne/utils/__init__.py * corrected conditions in _BaseTFR.crop corrected ```_time_mask``` and ```_freq_mask``` conditions in ```_BaseTFR.crop()``` * Make TFR raise value error for freqs <= 0 Make multitaper and morlet raise a value error if freqs include a frequency <= 0. Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at> * convert freqs in morlet and _make_dpss to np.array convert freqs in morlet and _make_dpss to np.array for faster computation Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at> * changed error statements changed error statements for invalid frequencies passed in mne/time_frequency/tfr.py ::morlet and ::_make_dpss Signed-off-by: Dirk Gütlin <dirk.guetlin@stud.sbg.ac.at>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raise a ValueError for invalid frequencies passed into
tfr_morletandtfr_multitaper, according to #5708Additional information
Raise a ValueError
"all computed frequencies in freqs must be greater than 0."if the freqs passed tomne/time_frequency/tfr.py::morletandmne/time_frequency/tfr.py::_make_dpssare <= 0.Note:
Used
np.any([f <= 0 for f in freqs])instead ofnp.any(freqs <= 0)to also handle simple lists.