Utility functions

Blox are the basic components of neural circuits. For documentation of the kinds of blox available, please see the Blox documentation page. Internally these are represented as ModelingToolkit systems.

The following functions are used to query blox.

Missing docstring.

Missing docstring for get_neurons. Check Documenter's build log for details.

NeurobloxBase.get_exci_neuronsFunction
get_exci_neurons(n::Union{GraphSystem, AbstractBlox})

Returns all excitatory neurons within a blox or graph.

  • If n <: Union{GraphSystem, AbstractComposite}, returns all excitatory neurons within the graph or composite blox.
  • If n::AbstractExciNeuron, returns a single-element vector [n].
NeurobloxBase.get_inh_neuronsFunction
get_inh_neurons(n::Union{GraphSystem, AbstractBlox})

Returns all inhibitory neurons within a blox or graph.

  • If n <: Union{GraphSystem, AbstractComposite}, returns all excitatory neurons within the graph or composite blox.
  • If n::AbstractExciNeuron, returns a single-element vector [n].
NeurobloxBase.namespaced_nameofFunction
namespaced_nameof(blox)

Returns the name of the blox, prefaced by its entire inner namespace (all levels of the namespace EXCEPT for the highest level). Namespaces represent the parent composite blox or graph that blox belongs to. E.g. the name cort1.wta2.neuron4 comes from a neuron neuron4 which belongs to wta2 (possibly a WinnerTakeAll blox) which in turn is part of cort1 (possibly a Cortical blox).

See also nameof and full_namespaced_nameof.

NeurobloxBase.full_namespaced_nameofFunction
full_namespaced_nameof(blox)

Return the name of the blox, prefaced by its entire inner namespace (all levels of the namespace INCLUDING for the highest level). Namespaces represent the parent composite blox or graph that blox belongs to. E.g. the name mdl.cort1.wta2.neuron4 comes from a neuron neuron4 which belongs to wta2 (possibly a WinnerTakeAll blox), which in turn is part of cort1 (possibly a Cortical blox), which finally is part of a circuit mdl.

See also nameof and namespaced_nameof.

Additionally there are several helpers for extracting useful information from solutions to simulations, such as the timing of spikes and the firing rate. Several of these are called by the plotting functions.

NeurobloxBase.detect_spikesFunction
detect_spikes(blox::AbstractNeuron, sol::AbstractSolution;
              threshold=nothing,
              tolerance=1e-3,
              ts=nothing,
              scheduler=:serial)

Find the spike timepoints of blox according to simulation solution sol. Return a SparseVector that is equal to 1 at the timepoints of each spike.

Keyword arguments: - threshold : [mV] Spiking threshold. Note that neurons like NeurobloxPharma.HHNeuronExci and NeurobloxPharma.HHNeuronInhib do not inherently contain a threshold and so require this threshold argument to be passed in order to determine spiking events. - tolerance : [mV] The tolerance around the threshold value in which a maximum counts as a spike. - ts : [ms] Timepoints in simulation solution sol where spikes are detected. It can be a range, a vector or an individual timepoint. If no values are passed (and ts=nothing) then the entire range of the solution sol is used.

NeurobloxBase.firing_rateFunction
firing_rate(blox::Union{AbstractComposite, Vector{AbstractNeuron}}, sol::AbstractSolution;
            transient=0, win_size=last(sol.t) - transient,
            overlap=0, threshold=nothing,
            scheduler=:serial, kwargs...)

Calculates the firing rate of blox. If blox is a composite blox or a vector containing multiple elements, then the average firing rate across all neurons in blox is returned.

Keyword arguments:

  • win_size : [ms] Sliding window size.
  • overlap : in range [0,1]. Overlap between two consecutive sliding windows.
  • transient : [ms] Transient period in the beginning of the timeseries that is ignored during firing rate calculation.
  • threshold : [mV] Spiking threshold.

See also frplot.

NeurobloxBase.inter_spike_intervalsFunction
inter_spike_intervals(blox::AbstractNeuron, sol; threshold, ts)

Return the time intervals between subsequent spikes in the solution of a single neuron.

inter_spike_intervals(blox::AbstractNeuron, sol; threshold, ts)

Return the time intervals between subsequent spikes in the solution of a Blox. Outputs a matrix whose rows are the interspike intervals for a single neuron.

NeurobloxBase.flat_inter_spike_intervalsFunction
flat_inter_spike_intervals(blox::AbstractNeuron, sol; threshold, ts)

Return the time intervals between subsequent spikes in the solution of a Blox. Concatenates the lists of interspike intervals of all vectors into a single vector.

NeurobloxBase.powerspectrumFunction
powerspectrum(cb::Union{AbstractComposite, Vector{AbstractNeuron}}, sol::AbstractSolution; sampling_rate=nothing, method=periodogram, window=nothing)

Calculate the power spectrum of the voltage timeseries for all neurons and/or neural masses contained in blox.

See powerspectrumplot for more information on the keyword arguments.

NeurobloxBase.voltage_timeseriesFunction
voltage_timeseries(cb::Union{AbstractComposite, Vector{Union{AbstractNeuron, AbstractNeuralMass}}, sol::AbstractSolution; ts)

Return the voltage timeseries of all neurons and/or neural masses contained in blox. The output is a Matrix where each row is a separate neuron or neural mass and each column is a timepoint.

Keyword arguments:

  • ts : [ms] Timepoints at which the voltage values are evaluated in simulation solution sol. It can be a range, a vector or an individual timepoint. If no values are passed (and ts=nothing) then the entire range of the solution sol is used.
NeurobloxBase.meanfield_timeseriesFunction
meanfield_timeseries(cb::Union{AbstractComposite, Vector{AbstractNeuron}, sol, state; ts)

Return the average timeseries of state variable state over all neurons contained in cb.

Keyword arguments:

  • ts : [ms] Timepoints at which the timeseries is evaluated in simulation solution sol. It can be a range, a vector or an individual timepoint. If no values are passed (and ts=nothing) then the entire range of the solution sol is used.
NeurobloxBase.state_timeseriesFunction
state_timeseries(blox::AbstractBlox, sol::SciMLBase.AbstractSolution, state::String; ts = nothing)

Return the timeseries of the state variable state from blox.

Keyword arguments:

  • ts : [ms] Timepoints at which the timeseries is evaluated in simulation solution sol. It can be a range, a vector or an individual timepoint. If no values are passed (and ts=nothing) then the entire range of the solution sol is used.
state_timeseries(cb::Union{AbstractComposite, Vector{<:AbstractBlox}}, 
                 sol::SciMLBase.AbstractSolution, state::String; ts = nothing)

Return the timeseries of the state variable state for each blox contained in cb. The resulting collection of timeseries are stacked in a Matrix where each row is a separate blox in cb.

Keyword arguments:

  • ts : [ms] Timepoints at which the timeseries is evaluated in simulation solution sol. It can be a range, a vector or an individual timepoint. If no values are passed (and ts=nothing) then the entire range of the solution sol is used.