Apply a function to a subset of channels. %(applyfun_summary_evoked)s Parameters ---------- %(fun_applyfun_evoked)s %(picks_all_data_noref)s %(dtype_applyfun)s %(n_jobs)s Ignored if ``channel_wise=False`` as the workload is split
(
self,
fun,
picks=None,
dtype=None,
n_jobs=None,
channel_wise=True,
*,
verbose=None,
**kwargs,
)
| 266 | |
| 267 | @verbose |
| 268 | def apply_function( |
| 269 | self, |
| 270 | fun, |
| 271 | picks=None, |
| 272 | dtype=None, |
| 273 | n_jobs=None, |
| 274 | channel_wise=True, |
| 275 | *, |
| 276 | verbose=None, |
| 277 | **kwargs, |
| 278 | ): |
| 279 | """Apply a function to a subset of channels. |
| 280 | |
| 281 | %(applyfun_summary_evoked)s |
| 282 | |
| 283 | Parameters |
| 284 | ---------- |
| 285 | %(fun_applyfun_evoked)s |
| 286 | %(picks_all_data_noref)s |
| 287 | %(dtype_applyfun)s |
| 288 | %(n_jobs)s Ignored if ``channel_wise=False`` as the workload |
| 289 | is split across channels. |
| 290 | %(channel_wise_applyfun)s |
| 291 | |
| 292 | .. versionadded:: 1.6 |
| 293 | %(verbose)s |
| 294 | %(kwargs_fun)s |
| 295 | |
| 296 | Returns |
| 297 | ------- |
| 298 | self : instance of Evoked |
| 299 | The evoked object with transformed data. |
| 300 | """ |
| 301 | _check_preload(self, "evoked.apply_function") |
| 302 | picks = _picks_to_idx(self.info, picks, exclude=(), with_ref_meg=False) |
| 303 | |
| 304 | if not callable(fun): |
| 305 | raise ValueError("fun needs to be a function") |
| 306 | |
| 307 | data_in = self._data |
| 308 | if dtype is not None and dtype != self._data.dtype: |
| 309 | self._data = self._data.astype(dtype) |
| 310 | |
| 311 | args = getfullargspec(fun).args + getfullargspec(fun).kwonlyargs |
| 312 | if channel_wise is False: |
| 313 | if ("ch_idx" in args) or ("ch_name" in args): |
| 314 | raise ValueError( |
| 315 | "apply_function cannot access ch_idx or ch_name " |
| 316 | "when channel_wise=False" |
| 317 | ) |
| 318 | if "ch_idx" in args: |
| 319 | logger.info("apply_function requested to access ch_idx") |
| 320 | if "ch_name" in args: |
| 321 | logger.info("apply_function requested to access ch_name") |
| 322 | |
| 323 | # check the dimension of the incoming evoked data |
| 324 | _check_option("evoked.ndim", self._data.ndim, [2]) |
| 325 |
nothing calls this directly
no test coverage detected