Skip to content

Commit

Permalink
Retain HF noise channels during RANSAC when not bad by any other metr…
Browse files Browse the repository at this point in the history
…ic (#64)

* Retain HF noise channels during RANSAC

* Updated whats_new.rst

* Fix broken unit test
  • Loading branch information
a-hurst authored Apr 12, 2021
1 parent a01902e commit 032cad1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit 032cad1

Please sign in to comment.