Skip to content

Commit 877e270

Browse files
committed
DOC: describe the new function, mention in the tutorial
1 parent e5aac42 commit 877e270

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def linkcode_resolve(domain, info):
113113
"SourceEstimate": "mne.SourceEstimate",
114114
# MEEGsim
115115
"SourceConfiguration": "meegsim.configuration.SourceConfiguration",
116+
"PointSource": "meegsim.sources.PointSource",
117+
"PatchSource": "meegsim.sources.PatchSource",
116118
}
117119
numpydoc_xref_ignore = {
118120
"type",

docs/user_guide/get_started/configuration.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ specific value of the ``random_state`` as shown below:
5353
5454
The resulting source configuration, including the locations and waveforms of all
5555
sources, will be the same on every call.
56+
57+
Accessing the simulated sources
58+
===============================
59+
60+
The simulated sources can be quickly accessed by their name (`"source"` in the
61+
example below). This might be helpful in case ground-truth waveforms were
62+
generated randomly:
63+
64+
.. code-block:: python
65+
66+
s = sc["source"]
67+
gt = s.waveform

src/meegsim/configuration.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ def __init__(self, src, sfreq, duration, random_state=None):
4545
self._noise_sources = {}
4646

4747
def __getitem__(self, name):
48+
"""
49+
This function provides quick access to the simulated sources, the syntax
50+
is similar to list/dict access: ``sc[name]`` returns the corresponding source
51+
if it is present in the configuration.
52+
53+
Parameters
54+
----------
55+
name : str
56+
Name of the source.
57+
58+
Returns
59+
-------
60+
source : PointSource or PatchSource
61+
The corresponding source.
62+
63+
Raises
64+
------
65+
ValueError
66+
In case there is no source with the provided name.
67+
"""
4868
check_if_source_exists(
4969
name,
5070
list(self._sources.keys()),

0 commit comments

Comments
 (0)