Eliminate stimulation's artifacts from instance. .. note:: This function operates in-place, consider passing ``inst.copy()`` if this is not desired. Parameters ---------- inst : instance of Raw or Epochs or Evoked The data. events : array, shape (n_events,
(
inst,
events=None,
event_id=None,
tmin=0.0,
tmax=0.01,
*,
baseline=None,
mode="linear",
stim_channel=None,
picks=None,
)
| 42 | |
| 43 | @fill_doc |
| 44 | def fix_stim_artifact( |
| 45 | inst, |
| 46 | events=None, |
| 47 | event_id=None, |
| 48 | tmin=0.0, |
| 49 | tmax=0.01, |
| 50 | *, |
| 51 | baseline=None, |
| 52 | mode="linear", |
| 53 | stim_channel=None, |
| 54 | picks=None, |
| 55 | ): |
| 56 | """Eliminate stimulation's artifacts from instance. |
| 57 | |
| 58 | .. note:: This function operates in-place, consider passing |
| 59 | ``inst.copy()`` if this is not desired. |
| 60 | |
| 61 | Parameters |
| 62 | ---------- |
| 63 | inst : instance of Raw or Epochs or Evoked |
| 64 | The data. |
| 65 | events : array, shape (n_events, 3) |
| 66 | The list of events. Required only when inst is Raw. |
| 67 | event_id : int |
| 68 | The id of the events generating the stimulation artifacts. |
| 69 | If None, read all events. Required only when inst is Raw. |
| 70 | tmin : float |
| 71 | Start time of the interpolation window in seconds. |
| 72 | tmax : float |
| 73 | End time of the interpolation window in seconds. |
| 74 | baseline : None | tuple, shape (2,) |
| 75 | The baseline to use when ``mode='constant'``, in which case it |
| 76 | must be non-None. |
| 77 | |
| 78 | .. versionadded:: 1.8 |
| 79 | mode : 'linear' | 'window' | 'constant' |
| 80 | Way to fill the artifacted time interval. |
| 81 | |
| 82 | ``"linear"`` |
| 83 | Does linear interpolation. |
| 84 | ``"window"`` |
| 85 | Applies a ``(1 - hanning)`` window. |
| 86 | ``"constant"`` |
| 87 | Uses baseline average. baseline parameter must be provided. |
| 88 | |
| 89 | .. versionchanged:: 1.8 |
| 90 | Added the ``"constant"`` mode. |
| 91 | stim_channel : str | None |
| 92 | Stim channel to use. |
| 93 | %(picks_all_data)s |
| 94 | |
| 95 | Returns |
| 96 | ------- |
| 97 | inst : same type as the input data |
| 98 | Instance with modified data. |
| 99 | """ |
| 100 | _check_option("mode", mode, ["linear", "window", "constant"]) |
| 101 | s_start = int(np.ceil(inst.info["sfreq"] * tmin)) |