Aux method.
(self, raw, add_channels, start, stop)
| 1268 | return sources |
| 1269 | |
| 1270 | def _sources_as_raw(self, raw, add_channels, start, stop): |
| 1271 | """Aux method.""" |
| 1272 | # merge copied instance and picked data with sources |
| 1273 | start, stop = _check_start_stop(raw, start, stop) |
| 1274 | data_ = self._transform_raw(raw, start=start, stop=stop) |
| 1275 | assert data_.shape[1] == stop - start |
| 1276 | |
| 1277 | preloaded = raw.preload |
| 1278 | if raw.preload: |
| 1279 | # get data and temporarily delete |
| 1280 | data = raw._data |
| 1281 | raw.preload = False |
| 1282 | del raw._data |
| 1283 | # copy and crop here so that things like annotations are adjusted |
| 1284 | try: |
| 1285 | out = raw.copy().crop( |
| 1286 | start / raw.info["sfreq"], (stop - 1) / raw.info["sfreq"] |
| 1287 | ) |
| 1288 | finally: |
| 1289 | # put the data back (always) |
| 1290 | if preloaded: |
| 1291 | raw.preload = True |
| 1292 | raw._data = data |
| 1293 | |
| 1294 | # populate copied raw. |
| 1295 | if add_channels is not None and len(add_channels): |
| 1296 | picks = pick_channels(raw.ch_names, add_channels) |
| 1297 | data_ = np.concatenate([data_, raw.get_data(picks, start=start, stop=stop)]) |
| 1298 | out._data = data_ |
| 1299 | out_first_samp = out.first_samp |
| 1300 | out_last_samp = out.last_samp |
| 1301 | out._first_samps = [out_first_samp] |
| 1302 | out._last_samps = [out_last_samp] |
| 1303 | out.filenames = [None] |
| 1304 | out.preload = True |
| 1305 | out._projector = None |
| 1306 | self._export_info(out.info, raw, add_channels) |
| 1307 | |
| 1308 | return out |
| 1309 | |
| 1310 | def _sources_as_epochs(self, epochs, add_channels, concatenate): |
| 1311 | """Aux method.""" |
no test coverage detected