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

Retain HF noise channels during RANSAC when not bad by any other metric #64

Merged
merged 3 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Changelog
- Added two keys to the :attr:`PrepPipeline.noisy_channels_original <prep_pipeline.PrepPipeline>` dictionary: ``bad_by_dropout`` and ``bad_by_SNR``, by `Yorguin Mantilla`_ (:gh:`45`)
- Changed RANSAC chunking logic to reduce max memory use and prefer equal chunk sizes where possible, by `Austin Hurst`_ (:gh:`44`)
- Changed RANSAC's random channel sampling code to produce the same results as MATLAB PREP for the same random seed, additionally changing the default RANSAC sample size from 25% of all *good* channels (e.g. 15 for a 64-channel dataset with 4 bad channels) to 25% of *all* channels (e.g. 16 for the same dataset), by `Austin Hurst`_ (:gh:`62`)
- Changed RANSAC so that "bad by high-frequency noise" channels are retained when making channel predictions (provided they aren't flagged as bad by any other metric), matching MATLAB PREP behaviour, by `Austin Hurst`_ (:gh:`64`)

Bug
~~~
Expand Down
7 changes: 6 additions & 1 deletion pyprep/find_noisy_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,18 @@ def find_bad_by_ransac(
(2017). Autoreject: Automated Artifact Rejection for MEG and EEG
Data. NeuroImage, 159, 417-429
"""
exclude_from_ransac = (
self.bad_by_correlation +
self.bad_by_deviation +
self.bad_by_dropout
)
self.bad_by_ransac, _ = find_bad_by_ransac(
self.EEGData,
self.sample_rate,
self.signal_len,
self.ch_names_new,
self.raw_mne._get_channel_positions(),
self.get_bads(),
exclude_from_ransac,
n_samples,
fraction_good,
corr_thresh,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_find_noisy_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_findnoisychannels(raw, montage):
# Make 80% of channels bad
num_bad_channels = int(raw._data.shape[0] * 0.8)
bad_channels = raw.info["ch_names"][0:num_bad_channels]
nd.bad_by_hf_noise = bad_channels
nd.bad_by_deviation = bad_channels
with pytest.raises(IOError):
nd.find_bad_by_ransac()

Expand Down