Skip to content

Conversation

@yh-luo
Copy link
Contributor

@yh-luo yh-luo commented May 24, 2020

Reference issue

Implementation in #7815

Additional information

After a deprecation cycle, TODO part will replace the current default value 0.25.
If that's ok, I will update latest.inc


return labels, scores

def _get_ctps_threshold(self, Pk_threshold=1e-20):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def _get_ctps_threshold(self, Pk_threshold=1e-20):
def _get_ctps_threshold(self, pk_threshold=1e-20):

you should not have capitals in snake_case variable names if you follow pep8 rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the paper, Pk was log-transformed to pk: pk = -log10(Pk). Because the threshold value used here was Pk, I wondered if Pk_threshold would be more appropriate than pk_threshold? or maybe significance_level would be better?

@agramfort
Copy link
Member

agramfort commented May 25, 2020 via email

@yh-luo
Copy link
Contributor Author

yh-luo commented May 25, 2020

Pk is a value to evaluate whether an IC is ECG-related.

Pk

@agramfort
Copy link
Member

agramfort commented May 25, 2020 via email

* ENH: Test deprecation warning for ctps threshold

* DOC: Update find_bads_ecg documentation
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

git grep find_bads_ecg suggests you'll also need to update tutorials/preprocessing/plot_40_artifact_correction_ica.py, preferably to use the new threshold='auto' option

assert_equal(len(scores), ica.n_components_)

idx, scores = ica.find_bads_ecg(evoked, method='correlation')
idx, scores = ica.find_bads_ecg(evoked, method='correlation', threshold=3)
Copy link
Member

Choose a reason for hiding this comment

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

Can this be changed to threshold='auto' and still work?

Copy link
Member

Choose a reason for hiding this comment

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

This has not been checked yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reminding, I've checked and updated the influenced tests and examples.

@agramfort
Copy link
Member

agramfort commented May 26, 2020 via email

* ENH: Tests for ECG detection uses threshold='auto' instead of None
@yh-luo
Copy link
Contributor Author

yh-luo commented May 27, 2020

threshold='auto' passed for both ctps and correlation methods locally, so I updated test_ica.py to use the new threshod='auto'

BTW, the computed threshold in plot_run_ica.py is 0.41 (the original default is 0.25) because the data were resampled to 150 Hz. Though both thresholds converged to the same components, I think it would be better to determine the threshold based on data sampling rate. Thus the threshold in plot_run_ica.py for CTPS method was updated to 'auto' instead of the current default 0.25.
To make sure the detected components are ECG related, the estimated source of the components are visualized.

@agramfort
Copy link
Member

@yh-luo you will need to update latest.inc file to get credit and document this improvement. thanks

@yh-luo yh-luo changed the title WIP, ENH: Automatically compute threshold for CTPS ECG detection MRG, ENH: Automatically compute threshold for CTPS ECG detection May 27, 2020

- The function ``mne.channels.read_dig_captrack`` will be deprecated in version 0.22 in favor of :func:`mne.channels.read_dig_captrak` to correct the spelling error: "captraCK" -> "captraK", by `Stefan Appelhoff`_

- The ``threshold`` argument in :meth:`mne.preprocessing.ICA.find_bads_ecg` defaults to ``None`` in version 0.21 but will change to ``'auto'`` in 0.22 by `Yu-Han Luo`_
Copy link
Member

Choose a reason for hiding this comment

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

you need you add your name to names.inc too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you! I had added my name to names.inc in previous PR, so I did not in this one. Locally built documentation works as expected.

@agramfort agramfort merged commit bbc853e into mne-tools:master May 27, 2020
@agramfort
Copy link
Member

thx @yh-luo !

larsoner added a commit to larsoner/mne-python that referenced this pull request May 28, 2020
* upstream/master:
  MRG: Add support for foreground in _Brain (mne-tools#7843)
  MRG, MAINT: Change default role in conf.py (mne-tools#7841)
  MRG, ENH: Support n_col keyword in ica.plot_score (mne-tools#7825)
  add icons to source dist (mne-tools#7840)
  Add CZI to list of funders (mne-tools#7839)
  DOC: added reference to sesameeg package (mne-tools#7835)
  MRG, ENH: Automatically compute threshold for CTPS ECG detection (mne-tools#7819)
  MAINT: Show how picks work for planars (mne-tools#7833)
  Clearer info docstring (mne-tools#7832)
  MRG, ENH: Add estimation method legend (mne-tools#7830)
  Remove double spaces (mne-tools#7822)
  add troubleshooting message about OpenGL [skip travis] (mne-tools#7827)
  fix links [skip travis] (mne-tools#7826)
@yh-luo yh-luo deleted the ica_ecg branch August 11, 2020 01:23
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.

3 participants