Get the stim channel from the provided data. Returns the stim channel data according to the simulation parameters which should be added through the add_data method. If both start_sample and stop_sample are not specified, the entire duration is used. Parameters
(self, start_sample=0, stop_sample=None)
| 451 | ) |
| 452 | |
| 453 | def get_stim_channel(self, start_sample=0, stop_sample=None): |
| 454 | """Get the stim channel from the provided data. |
| 455 | |
| 456 | Returns the stim channel data according to the simulation parameters |
| 457 | which should be added through the add_data method. If both start_sample |
| 458 | and stop_sample are not specified, the entire duration is used. |
| 459 | |
| 460 | Parameters |
| 461 | ---------- |
| 462 | start_sample : int |
| 463 | First sample in chunk. Default is the value of the ``first_samp`` |
| 464 | attribute. |
| 465 | stop_sample : int | None |
| 466 | The final sample of the returned stc. If None, then all samples |
| 467 | from start_sample onward are returned. |
| 468 | |
| 469 | Returns |
| 470 | ------- |
| 471 | stim_data : ndarray of int, shape (n_samples,) |
| 472 | The stimulation channel data. |
| 473 | """ |
| 474 | if start_sample is None: |
| 475 | start_sample = self.first_samp |
| 476 | if stop_sample is None: |
| 477 | stop_sample = start_sample + self.n_times - 1 |
| 478 | elif stop_sample < start_sample: |
| 479 | raise ValueError("Argument start_sample must be >= stop_sample.") |
| 480 | n_samples = stop_sample - start_sample + 1 |
| 481 | |
| 482 | # Initialize the stim data array |
| 483 | stim_data = np.zeros(n_samples, dtype=np.int64) |
| 484 | |
| 485 | # Select only events in the time chunk |
| 486 | stim_ind = np.where( |
| 487 | np.logical_and( |
| 488 | self._events[:, 0] >= start_sample, self._events[:, 0] < stop_sample |
| 489 | ) |
| 490 | )[0] |
| 491 | |
| 492 | if len(stim_ind) > 0: |
| 493 | relative_ind = self._events[stim_ind, 0] - start_sample |
| 494 | stim_data[relative_ind] = self._events[stim_ind, 2] |
| 495 | |
| 496 | return stim_data |
| 497 | |
| 498 | def get_stc(self, start_sample=None, stop_sample=None): |
| 499 | """Simulate a SourceEstimate from the provided data. |
no outgoing calls