Apply the PCA-OBS algorithm to picks of a Raw object. Uses the optimal basis set (OBS) algorithm from :footcite:`NiazyEtAl2005`. Parameters ---------- raw : instance of Raw The raw data to process. %(picks_all_data_noref)s qrs_times : ndarray, shape (n_peaks,)
(
raw: Raw,
picks: list[str],
*,
qrs_times: np.ndarray,
n_components: int = 4,
n_jobs: int | None = None,
copy: bool = True,
verbose: bool | str | int | None = None,
)
| 16 | |
| 17 | @verbose |
| 18 | def apply_pca_obs( |
| 19 | raw: Raw, |
| 20 | picks: list[str], |
| 21 | *, |
| 22 | qrs_times: np.ndarray, |
| 23 | n_components: int = 4, |
| 24 | n_jobs: int | None = None, |
| 25 | copy: bool = True, |
| 26 | verbose: bool | str | int | None = None, |
| 27 | ) -> Raw: |
| 28 | """ |
| 29 | Apply the PCA-OBS algorithm to picks of a Raw object. |
| 30 | |
| 31 | Uses the optimal basis set (OBS) algorithm from :footcite:`NiazyEtAl2005`. |
| 32 | |
| 33 | Parameters |
| 34 | ---------- |
| 35 | raw : instance of Raw |
| 36 | The raw data to process. |
| 37 | %(picks_all_data_noref)s |
| 38 | qrs_times : ndarray, shape (n_peaks,) |
| 39 | Array of times in the Raw data of detected R-peaks in ECG channel. |
| 40 | n_components : int |
| 41 | Number of PCA components to use to form the OBS (default 4). |
| 42 | %(n_jobs)s |
| 43 | copy : bool |
| 44 | If False, modify the Raw instance in-place. |
| 45 | If True (default), copy the raw instance before processing. |
| 46 | %(verbose)s |
| 47 | |
| 48 | Returns |
| 49 | ------- |
| 50 | raw : instance of Raw |
| 51 | The modified raw instance. |
| 52 | |
| 53 | Notes |
| 54 | ----- |
| 55 | .. versionadded:: 1.10 |
| 56 | |
| 57 | References |
| 58 | ---------- |
| 59 | .. footbibliography:: |
| 60 | """ |
| 61 | # sanity checks |
| 62 | _validate_type(qrs_times, np.ndarray, "qrs_times") |
| 63 | if len(qrs_times.shape) > 1: |
| 64 | raise ValueError("qrs_times must be a 1d array") |
| 65 | if qrs_times.dtype not in [int, float]: |
| 66 | raise ValueError("qrs_times must be an array of either integers or floats") |
| 67 | if np.any(qrs_times < 0): |
| 68 | raise ValueError("qrs_times must be strictly positive") |
| 69 | if np.any(qrs_times >= raw.times[-1]): |
| 70 | logger.warning("some out of bound qrs_times will be ignored..") |
| 71 | |
| 72 | if copy: |
| 73 | raw = raw.copy() |
| 74 | |
| 75 | raw.apply_function( |