MCPcopy
hub / github.com/mne-tools/mne-python / SourceSimulator

Class SourceSimulator

mne/simulation/source.py:348–589  ·  view source on GitHub ↗

Class to generate simulated Source Estimates. Parameters ---------- src : instance of SourceSpaces Source space. tstep : float Time step between successive samples in data. Default is 0.001 s. duration : float | None Time interval during which the simulat

Source from the content-addressed store, hash-verified

346
347
348class SourceSimulator:
349 """Class to generate simulated Source Estimates.
350
351 Parameters
352 ----------
353 src : instance of SourceSpaces
354 Source space.
355 tstep : float
356 Time step between successive samples in data. Default is 0.001 s.
357 duration : float | None
358 Time interval during which the simulation takes place in seconds.
359 If None, it is computed using existing events and waveform lengths.
360 first_samp : int
361 First sample from which the simulation takes place, as an integer.
362 Comparable to the :term:`first_samp` property of `~mne.io.Raw` objects.
363 Default is 0.
364
365 Attributes
366 ----------
367 duration : float
368 The duration of the simulation in seconds.
369 n_times : int
370 The number of time samples of the simulation.
371 """
372
373 def __init__(self, src, tstep=1e-3, duration=None, first_samp=0):
374 if duration is not None and duration < tstep:
375 raise ValueError("duration must be None or >= tstep.")
376 self.first_samp = _ensure_int(first_samp, "first_samp")
377 self._src = src
378 self._tstep = tstep
379 self._labels = []
380 self._waveforms = []
381 self._events = np.empty((0, 3), dtype=int)
382 self._duration = duration # if not None, sets # samples
383 self._last_samples = []
384 self._chk_duration = 1000
385
386 @property
387 def duration(self):
388 """Duration of the simulation in same units as tstep."""
389 if self._duration is not None:
390 return self._duration
391 return self.n_times * self._tstep
392
393 @property
394 def n_times(self):
395 """Number of time samples in the simulation."""
396 if self._duration is not None:
397 return int(self._duration / self._tstep)
398 ls = self.first_samp
399 if len(self._last_samples) > 0:
400 ls = np.max(self._last_samples)
401 return ls - self.first_samp + 1 # >= 1
402
403 @property
404 def last_samp(self):
405 return self.first_samp + self.n_times - 1

Callers 2

test_simulate_raw_bemFunction · 0.90
test_source_simulatorFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_simulate_raw_bemFunction · 0.72
test_source_simulatorFunction · 0.72