Skip to content

Commit eada635

Browse files
authored
Docs: update morphology file format in docs (#517)
2 parents 54bd0d0 + 8212f82 commit eada635

4 files changed

Lines changed: 77 additions & 68 deletions

File tree

data_base/IO/LoaderDumper/dask_to_categorized_msgpack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
r"""Save and load dask dataframes to msgpack with categorical columns.
15+
"""Save and load dask dataframes to msgpack with categorical columns.
1616
1717
This dumper is designed for dataframes with the following properties:
1818
1919
- The index is str
2020
- The columns have a lot of repetitive values, so they can be grouped.
2121
22-
If the number of partitions is very large (:math:`\textgreater 10000`), it will repartition the
22+
If the number of partitions is very large (:math:`\\gt 10000`), it will repartition the
2323
dataframe to 5000 partitions.
2424
Loading such a dataframe is normaly possible within 1 second.
2525
26-
Before saving, all str-columns will be converted to ``pd.Categorical``s
27-
In each respective partition, if the part of unique values in the respective column is :math:`\leq 20%`. The original datatype
26+
Before saving, all str-columns will be converted to ``pd.Categorical``
27+
In each respective partition, if the part of unique values in the respective column is :math:`\\leq 20\\%`. The original datatype
2828
will be restored if the dataframe is loaded.
2929
This therefore only serves as optimization to increase loading speed and reduce network traffic for suitable dataframes.
3030
Suitable dataframes are for example the :ref:`syn_activation_format` dataframe.

docs/file_formats.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ File & data formats
2121
.syn
2222
****
2323
ISF custom file format to store synapse locations onto a morphology.
24-
Only valid with an associated morphology :ref:`hoc_file_format` file.
24+
Only valid with an associated morphology :ref:`morphology_file_format` file.
2525

2626
For each synapse, it provides the synapse type and location onto the morphology.
2727
Each row index corresponds to its synapse ID, providing a link to a corresponding :ref:`con_file_format` file.
@@ -50,9 +50,9 @@ Example::
5050
.con
5151
****
5252
ISF custom file format to store connectivity data.
53-
To be used in conjunction with an associated :ref:`syn_file_format` file and morphology :ref:`hoc_file_format` file.
53+
To be used in conjunction with an associated :ref:`syn_file_format` file and morphology :ref:`morphology_file_format` file.
5454
It numbers each synapse, and links it to its associated presynaptic cell type and ID.
55-
While a :ref:`syn_file_format` file and :ref:`hoc_file_format` file provide the anatomical realization of a morphology embedding into a network,
55+
While a :ref:`syn_file_format` file and :ref:`morphology_file_format` file provide the anatomical realization of a morphology embedding into a network,
5656
the addition of a :ref:`con_file_format` file makes possible to construct a functional realization, as it allows linking the synapses to
5757
presynaptic cells of a dense connectome model, which in turn allows to assign cell type specific activation patterns
5858
to each synapse. ISF's workflow is designed to create these files in tandem, so they always co-exist.
@@ -91,7 +91,7 @@ Cell parameters
9191
===============
9292

9393
:ref:`param_file_format` file to store biophysical parameters of a cell.
94-
Includes a reference to a :ref:`hoc_file_format` morphology file,
94+
Includes a reference to a :ref:`morphology_file_format` morphology file,
9595
biophysical properties of the cell per morphological structure (e.g. soma, dendrite, axon initial segment ...),
9696
and basic simulation parameters. Morphology structure labels should match those inferred from the morphology file.
9797

@@ -181,7 +181,7 @@ Network parameters
181181
==================
182182
The :ref:`param_file_format` format is used to store network parameters,
183183
describing the presynaptic cells and their synaptic activations.
184-
Only valid with an associated :ref:`hoc_file_format` morphology file, :ref:`syn_file_format` file, and :ref:`con_file_format` file.
184+
Only valid with an associated :ref:`morphology_file_format` morphology file, :ref:`syn_file_format` file, and :ref:`con_file_format` file.
185185

186186
For each presynaptic cell type in the network, this following information is provided:
187187

simrun/modular_reduced_model_inference/strategy.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -440,26 +440,26 @@ def visualize(self, optimizer_output, normalize=True):
440440

441441

442442
class RaisedCosineBasis(object):
443-
r"""Set of raised cosine basis functions to use as a kernel for weighing synaptic activation patterns.
443+
"""Set of raised cosine basis functions to use as a kernel for weighing synaptic activation patterns.
444444
445445
A raised cosine is defined as:
446446
447447
.. math::
448448
449-
f_i(x) = \\frac{1}{2} cos(a \cdot log(\\tau + c) - \phi_i) + \\frac{1}{2}
449+
f_i(x) = \\frac{1}{2} cos(a \\cdot log(\\tau + c) - \\phi_i) + \\frac{1}{2}
450450
451451
where :math:`\\tau` is the input dimension (space or time e.g.), :math:`a` is the steepness, :math:`c` is the offset, and :math:`\phi` is the phase.
452-
These basis functions can be superimposed using learnable weights :math:`x_i` to form a single filter :math:`\mathbf{w}(\\tau)` over the domain :math:`\\tau`:
452+
These basis functions can be superimposed using learnable weights :math:`x_i` to form a single filter :math:`\\mathbf{w}(\\tau)` over the domain :math:`\\tau`:
453453
454454
.. math::
455455
456-
\mathbf{w}(\\tau) = \sum_{i} x_i \cdot f_i(\\tau)
456+
\mathbf{w}(\\tau) = \\sum_{i} x_i \\cdot f_i(\\tau)
457457
458458
And this filter can then be used to weigh the input data :math:`\mathbf{D}`:
459459
460460
.. math::
461461
462-
WI(t) = \int_{t-width}^{t} \mathbf{w}(\\tau) \cdot \mathbf{D}(\\tau)
462+
WI(t) = \\int_{t-width}^{t} \\mathbf{w}(\\tau) \\cdot \\mathbf{D}(\\tau)
463463
464464
Note:
465465
The notation here heavily implies that the cosine functions are defined over the time domain.
@@ -503,10 +503,10 @@ def __init__(
503503

504504

505505
def compute(self, width=80):
506-
r"""Compute the vector of raised cosine basis functions :math:`\mathbf{f}`.
506+
"""Compute the vector of raised cosine basis functions :math:`\\mathbf{f}`.
507507
508-
Each element :math:`f_i` in the vector :math:`\mathbf{f}` is a raised cosine basis function
509-
with a different :math:`\phi_i`. The domain of each :math:`f_i` is :math:`[0, width]`.
508+
Each element :math:`f_i` in the vector :math:`\\mathbf{f}` is a raised cosine basis function
509+
with a different :math:`\\phi_i`. The domain of each :math:`f_i` is :math:`[0, width]`.
510510
511511
Args:
512512
width (int): The width of the basis functions.
@@ -531,25 +531,25 @@ def compute(self, width=80):
531531

532532

533533
def get(self):
534-
r"""Get the basis functions :math:`\mathbf{f}`.
534+
"""Get the basis functions :math:`\\mathbf{f}`.
535535
536536
Returns:
537537
list: The list of basis functions."""
538538
return self.basis
539539

540540

541541
def get_superposition(self, x):
542-
r"""Get the weighed sum :math:`\mathbf{w}(\\tau)` of the basis functions :math:`f`.
542+
"""Get the weighed sum :math:`\\mathbf{w}(\\tau)` of the basis functions :math:`f`.
543543
544544
The superposition of all basis functions, weighed by the input weights,
545545
is a single filter of length :param:`width` that can be used to weigh the input data: synapse activations.
546546
547547
.. math::
548548
549-
\mathbf{w}(\\tau) = \sum_{i} x_i\ f_i(\\tau) = \mathbf{x} \cdot \mathbf{f}(\\tau)
549+
\\mathbf{w}(\\tau) = \\sum_{i} x_i\\ f_i(\\tau) = \\mathbf{x} \\cdot \\mathbf{f}(\\tau)
550550
551551
Args:
552-
x (array): The (learnable) input weights :math:`\mathbf{x}`
552+
x (array): The (learnable) input weights :math:`\\mathbf{x}`
553553
554554
Returns:
555555
array: The weighed sum of the basis functions.
@@ -558,7 +558,7 @@ def get_superposition(self, x):
558558

559559

560560
def visualize(self, ax=None, plot_kwargs=None):
561-
r"""Visualize the basis functions :math:`\mathbf{f}`.
561+
"""Visualize the basis functions :math:`\\mathbf{f}`.
562562
563563
Args:
564564
ax (plt.axis): The axis to plot on. Default is ``None``.
@@ -576,7 +576,7 @@ def visualize(self, ax=None, plot_kwargs=None):
576576

577577

578578
def visualize_w(self, x, ax=None, plot_kwargs=None):
579-
r"""Visualize the superposition :math:`\mathbf{w}(\tau)` of the basis functions :math:`\mathbf{f}`.
579+
"""Visualize the superposition :math:`\\mathbf{w}(\\tau)` of the basis functions :math:`\\mathbf{f}`.
580580
581581
Args:
582582
x (array): The (learnable) input weights for the basis functions.
@@ -637,7 +637,7 @@ def _setup(self):
637637
self._get_score = partial(self._get_score_static, self.RaisedCosineBasis_postspike, self.ISI)
638638

639639
def _get_x0(self):
640-
r"""Get an initial guess for the learnable weights of the basis functions :math:`\mathbf{x}`.
640+
"""Get an initial guess for the learnable weights of the basis functions :math:`\\mathbf{x}`.
641641
642642
These weights are optimized by the solver.
643643
@@ -679,7 +679,7 @@ def normalize_x(self, x):
679679

680680

681681
class Strategy_spatiotemporalRaisedCosine(_Strategy):
682-
r'''Spatiotemporal raised cosine strategy.
682+
'''Spatiotemporal raised cosine strategy.
683683
684684
Uses the :class:``RaisedCosineBasis`` to create a set of basis functions.
685685
@@ -691,27 +691,27 @@ class Strategy_spatiotemporalRaisedCosine(_Strategy):
691691
- ``ISI``: The inter-spike intervals.
692692
693693
Attributes:
694-
RaisedCosineBasis_spatial (RaisedCosineBasis): The spatial basis functions :math:`\mathbf{g}(z)`.
695-
RaisedCosineBasis_temporal (RaisedCosineBasis): The temporal basis functions :math:`\mathbf{f}(t)`.
694+
RaisedCosineBasis_spatial (RaisedCosineBasis): The spatial basis functions :math:`\\mathbf{g}(z)`.
695+
RaisedCosineBasis_temporal (RaisedCosineBasis): The temporal basis functions :math:`\\mathbf{f}(t)`.
696696
base_vectors_arrays_dict (dict):
697-
The basis vectors for each group. basis vectors are of shape (:math:`N_{trials}`, :math:`N_\tau`, :math:`N_z`)
697+
The basis vectors for each group. basis vectors are of shape (:math:`N_{trials}`, :math:`N_\\tau`, :math:`N_z`)
698698
These basis vectors are used for the optimizer, and are already multiplied with the data.
699699
Do not confuse them with the basis vectors of :param:`RaisedCosineBasis_spatial` and :param:`RaisedCosineBasis_temporal`,
700700
as the latter are not multiplied with the synapse activaiton data.
701701
groups (list): The list of groups. Usually simply ``['EXC', 'INH']``.
702702
len_z (int): The length of the spatial domain i.e. the amount of spatial basis vectors.
703703
len_t (int): The length of the temporal domain i.e. the amount of temporal basis vectors.
704704
len_trials (int): The number of trials.
705-
convert_x (callable): The conversion function to convert the 1D learnable weight vector :math:`\mathbf{x}` into a structured dictionary.
705+
convert_x (callable): The conversion function to convert the 1D learnable weight vector :math:`\\mathbf{x}` into a structured dictionary.
706706
_get_score (callable): The cost function to provide to the optimizer.
707707
'''
708708

709709
def __init__(self, name, RaisedCosineBasis_spatial, RaisedCosineBasis_temporal):
710-
r"""
710+
"""
711711
Args:
712712
name (str): The name of the strategy.
713-
RaisedCosineBasis_spatial (RaisedCosineBasis): The spatial basis functions :math:`\mathbf{g}(z)`.
714-
RaisedCosineBasis_temporal (RaisedCosineBasis): The temporal basis :math:`\mathbf{f}(t)`.
713+
RaisedCosineBasis_spatial (RaisedCosineBasis): The spatial basis functions :math:`\\mathbf{g}(z)`.
714+
RaisedCosineBasis_temporal (RaisedCosineBasis): The temporal basis :math:`\\mathbf{f}(t)`.
715715
"""
716716
super(Strategy_spatiotemporalRaisedCosine, self).__init__(name)
717717
self.RaisedCosineBasis_spatial = RaisedCosineBasis_spatial
@@ -728,33 +728,33 @@ def _setup(self):
728728
self._get_score = partial(self._get_score_static, self.convert_x, self.base_vectors_arrays_dict)
729729

730730
def compute_basis(self):
731-
r'''Compute the basis vectors for the dataset.
731+
'''Compute the basis vectors for the dataset.
732732
733-
These basis vectors are defined as :math:`\mathbf{f}(t) \cdot \mathbf{g}(z) \cdot \mathbf{D}`.
733+
These basis vectors are defined as :math:`\\mathbf{f}(t) \\cdot \\mathbf{g}(z) \\cdot \\mathbf{D}`.
734734
When these basis vectors are weighed, they form the argument of the integral over the domain.
735735
Once integrated over the domain, they yield the weighted net input.
736736
737737
.. math::
738738
739-
WNI(t) = \int_{t-width}^{t} \int_z \mathbf{w}_{\\tau}(\\tau) \cdot \mathbf{w}_{z}(z) \cdot \mathbf{D} = \int_{t-width}^{t} \int_z \mathbf{x} \cdot \mathbf{y} \cdot \mathbf{f}(t) \cdot \mathbf{g}(z) \cdot \mathbf{D}
739+
WNI(t) = \\int_{t-width}^{t} \\int_z \\mathbf{w}_{\\tau}(\\tau) \\cdot \\mathbf{w}_{z}(z) \\cdot \\mathbf{D} = \\int_{t-width}^{t} \\int_z \\mathbf{x} \\cdot \\mathbf{y} \\cdot \\mathbf{f}(t) \\cdot \\mathbf{g}(z) \\cdot \\mathbf{D}
740740
741741
Attention:
742742
These are not the same basis vectors as in :class:`RaisedCosineBasis`.
743-
These basis vectors are already multiplied with the data :math:`\mathbf{D}`.
743+
These basis vectors are already multiplied with the data :math:`\\mathbf{D}`.
744744
Since dot product is commutative, the order of this multiplication does not matter for calculating
745745
the weighted net input, but these intermediate basis vectors are different.
746746
747747
Returns:
748-
dict: A dictionary of basis vectors for each group. basis vectors are of shape :math:`(n_trials, dim(\mathbf{f}(\\tau)), dim(\mathbf{g}(z)))`.
748+
dict: A dictionary of basis vectors for each group. basis vectors are of shape :math:`(n\\_trials, dim(\\mathbf{f}(\\tau)), dim(\\mathbf{g}(z)))`.
749749
'''
750750

751751
def _compute_base_vector_array(spatiotemp_SA):
752-
r"""
752+
"""
753753
Args:
754-
spatiotemp_SA (array): The spatiotemporal synaptic activation patterns of shape :math:`(n_trials, dim(\mathbf{f}(\\tau)), dim(\mathbf{g}(z)))`.
754+
spatiotemp_SA (array): The spatiotemporal synaptic activation patterns of shape :math:`(n_trials, dim(\\mathbf{f}(\\tau)), dim(\\mathbf{g}(z)))`.
755755
756756
Returns:
757-
array: The basis vector array of shape :math:`(n_trials, dim(\mathbf{f}(\\tau)), dim(\mathbf{g}(z)))`.
757+
array: The basis vector array of shape :math:`(n\\_trials, dim(\\mathbf{f}(\\tau)), dim(\\mathbf{g}(z)))`.
758758
"""
759759
_, time_domain, space_domain = spatiotemp_SA.shape
760760
self.RaisedCosineBasis_spatial.compute(space_domain)
@@ -776,7 +776,7 @@ def _compute_base_vector_array(spatiotemp_SA):
776776
self.base_vectors_arrays_dict = base_vectors_arrays_dict
777777

778778
def _get_x0(self):
779-
r"""Get an initial guess for the learnable weights :math:`\mathbf{x}` and :math:`\mathbf{y}` of the basis functions :math:`\mathbf{f}(\tau)` and :math:`\mathbf{g}(z)`.
779+
"""Get an initial guess for the learnable weights :math:`\\mathbf{x}` and :math:`\\mathbf{y}` of the basis functions :math:`\\mathbf{f}(\\tau)` and :math:`\\mathbf{g}(z)`.
780780
781781
Returns:
782782
np.array: An array of random values in the range :math:`[-1, 1)`, with the same length as the basis parameters.
@@ -785,7 +785,7 @@ def _get_x0(self):
785785

786786
@staticmethod
787787
def _convert_x_static(groups, len_z, x):
788-
r"""Convert the input array :math:`\mathbf{x}` into a dictionary of basis vectors.
788+
"""Convert the input array :math:`\\mathbf{x}` into a dictionary of basis vectors.
789789
790790
Useful for passing the learnable weights to the optimizer as a one-dimensional array,
791791
but keeping track of the basis vectors for each group and dimension.
@@ -827,21 +827,21 @@ def _convert_x_static(groups, len_z, x):
827827

828828
@staticmethod
829829
def _get_score_static(convert_x, base_vectors_arrays_dict, x):
830-
r"""Calculate the weighted net input :math:`WNI(t)` for the given weights :math:`\mathbf{x}`.
830+
"""Calculate the weighted net input :math:`WNI(t)` for the given weights :math:`\\mathbf{x}`.
831831
832832
This is the method that calculates the cost function for the optimizer.
833833
It is assigned to :func:`~simrun.modular_reduced_model_inference.Strategy_spatiotemporalRaisedCosine._get_score` during
834834
the setup of the strategy.
835835
836-
This method left-multiplies the basis vectors :math:`\mathbf{f}(\tau) \cdot \mathbf{g}(z) \cdot \mathbf{D}`
837-
with the learnable weights :math:`\mathbf{x}` and :math:`\mathbf{y}`.
836+
This method left-multiplies the basis vectors :math:`\\mathbf{f}(\\tau) \\cdot \\mathbf{g}(z) \\cdot \\mathbf{D}`
837+
with the learnable weights :math:`\\mathbf{x}` and :math:`\\mathbf{y}`.
838838
It then integrates the results for each group to get the weighted net input :math:`WNI(t)`.
839839
840840
Args:
841841
convert_x (callable): The conversion function from the learnable weights to the basis vectors.
842842
base_vectors_arrays_dict (dict): The dictionary of basis vectors for each group.
843843
x (array):
844-
The learnable weights :math:`\mathbf{x}` and :math:`\mathbf{y}` as a single array.
844+
The learnable weights :math:`\\mathbf{x}` and :math:`\\mathbf{y}` as a single array.
845845
These are converted to spatial and temporal weights per group with :param:`convert_x`.
846846
847847
Attention:
@@ -862,18 +862,18 @@ def _get_score_static(convert_x, base_vectors_arrays_dict, x):
862862
return wni # shape: (n_trials,)
863863

864864
def normalize(self, x, flipkey=None):
865-
r'''Normalize the kernel basis functions such that sum of all absolute values of all kernels is 1.
865+
'''Normalize the kernel basis functions such that sum of all absolute values of all kernels is 1.
866866
867867
Attention:
868868
These are the same basis functions as in :class:`RaisedCosineBasis`.
869869
These are thus not multiplied with the synapse activation data, as is the case with :func:`compute_basis`
870870
871871
Args:
872-
x (array): The learnable weights :math:`\mathbf{x}` and :math:`\mathbf{y}` as a 1D array.
872+
x (array): The learnable weights :math:`\\mathbf{x}` and :math:`\\mathbf{y}` as a 1D array.
873873
These are converted to spatial and temporal weights per group with :param:`convert_x`.
874874
875875
Returns:
876-
array: The normalized learnable weights :math:`\mathbf{x}`.
876+
array: The normalized learnable weights :math:`\\mathbf{x}`.
877877
'''
878878
x = self.convert_x(x)
879879
#temporal

0 commit comments

Comments
 (0)