Remove SSP projection vector. .. note:: The projection vector can only be removed if it is inactive (has not been applied to the data). Parameters ---------- idx : int | list of int | str Index of the projector to remove. Can also be "a
(self, idx="all")
| 349 | return self |
| 350 | |
| 351 | def del_proj(self, idx="all"): |
| 352 | """Remove SSP projection vector. |
| 353 | |
| 354 | .. note:: The projection vector can only be removed if it is inactive |
| 355 | (has not been applied to the data). |
| 356 | |
| 357 | Parameters |
| 358 | ---------- |
| 359 | idx : int | list of int | str |
| 360 | Index of the projector to remove. Can also be "all" (default) |
| 361 | to remove all projectors. |
| 362 | |
| 363 | Returns |
| 364 | ------- |
| 365 | self : same type as the input data |
| 366 | The instance. |
| 367 | """ |
| 368 | if isinstance(idx, str) and idx == "all": |
| 369 | idx = list(range(len(self.info["projs"]))) |
| 370 | idx = np.atleast_1d(np.array(idx, int)).ravel() |
| 371 | |
| 372 | for ii in idx: |
| 373 | proj = self.info["projs"][ii] |
| 374 | if proj["active"] and set(self.info["ch_names"]) & set( |
| 375 | proj["data"]["col_names"] |
| 376 | ): |
| 377 | msg = ( |
| 378 | f"Cannot remove projector that has already been " |
| 379 | f"applied, unless you first remove all channels it " |
| 380 | f"applies to. The problematic projector is: {proj}" |
| 381 | ) |
| 382 | raise ValueError(msg) |
| 383 | |
| 384 | keep = np.ones(len(self.info["projs"])) |
| 385 | keep[idx] = False # works with negative indexing and does checks |
| 386 | with self.info._unlock(): |
| 387 | self.info["projs"] = [p for p, k in zip(self.info["projs"], keep) if k] |
| 388 | return self |
| 389 | |
| 390 | @fill_doc |
| 391 | def plot_projs_topomap( |