Skip to content

Commit 0fec201

Browse files
authored
Merge pull request #159 from zm711/main
Improve Docs I
2 parents a95f00b + 8464a45 commit 0fec201

4 files changed

Lines changed: 39 additions & 39 deletions

File tree

docs/generate_recordings.rst

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Generating Recordings
44
=====================
55

6-
Recordings are generated combining templates and spike trains. The recordings parameters are divided in different
6+
Recordings are generated combining templates and spike trains. The recordings parameters are divided into different
77
sections:
88

99
* :code:`spiketrains`
@@ -13,8 +13,8 @@ sections:
1313
* :code:`seeds`
1414

1515
The :code:`spiketrains` part deals with the generation of spike trains, while the :code:`templates`,
16-
:code:`cell-types`, and :code:`recordings` sections specify parameters to assemble spike trains and templates and build
17-
the extracellular recordings. The :code:`seeds` contains all the random seeds involved in the simulations, to ensure
16+
:code:`cell-types`, and :code:`recordings` sections specify parameters to assemble templates, select cell types, and build
17+
the extracellular recordings, respectively. The :code:`seeds` contains all the random seeds involved in the simulations to ensure
1818
reproducibility.
1919

2020

@@ -23,19 +23,19 @@ Spike trains generation
2323

2424
The first step is the spike train generation. The user can specify the number and type of cells in 2 ways:
2525

26-
1. providing a list of :code:`rates` and corresponding :code:`types`: e.g. rates = [3, 3, 5], types = ['E', 'E', 'E']
26+
1. providing a list of :code:`rates` and corresponding :code:`types`: e.g. rates = [3, 3, 5], types = ['E', 'E', 'I']
2727
will generate 3 spike trains with average firing rates 3, 3, and 5 Hz and respectively excitatory, excitatory , and inhibitory type.
2828
2. providing :code:`n_exc`, :code:`n_inh`, :code:`f_exc`, :code:`f_inh`, :code:`st_exc`, :code:`st_min`: in this case
2929
there will be generated :code:`n_exc` excitatory spike trains with average firing rate of :code:`f_exc` and firing rate standard deviation of :code:`st_exc` (same for inhibitory spike trains)
3030

31-
The firinga rates generated with the second option have a minimum firing rate of :code:`min_rate` (default 0.5 Hz).
31+
The firing rates generated with the second option have a minimum firing rate of :code:`min_rate` (default 0.5 Hz).
3232

3333
Spike trains are simulated as Poisson or Gamma processes (chosen with the parameter :code:`process`) and in the latter
3434
case the :code:`gamma` parameter controls the curve shape.
3535

3636
Spikes violating the refreactory period :code:`ref_per` (default is 2 ms) are removed.
3737

38-
:code:`t_start` (0 s by default) is the start timestamp of the recordings in second and :code:`duration` will correspond
38+
:code:`t_start` (0 s by default) is the start timestamp of the recordings in seconds and :code:`duration` will correspond
3939
to the duration of the recordings.
4040

4141

@@ -60,7 +60,7 @@ Spike trains parameters section summary
6060
st_inh: 3 # firing rate standard deviation of inhibitory cells in Hz
6161
min_rate: 0.5 # minimum firing rate in Hz
6262
ref_per: 2 # refractory period in ms
63-
process: poisson # process for spike train simulation (poisson-gamma)
63+
process: poisson # process for spike train simulation (poisson, gamma)
6464
gamma_shape: 2 # gamma shape (for gamma process)
6565
t_start: 0 # start time in s
6666
duration: 10 # duration in s
@@ -72,8 +72,8 @@ Recordings Generation
7272
Specifying excitatory and inhibitory cell-types
7373
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7474

75-
In order to select the proper cell type (excitatory - inhibitory) the :code:`cell-types` section of the parameters
76-
allows the user to specify which strings to look for in the cell model name (from the NMC database) to assign it to
75+
In order to select the proper cell type (excitatory or inhibitory) the :code:`cell-types` section of the parameters
76+
allows the user to specify which strings to look for in the cell model name (from the NMC database) to assign it to
7777
the excitatory or inhibitory set. In this example from L5 cells, all cells contining LBC (Large Basket Cells) will be
7878
marked as inhibitory, and so on.
7979
If you use custom cell models, you should overwrite this section as shown in
@@ -104,8 +104,8 @@ provided) and they follow the following rules:
104104
Once the templates are selected and matched to the corresponding spike train, temporal jitter is added to them to
105105
simulate the uncertainty of the spike event within the sampling period. :code:`n_jitters` (default is 10) templates are
106106
created by upsampling the original templates by :code:`upsample` times (default is 8) and shifting them within a
107-
sampling period. During convolution, randomly a jittered version of the spike is selected.
108-
Finally, the templates are linearly padded on both sides (:code:`pad_len` by default pads 3 ms before and 3 after the
107+
sampling period. During convolution, a jittered version of the spike is randomly selected.
108+
Finally, the templates are linearly padded on both sides (:code:`pad_len` by default pads 3 ms before and 3 ms after the
109109
duration of the template) to ensure a smooth convolution.
110110

111111
The :code:`overlap_threshold` allows to define spatially overlapping templates. For example, if set to 0.9 (by default)
@@ -139,7 +139,7 @@ Other recordings settings
139139

140140
After the templates are selected, jittered, and padded, clean recordings are generated by convolving each template with
141141
its corresponding spike train.
142-
The :code:`fs` parameters permits to resample the recordings and if it is not provided recordings are created with the
142+
The :code:`fs` parameters permits resampling of the recordings and if it is not provided recordings are created with the
143143
same sampling frequency as the templates.
144144
Recordings can be split in times chunks using the :code:`chunk_duration` (20 s by default) parameter.
145145
Chunks can be processed in parallel.
@@ -151,7 +151,7 @@ coincident. :code:`sync_jitt` (default 1 ms) controls the jittering in time for
151151
The :code:`modulation` parameter is extremely important, as it controls the variablility of the amplitude modulation:
152152
* if :code:`modulation` id :code:`none`, spikes are not modulated and each instance will have the same aplitude
153153
* if :code:`modulation` id :code:`template`, each spike event is modulated with the same amplitude for all electrodes
154-
* if :code:`modulation` id :code:`electrode`, each spike event is modulated with different amplitude for each electrode
154+
* if :code:`modulation` id :code:`electrode`, each spike event is modulated with a different amplitude for each electrode
155155

156156
For the :code:`template` and :code:`electrode` modulations, the amplitude is modulated as a Normal distribution with
157157
amplitude 1 and standard deviation of :code:`sdrand` (default is 0.05).
@@ -178,14 +178,14 @@ The templates are stretched with the same value on all electrodes, and then, in
178178
the eap on each electrode to match the specific :math:`mod` for the electrode. Also for an :code:`template`-type modulation,
179179
the eap is rescaled at the template level.
180180

181-
Next, noise is added to to the clean recordings. Three different noise modes can be used (using the :code:`noise_mode`
181+
Next, noise is added to the clean recordings. Three different noise modes can be used (using the :code:`noise_mode`
182182
parameter):
183183

184184
1. :code:`uncorrelated`: additive gaussian noise (default) with a standard deviation of :code:`noise_level`
185185
(10 :math:`\mu V` by default)
186186

187-
2. :code:`distance-correlated`: noise is generated as a multivariate normal with covariance matrix decaying with
188-
distance between electrodes. The :code:`noise_half_distance` parameter is the distance for which correlation is 0.5.
187+
2. :code:`distance-correlated`: noise is generated as a multivariate normal with a covariance matrix decaying with
188+
distance between electrodes. The :code:`noise_half_distance` parameter is the distance for which the correlation is 0.5.
189189

190190
3. :code:`far-neurons`: noise is generated by the activity of :code:`far_neurons_n` far neurons (default 300). In order to use this mode,
191191
it is recommended to generate templates with a small or null maximum amplitude. In fact, far neurons if their maximum amplitude
@@ -205,7 +205,7 @@ noise level is adjusted so that the overall standard deviation is equal to :code
205205

206206
Finally, and optionally, the recordings can be filtered (if :code:`filter` is :code:`True`) with a high-pass or band-pass
207207
filter with :code:`filter_cutoff` frequency(ies) ([300, 6000] by default). If :code:`filter_cutoff` is a scalar, the signal is high-pass
208-
filtered. The order of the Butterworth filter can be adjusted with the :code:`filter_order` frequency(ies) param.
208+
filtered. The order of the Butterworth filter can be adjusted with the :code:`filter_order` frequency(ies) parameter.
209209

210210
For further analysis, spike events can be annotated as "TO" (temporal overlapping) or "SO" (spatio-temporal overlapping)
211211
when :code:`overlap` is set to :code:`True`. The waveforms can also be extracted and loaded to the
@@ -262,23 +262,23 @@ When drifting templates are generated (:ref:`drift-templates`), drifting recordi
262262
:code:`drifting` is set to :code:`True`. The :code:`preferred_dir` parameter indicates the 3D vector with the
263263
preferred direction of drift ([0,0,1], default, is upwards in the z-direction) and the :code:`angle_tol` (default is 15
264264
degrees) corresponds to the tolerance in this direction.
265-
There are three types of :code:`drift_mode`: slow or fast.
265+
There are two types of :code:`drift_mode`: slow or fast.
266266
The different modalities vary in terms of how the drifting template is selected for each spike during the modulated convolution.
267267

268-
For slow drifts, a new position is calculated moving from the initial position along the drifting direction with
268+
For slow drift, a new position is calculated moving from the initial position along the drifting direction with
269269
a velocity of :code:`slow_drift_velocity` (default 5 :math:`\mu m`/min).
270270
If a boundary position is reached (initial or final positions), the drift direction is reversed.
271271
The shape of slow drift can be controlled with the :code:`slow_drift_shape` parameter (default is a :code:`triangluar` shape),
272272
while the amplitude in :math:`\mu m` with the :code:`slow_drift_amplitude`.
273273

274-
For fast drifts, the user can set the frequency at which fast drift events occur (every :code:`fast_drift_period` s, default 20 s).
274+
For fast drift, the user can set the frequency at which fast drift events occur (every :code:`fast_drift_period` s, default 20 s).
275275
When a fast drift event happens, a new template position is selected randomly among the drifting templates for each
276276
drifting neuron, so that the amplitude of the new template on the channel in which the old template has the largest
277-
peak is within :code:`fast_drift_min_jump` and :code:`fast_drift_min_jump` (defaults 5-20).
278-
This is to ensure that fast drifts are not too abrupt.
277+
peak is within :code:`fast_drift_min_jump` and :code:`fast_drift_max_jump` (defaults 5 and 20, respectively).
278+
This is to ensure that each fast drift event is not too abrupt.
279279

280280
Drift can be rigid (all neurons drift coherently) or non-rigid (each neuron drifts differently). The :code:`drift_mode_probe` parameter
281-
controls this and in case of non-rigid drift, the a lineare gradient depending on the neurons' depth is applied.
281+
controls this and in the case of non-rigid drift, a linear gradient depending on the neuron's depth is applied.
282282
By default, the neurons at the bottom of the probe will drift at 50% speed with respect to the neurons at the top of the probe.
283283
Other parameters can be controlled. See the :py:func:`~MEArec.drift_tools.generate_drift_dict_from_params` function for more details.
284284

@@ -341,13 +341,13 @@ Recordings can also be generated using a Python script, or a jupyter notebook.
341341
recgen = mr.gen_recordings(params=None, templates=None, tempgen=None, n_jobs=None, verbose=False)
342342
343343
344-
The :code:`params` argument can be the path to a yaml file or a dictionary containing the parameters (if :code:`None`` default
345-
parameters are used). On of the :code:`templates` or :code:`tempgen` parameters must be indicated, the
344+
The :code:`params` argument can be the path to a yaml file or a dictionary containing the parameters (if :code:`None` default
345+
parameters are used). One of the :code:`templates` or :code:`tempgen` parameters must be indicated, the
346346
former pointing to a generated templates file, the latter instead is a :code:`TemplateGenerator` object.
347-
The :code:`n_jobs` argument indicates how many jobs will be used in parallel (for parallel processing, more than 1 chunks
348-
are required).
347+
The :code:`n_jobs` argument indicates how many jobs will be used in parallel (for parallel processing, more than 1 chunk
348+
is required).
349349
If :code:`verbose=True`, the output shows the progress of the template simulation. :code:`verbose=True` corresponds to
350-
:code:`verbose=1`. For a higher level of verbosity also :code:`verbose=2` can be used.
350+
:code:`verbose=1`. For a higher level of verbosity :code:`verbose=2` can also be used.
351351

352352

353353
The :code:`gen_recordings()` function returns a gen_templates :code:`RecordingGenerator` object (:code:`recgen`).
@@ -388,4 +388,4 @@ The :code:`RecordingGenerator` class contains several fields:
388388
import MEArec as mr
389389
mr.save_recording_generator(recgen, filename=None)
390390
391-
where :code:`recgen` is a :code:`RecordingGenerator` object and :code:`filename` is the output file name.
391+
where :code:`recgen` is a :code:`RecordingGenerator` object and :code:`filename` is the output file name.

docs/generate_templates.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Rotations are optional and can be chosen with the :code:`rot` parameter among :c
6060

6161
The :code:`physrot` rotation is default and it is designed for L5 models of the NMC portal. This kind of rotation applies
6262
a physiological rotation to the models: for example, pyramidal cells are rotated along the z-axis (depth) and a small
63-
rendom tilt is applied (15 degrees). Some interneurons, that do not show a preferred orientation, are rotated randomly
63+
random tilt is applied (15 degrees). Some interneurons, that do not show a preferred orientation, are rotated randomly
6464
in 3d.
6565

6666
The :code:`probe` parameter allows the user to choose which neural probe has to be used. Probes are handled with the
@@ -106,17 +106,17 @@ Extracellular parameters summary
106106
Drifting templates
107107
------------------
108108

109-
MEArec allows to generate recordings with drifting units over time. In order to do so, drifting templates have to be
109+
MEArec allows for the generation of recordings with units drifting over time. In order to do so, drifting templates have to be
110110
generated. Note that drifting recordings can be simulated ONLY from drifting templates.
111111

112112
To generate drifting, set the :code:`drifting` parameter to :code:`True`.
113113
Drifting is simulated as follows: first, an initial position is chosen so that the resulting EAP is above the detection
114114
threshold. Second, a final position is chosen so that i) the EAP is above threshold and ii) the drifting distance is
115-
between :code:`min_drift` (defualt 20 :math:`\mu m`) and :code:`max_drift` defualt 100 :math:`\mu m`. Third, the neuron is moved along
115+
between :code:`min_drift` (default 20 :math:`\mu m`) and :code:`max_drift` default 100 :math:`\mu m`. Third, the neuron is moved along
116116
the straight line connecting the initial and final position for :code:`drift_steps` points (default 50).
117117
The :code:`drift_x_lim`, :code:`drift_y_lim`, and :code:`drift_z_lim` can be used to decide the drift directions. For
118118
example, in the default case :code:`drift_x_lim` is [-10, 10], :code:`drift_y_lim` is [-10, 10], and :code:`drift_z_lim`
119-
is [20, 80] and the final position will be pointing upwards in the z-direction, with some small shifts in the x- abd
119+
is [20, 80] and the final position will be pointing upwards in the z-direction, with some small shifts in the x- and
120120
y-axes.
121121

122122
Drifting parameters summary
@@ -151,7 +151,7 @@ If :code:`intraonly` is True, only
151151
the intracellular simulation is run. Simulations are run in parallel if :code:`parallel` is True and the temporary
152152
processing folder is deleted if :code:`delete_tmp` is True. If :code:`n_jobs` is None, the function will use as many jobs
153153
as available cell models (if run in parallel). Finally, the :code:`recompile` argument forces a recompilation of the
154-
models (use this if you added new cell models in the :code:`cell_models_folder`).
154+
models (use this if you have added new cell models in the :code:`cell_models_folder`).
155155
If :code:`verbose` is True, the output shows the progress of the template simulation.
156156

157157
The :code:`gen_templates()` function returns a gen_templates :code:`TemplateGenerator` object (:code:`tempgen`).

docs/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEArec is a Python package and it can be easily installed using pip:
88
pip install MEArec
99
1010
11-
If you want to install from sources and be updated with the latest development you can install with:
11+
If you want to install from source and be up-to-date with the latest development you can install with:
1212

1313
.. code-block:: python
1414
@@ -30,14 +30,14 @@ The following are the Python requirements, which are installed when running the
3030
- h5py
3131
- `MEAutility <https://github.com/alejoe91/MEAutility>`_
3232

33-
Additional requirements for template generatiom
33+
Additional requirements for template generation
3434
-----------------------------------------------
3535

3636
The template generation phase requires NEURON and LFPy to be installed. These are not installed by default, but they can be easily installed with pip.
3737

3838
.. code-block:: bash
3939
40-
pip install MEArec[templatess]
40+
pip install MEArec[templates]
4141
4242
4343
Installing NEURON

docs/overview.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Overview
22
=========
33

4-
MEArec is a Python package designed to make simulation of extracellular recordings easy, fast, and highly controllable.
4+
MEArec is a Python package designed to make the simulation of extracellular recordings easy, fast, and highly controllable.
55

66
The core idea of MEArec is explained in this figure.
77

88
.. image:: images/overview.png
99

10-
The biophysical simulations of extracellular action potentials (EAP or templates) allows to generate a large number of
10+
The biophysical simulations of extracellular action potentials (EAPs or templates) allow for the generation of a large number of
1111
templates from different cell models placed at random locations and with varying rotations around the probe.
1212
Further details and parameters of the template generation are explained :ref:`gen-templates`.
1313

0 commit comments

Comments
 (0)