Make a set of :term:`events` separated by a fixed duration. Parameters ---------- raw : instance of Raw A raw object to use the data from. id : int The id to use (default 1). start : float Time of first event (in seconds). stop : float | None
(
raw,
id=1, # noqa: A002
start=0,
stop=None,
duration=1.0,
first_samp=True,
overlap=0.0,
)
| 921 | |
| 922 | @fill_doc |
| 923 | def make_fixed_length_events( |
| 924 | raw, |
| 925 | id=1, # noqa: A002 |
| 926 | start=0, |
| 927 | stop=None, |
| 928 | duration=1.0, |
| 929 | first_samp=True, |
| 930 | overlap=0.0, |
| 931 | ): |
| 932 | """Make a set of :term:`events` separated by a fixed duration. |
| 933 | |
| 934 | Parameters |
| 935 | ---------- |
| 936 | raw : instance of Raw |
| 937 | A raw object to use the data from. |
| 938 | id : int |
| 939 | The id to use (default 1). |
| 940 | start : float |
| 941 | Time of first event (in seconds). |
| 942 | stop : float | None |
| 943 | Maximum time of last event (in seconds). If None, events extend to the |
| 944 | end of the recording. |
| 945 | duration : float |
| 946 | The duration to separate events by (in seconds). |
| 947 | first_samp : bool |
| 948 | If True (default), times will have :term:`first_samp` added to them, as |
| 949 | in :func:`mne.find_events`. This behavior is not desirable if the |
| 950 | returned events will be combined with event times that already |
| 951 | have :term:`first_samp` added to them, e.g. event times that come |
| 952 | from :func:`mne.find_events`. |
| 953 | overlap : float |
| 954 | The overlap between events (in seconds). |
| 955 | Must be ``0 <= overlap < duration``. |
| 956 | |
| 957 | .. versionadded:: 0.18 |
| 958 | |
| 959 | Returns |
| 960 | ------- |
| 961 | %(events)s |
| 962 | """ |
| 963 | from .io import BaseRaw |
| 964 | |
| 965 | _validate_type(raw, BaseRaw, "raw") |
| 966 | _validate_type(id, "int", "id") |
| 967 | _validate_type(duration, "numeric", "duration") |
| 968 | _validate_type(overlap, "numeric", "overlap") |
| 969 | duration, overlap = float(duration), float(overlap) |
| 970 | if not 0 <= overlap < duration: |
| 971 | raise ValueError( |
| 972 | f"overlap must be >=0 but < duration ({duration}), got {overlap}" |
| 973 | ) |
| 974 | |
| 975 | start = raw.time_as_index(start, use_rounding=True)[0] |
| 976 | if stop is not None: |
| 977 | stop = raw.time_as_index(stop, use_rounding=True)[0] |
| 978 | else: |
| 979 | stop = raw.last_samp + 1 |
| 980 | if first_samp: |