Assign score to components based on statistic or metric. Parameters ---------- inst : instance of Raw, Epochs or Evoked The object to reconstruct the sources from. target : array-like | str | None Signal to which the sources shall be compared.
(
self,
inst,
target=None,
score_func="pearsonr",
start=None,
stop=None,
l_freq=None,
h_freq=None,
reject_by_annotation=True,
verbose=None,
)
| 1383 | |
| 1384 | @verbose |
| 1385 | def score_sources( |
| 1386 | self, |
| 1387 | inst, |
| 1388 | target=None, |
| 1389 | score_func="pearsonr", |
| 1390 | start=None, |
| 1391 | stop=None, |
| 1392 | l_freq=None, |
| 1393 | h_freq=None, |
| 1394 | reject_by_annotation=True, |
| 1395 | verbose=None, |
| 1396 | ): |
| 1397 | """Assign score to components based on statistic or metric. |
| 1398 | |
| 1399 | Parameters |
| 1400 | ---------- |
| 1401 | inst : instance of Raw, Epochs or Evoked |
| 1402 | The object to reconstruct the sources from. |
| 1403 | target : array-like | str | None |
| 1404 | Signal to which the sources shall be compared. It has to be of |
| 1405 | the same shape as the sources. If str, a routine will try to find |
| 1406 | a matching channel name. If None, a score |
| 1407 | function expecting only one input-array argument must be used, |
| 1408 | for instance, scipy.stats.skew (default). |
| 1409 | score_func : callable | str |
| 1410 | Callable taking as arguments either two input arrays |
| 1411 | (e.g. Pearson correlation) or one input |
| 1412 | array (e. g. skewness) and returns a float. For convenience the |
| 1413 | most common score_funcs are available via string labels: |
| 1414 | Currently, all distance metrics from scipy.spatial and All |
| 1415 | functions from scipy.stats taking compatible input arguments are |
| 1416 | supported. These function have been modified to support iteration |
| 1417 | over the rows of a 2D array. |
| 1418 | start : int | float | None |
| 1419 | First sample to include. If float, data will be interpreted as |
| 1420 | time in seconds. If None, data will be used from the first sample. |
| 1421 | stop : int | float | None |
| 1422 | Last sample to not include. If float, data will be interpreted as |
| 1423 | time in seconds. If None, data will be used to the last sample. |
| 1424 | l_freq : float |
| 1425 | Low pass frequency. |
| 1426 | h_freq : float |
| 1427 | High pass frequency. |
| 1428 | %(reject_by_annotation_all)s |
| 1429 | |
| 1430 | .. versionadded:: 0.14.0 |
| 1431 | %(verbose)s |
| 1432 | |
| 1433 | Returns |
| 1434 | ------- |
| 1435 | scores : ndarray |
| 1436 | Scores for each source as returned from score_func. |
| 1437 | """ |
| 1438 | if isinstance(inst, BaseRaw): |
| 1439 | _check_compensation_grade( |
| 1440 | self.info, inst.info, "ICA", "Raw", ch_names=self.ch_names |
| 1441 | ) |
| 1442 | sources = self._transform_raw(inst, start, stop, reject_by_annotation) |