MCPcopy
hub / github.com/mne-tools/mne-python / _get_ctps_threshold

Method _get_ctps_threshold

mne/preprocessing/ica.py:1578–1600  ·  view source on GitHub ↗

Automatically decide the threshold of Kuiper index for CTPS method. This function finds the threshold of Kuiper index based on the threshold of pk. Kuiper statistic that minimizes the difference between pk and the pk threshold (defaults to 20 :footcite:`DammersEtAl2008`)

(self, pk_threshold=20)

Source from the content-addressed store, hash-verified

1576 return labels, scores
1577
1578 def _get_ctps_threshold(self, pk_threshold=20):
1579 """Automatically decide the threshold of Kuiper index for CTPS method.
1580
1581 This function finds the threshold of Kuiper index based on the
1582 threshold of pk. Kuiper statistic that minimizes the difference between
1583 pk and the pk threshold (defaults to 20 :footcite:`DammersEtAl2008`)
1584 is returned. It is assumed that the data are appropriately filtered and
1585 bad data are rejected at least based on peak-to-peak amplitude
1586 when/before running the ICA decomposition on data.
1587
1588 References
1589 ----------
1590 .. footbibliography::
1591 """
1592 N = self.info["sfreq"]
1593 Vs = np.arange(1, 100) / 100
1594 C = math.sqrt(N) + 0.155 + 0.24 / math.sqrt(N)
1595 # in formula (13), when k gets large, only k=1 matters for the
1596 # summation. k*V*C thus becomes V*C
1597 Pks = 2 * (4 * (Vs * C) ** 2 - 1) * (np.exp(-2 * (Vs * C) ** 2))
1598 # NOTE: the threshold of pk is transformed to Pk for comparison
1599 # pk = -log10(Pk)
1600 return Vs[np.argmin(np.abs(Pks - 10 ** (-pk_threshold)))]
1601
1602 @verbose
1603 def find_bads_ecg(

Callers 2

find_bads_ecgMethod · 0.95
test_ica_additionalFunction · 0.95

Calls 1

sqrtMethod · 0.80

Tested by 1

test_ica_additionalFunction · 0.76