Skip to content

FIX resampling events indices - #6247

Merged
larsoner merged 3 commits into
mne-tools:masterfrom
jeythekey:fix-resample-events
Apr 29, 2019
Merged

larsoner merged 3 commits into
mne-tools:masterfrom
jeythekey:fix-resample-events

Conversation

@jeythekey

Copy link
Copy Markdown
Contributor

This is a one-character fix for inst.resample, when also resampling events.

The ceiling-check of the max. index of the resampled events was missing a -1, so e.g. cropping to the same data-segment between two events before and and again after resampling resulted in an error.

@agramfort

Copy link
Copy Markdown
Member

Can you add a test?

@jeythekey

Copy link
Copy Markdown
Contributor Author
import numpy as np
test = np.array([1,2,3])
try:
    test[test.shape[0]]
    print('Test failed')
except IndexError:
    test[test.shape[0]-1]
    print('Test passed')

Does this suffice?

@jeythekey

Copy link
Copy Markdown
Contributor Author

I think the test failing is unrelated to this PR.

@agramfort

Copy link
Copy Markdown
Member

please look for the test function that uses the code you changed.

https://github.com/mne-tools/mne-python/blob/master/mne/io/fiff/tests/test_raw_fiff.py#L969

this test should be changed to is breaks on master and works with this pull request. thanks

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

I have restarted the single failing Travis build just to make sure.

@codecov

codecov Bot commented Apr 28, 2019 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@3d33e8e). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #6247   +/-   ##
=========================================
  Coverage          ?   89.17%           
=========================================
  Files             ?      415           
  Lines             ?    74895           
  Branches          ?    12345           
=========================================
  Hits              ?    66791           
  Misses            ?     5223           
  Partials          ?     2881

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

Restarted Travis is green now.

@jona-sassenhagen

Copy link
Copy Markdown
Contributor

@jeythekey do you see what Alex says about adding a test? Or do you need more support?

@jeythekey

Copy link
Copy Markdown
Contributor Author

OK, the test should hopefully show the issue now. I am sorry, I wasn't aware of the rule, that every PR needs to come with a test obligatorily. (This could also be more explicit about this.). I also didn't know that I don't have to mimic the old behavior myself in a test, that makes of course things much more comfortable. So, thanks for the advices!

@agramfort

Copy link
Copy Markdown
Member

@jeythekey can you see why travis complains? I suspect pep8 errors

@agramfort

Copy link
Copy Markdown
Member

travis is still not happy. You'll need to update what's new. I'll let @larsoner confirm that it's actually a bug. He knows this code more than me. thx

@jeythekey

Copy link
Copy Markdown
Contributor Author

@jona-sassenhagen Could you restart travis again, please? (I think some network/loading problem). Is anything missing here besides whats_new?

@larsoner
larsoner merged commit af340be into mne-tools:master Apr 29, 2019
@larsoner

Copy link
Copy Markdown
Member

Argh missed the whats_new.rst update requirement. @jeythekey feel free to open a separate quick PR for this

@jeythekey

Copy link
Copy Markdown
Contributor Author

Can I include the whats-new in this PR: #6246, which hopefully can be merged soon as well?

@larsoner

Copy link
Copy Markdown
Member

Yes that should be fine

jeythekey added a commit to jeythekey/mne-python that referenced this pull request Apr 29, 2019
@jeythekey
jeythekey deleted the fix-resample-events branch April 29, 2019 19:39
mmagnuski pushed a commit that referenced this pull request May 3, 2019
* Fix sorting in descending order in ica._detect_artifacts (was sortin in ascending order).

* Fix sfreq selection in ica._band_pass_filter (called (only) in ica.score_sources to filter sources and targets) to use the raw sfreq rather than the one used for fitting the ica.

* Incorporate missed suggestion from #5620 + summary of discussion

* fix PEP8

* fix typo in doc

* Allow both exclude and ica.exclude to be array_like by always converting to list first.

* ica.detect_artifacts: Corrected doc according to code and changed some default values to yield the same compos as before

* Added test for checking descending sorting in detect_artifacts for integer criterion

* Stylistic improvements thanks to jona-sassenhagen

* Fix test for score-sorting

* pep8 and whats_new.rst

* Remove links to privat funcs in whats_new.rst

* fix links in whats_new

* STY: No end period

* Futher improvements thanks to mmagnuski and a few further corrections in the docstrings of run_ica and detect_artifacts

* Added warning for new sorting-direction in detect_artifacts; added whats_new from #6247

* improve bug section; remove warning again; typo
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