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

amended _write_electrodes_tsv to exclude writing stim channels to electrodes.tsv #1023

Merged
merged 14 commits into from Jul 30, 2022

Conversation

scott-huberty
Copy link
Contributor

closes #1022

make tests and make pep passed on my local machine, fingers crossed!

@welcome
Copy link

welcome bot commented Jul 28, 2022

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #1023 (8e0ac92) into main (7c08e3b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1023   +/-   ##
=======================================
  Coverage   95.17%   95.18%           
=======================================
  Files          25       25           
  Lines        3774     3777    +3     
=======================================
+ Hits         3592     3595    +3     
  Misses        182      182           
Impacted Files Coverage Δ
mne_bids/dig.py 98.62% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

@hoechenberger
Copy link
Member

Great, can you add a test and a changelog entry please?

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

Thanks! +1 to merge once the changelog entry is there

@scott-huberty
Copy link
Contributor Author

Sure! I was going to add a test for this new behaviour using the 'test_egi.mff' in PR #1006 , but you're right it makes more sense to do it here.

Will add the test and update changelog now.

@sappelhoff sappelhoff added this to the 0.11 milestone Jul 29, 2022
@scott-huberty
Copy link
Contributor Author

I don't see a latest.inc file to add my changes to, should I add them whats_new.rst?

I'm not sure if my test is too convoluted, I was trying to test for two cases:

  1. for the test file 'sample_audvis_trunc_raw.fif', only eeg channels (with electrodes) should be written to electrodes.tsv.
  2. The warning that was identified in Add EGI as manufacturer #1006 that was getting raised during read_raw_bids "There are channels without locations", should no longer be getting raised, so if it does, the test will fail.


# test 1
with open(bids_path.directory /
'sub-01_ses-01_acq-01_space-CapTrak_electrodes.tsv') as sidecar:
Copy link
Member

Choose a reason for hiding this comment

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

Should specify encoding='utf-8'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks for the tip!

# test 2
with pytest.warns(RuntimeWarning) as record:
read_raw_bids(bids_path)
# list of warnings emitted by read_raw_bids
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate your writing this test (looks like a lot of work!), but I don't think we need this one … we just need to ensure we're writing the correct stuff (which the previous test ensures); testing the reading operation again is, IMHO, overkill. I'd suggest to remove test 2.
@sappelhoff WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was wondering if it was too much ha. I can remove it.

Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
@@ -334,7 +334,7 @@ def test_electrodes_io(tmp_path):
raw.pick_types(eeg=True, stim=True) # we don't need meg channels
bids_root = tmp_path / 'bids1'
bids_path = _bids_path.copy().update(root=bids_root, datatype='eeg')
os.makedirs(op.join(bids_root, 'sub-01', 'ses-01', 'eeg'), exist_ok=True)
(bids_root / 'sub-01' / 'ses-01' / 'eeg').mkdir(exist_ok=True)
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to create this directory manually, anyway..?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure.. I was having a hard time understanding this, but was trying to follow the examples from the other tests in test.dig.py

Copy link
Member

Choose a reason for hiding this comment

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

write_raw_bids should create the directory tree, could you try without?

scott-huberty and others added 2 commits July 29, 2022 15:13
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
@mscheltienne
Copy link
Member

And yes, for the changelog it's in whats_new.rst, thanks!

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

@scott-huberty please also comment in #1028 with your full name, ORCID, and affiliation -- I'd like to add you there.

(@mscheltienne as well)

Comment on lines 344 to 349
assert n_entries == len(
raw
.copy()
.pick_types(eeg=True)
.ch_names
)
Copy link
Member

Choose a reason for hiding this comment

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

seems my prior comment got lost: you should not need to do raw.copy() here. use raw.get_channel_types() and count the 'eeg's

Copy link
Member

Choose a reason for hiding this comment

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

Nice trick, @drammock!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

awesome, thanks @drammock!

Co-authored-by: Mathieu Scheltienne <mathieu.scheltienne@gmail.com>
Copy link
Member

@mscheltienne mscheltienne left a comment

Choose a reason for hiding this comment

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

I think those are the last points I see, + the encoding='utf-8' to be added as mentioned by Richard.

I hope this is the last change we need to add support for the EGI format!

doc/whats_new.rst Show resolved Hide resolved
mne_bids/tests/test_dig.py Outdated Show resolved Hide resolved
scott-huberty and others added 3 commits July 29, 2022 18:04
Co-authored-by: Mathieu Scheltienne <mathieu.scheltienne@gmail.com>
Co-authored-by: Mathieu Scheltienne <mathieu.scheltienne@gmail.com>
@scott-huberty
Copy link
Contributor Author

@scott-huberty please also comment in #1028 with your full name, ORCID, and affiliation -- I'd like to add you there.

(@mscheltienne as well)

Thanks for that, @sappelhoff ! I think I commented in the right location of the zenodo json file.. Just Let me know if I commented in the wrong place.

@hoechenberger hoechenberger enabled auto-merge (squash) July 30, 2022 08:00
@hoechenberger hoechenberger merged commit fc28eae into mne-tools:main Jul 30, 2022
@welcome
Copy link

welcome bot commented Jul 30, 2022

🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪

@hoechenberger
Copy link
Member

Thanks @scott-huberty!

@scott-huberty
Copy link
Contributor Author

Thanks @scott-huberty!

Thanks everyone for the help!

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.

write_raw_bids shoudn't write stim channels to electrodes.tsv
5 participants