Crop raw data file. Limit the data from the raw file to go between specific times. Note that the new ``tmin`` is assumed to be ``t=0`` for all subsequently called functions (e.g., :meth:`~mne.io.Raw.time_as_index`, or :class:`~mne.Epochs`). New :term:`first_samp` and
(
self,
tmin=0.0,
tmax=None,
include_tmax=True,
*,
reset_first_samp=False,
verbose=None,
)
| 1569 | |
| 1570 | @verbose |
| 1571 | def crop( |
| 1572 | self, |
| 1573 | tmin=0.0, |
| 1574 | tmax=None, |
| 1575 | include_tmax=True, |
| 1576 | *, |
| 1577 | reset_first_samp=False, |
| 1578 | verbose=None, |
| 1579 | ): |
| 1580 | """Crop raw data file. |
| 1581 | |
| 1582 | Limit the data from the raw file to go between specific times. Note |
| 1583 | that the new ``tmin`` is assumed to be ``t=0`` for all subsequently |
| 1584 | called functions (e.g., :meth:`~mne.io.Raw.time_as_index`, or |
| 1585 | :class:`~mne.Epochs`). New :term:`first_samp` and :term:`last_samp` |
| 1586 | are set accordingly. |
| 1587 | |
| 1588 | Thus function operates in-place on the instance. |
| 1589 | Use :meth:`mne.io.Raw.copy` if operation on a copy is desired. |
| 1590 | |
| 1591 | Parameters |
| 1592 | ---------- |
| 1593 | %(tmin_raw)s |
| 1594 | %(tmax_raw)s |
| 1595 | %(include_tmax)s |
| 1596 | reset_first_samp : bool |
| 1597 | If True, reset :term:`first_samp` to 0 after cropping, treating |
| 1598 | the cropped segment as an independent recording. Note that this |
| 1599 | can break things if you extracted events before cropping and try |
| 1600 | to use them afterward. Default is False. |
| 1601 | |
| 1602 | .. versionadded:: 1.12 |
| 1603 | %(verbose)s |
| 1604 | |
| 1605 | Returns |
| 1606 | ------- |
| 1607 | raw : instance of Raw |
| 1608 | The cropped raw object, modified in-place. |
| 1609 | |
| 1610 | Notes |
| 1611 | ----- |
| 1612 | After cropping, :term:`first_samp` is updated to reflect the new |
| 1613 | start of the data, preserving the original recording timeline. |
| 1614 | This means ``raw.times`` will still start at ``0.0``, but |
| 1615 | ``raw.first_samp`` will reflect the offset from the original |
| 1616 | recording. If you want to treat the cropped segment as an |
| 1617 | independent signal with ``first_samp=0``, you can convert it |
| 1618 | to a :class:`~mne.io.RawArray`:: |
| 1619 | |
| 1620 | raw_array = mne.io.RawArray(raw.get_data(), raw.info) |
| 1621 | |
| 1622 | Examples |
| 1623 | -------- |
| 1624 | By default, cropping preserves the original recording timeline, |
| 1625 | so :term:`first_samp` remains non-zero after cropping:: |
| 1626 | |
| 1627 | >>> raw = mne.io.read_raw_fif(fname) # doctest: +SKIP |
| 1628 | >>> print(raw.first_samp) # doctest: +SKIP |