Crop data to a given time interval. Parameters ---------- tmin : float | None Start time of selection in seconds. tmax : float | None End time of selection in seconds. %(include_tmax)s %(verbose)s Returns -----
(self, tmin=None, tmax=None, include_tmax=True, verbose=None)
| 229 | |
| 230 | @verbose |
| 231 | def crop(self, tmin=None, tmax=None, include_tmax=True, verbose=None): |
| 232 | """Crop data to a given time interval. |
| 233 | |
| 234 | Parameters |
| 235 | ---------- |
| 236 | tmin : float | None |
| 237 | Start time of selection in seconds. |
| 238 | tmax : float | None |
| 239 | End time of selection in seconds. |
| 240 | %(include_tmax)s |
| 241 | %(verbose)s |
| 242 | |
| 243 | Returns |
| 244 | ------- |
| 245 | self : instance of Dipole |
| 246 | The cropped instance. |
| 247 | """ |
| 248 | sfreq = None |
| 249 | if len(self.times) > 1: |
| 250 | sfreq = 1.0 / np.median(np.diff(self.times)) |
| 251 | mask = _time_mask( |
| 252 | self.times, tmin, tmax, sfreq=sfreq, include_tmax=include_tmax |
| 253 | ) |
| 254 | self._set_times(self.times[mask]) |
| 255 | for attr in ("_pos", "_gof", "_amplitude", "_ori", "_khi2", "_nfree"): |
| 256 | if getattr(self, attr) is not None: |
| 257 | setattr(self, attr, getattr(self, attr)[mask]) |
| 258 | for key in self.conf.keys(): |
| 259 | self.conf[key] = self.conf[key][mask] |
| 260 | return self |
| 261 | |
| 262 | def copy(self): |
| 263 | """Copy the Dipoles object. |