analysis Package

This sub-package contains modules that are related to analysis.

Modules

Architecture

The mozaik.analysis.analysis.Analysis interface assumes that the input to the analysis is retrieved from mozaik.storage.datastore, in the form of recorded data or analysis data structures (see mozaik.analysis.data_structures) produced by other analysis algorithms that were run previously. The analysis itself should be able to filter out from the datastore the recordings/data_structures that it can handle and should be as encompassing and general as possible. This way it will be possible to significantly ‘configure’ the analysis process by merely filtering the data given to the Analysis classes via the mozaik.storage.queries mechanisms. The analysis function is responsible for packaging its results into one or a set of the data structures defined in mozaik.analysis.data_structures and send them to the datastorage. Thus when creating new analysis one should always check which data structures are already defined, and define a new one only in case it is not possible to map the new results data structure on any of the existing ones.

Analysis data structures

The goal of the AnalysisDataStructure class is to offer a common interface/format for data generated by analysis, so they can be consumed by other analysis or visualization code in a standard way. For example many analyses can generate 2D tuning curves of several kinds but they all share a common data structure and can be plotted in a common way.

An analysis class can generate several AnalysisDataStructures (ADSs) and one ADS can be generated by several Analysis classes.

One important aspect of the ADS design is the notion of parameters as opposed to inputs. Each ADS should define a number of Parameters (see the documentation on Parameters). The importance of parameters is that they will offer a way to identify the ADS in the data store (see param_filter_query in queries). Furthermore the constructor of the AnalysisDataStructure can accept inputs, which are standard variables that should correspond to the data that is actually stored in the ADS.

The five parameters that are common to each ADS and are defined in the top mozaik.analysis.data_structures.AnalysisDataStructure class are:

identifier
An important parameter of each AnalysisDataStructure is an identifier which is used to identify data structures of common type in storage facilities. Currently different datastructures with a common interface should share the identifiers but it is not clear yet whether this is needed. If it turns out such sharing is not necessary it might be abolished and there will be one-to-one mapping between AnalysisDataStructure classes and identifiers.
analysis_algorithm
The identity (name) of the analysis class that produced this analysis data structure.
sheet_name
The sheet for which this results were computed. None if they do not belong to a specific sheet.
neuron
Neuron id to which the data structure belongs. None if it is not neuron specific.
stimulus_id
Stimulus id (as string) to which the data structure belongs. None if it is not stimulus specific.
tags

In complicated workflows it might become difficult to design a filter to extract the right set of recordings or analysis data structures for a given analysis or visualization. We do not want users to define multiple AnalysisDataStructures that hold the same kind of data only to be able to tell them apart.

Therefore, we also allow all analysis data structures to contain a list of tags (which are strings) that one can add during their creation (or later) and use them to later for their identification in a DataStore. Queries are written that support filtering of ADSs based on tags.

However, in general, we encourage users to use filter methods rather than tags to perform their plotting/analysis whenever possible!

For more details see the mozaik.analysis.data_structures and mozaik.analysis.analysis module and specifically the two most important API classes: mozaik.analysis.data_structures.AnalysisDataStructure and mozaik.analysis.analysis.Analysis

analysis Module

This module contains the Mozaik analysis interface and implementation of various analysis algorithms

For more documentation refer to `mozaik.analysis`_

class mozaik.analysis.analysis.Analysis(datastore, parameters, tags=None)

Bases: mozaik.core.ParametrizedObject

The analysis interface.

Each mozaik analysis is a subclass of this class and is required to implementat the perform_analysis function which should contain the analysis code. This function should retrieve data from the DataStoreView that is supplied in the datastore parameter. Further, it should include tags as the tags for all AnalysisDataStructure objects that it creates. (See the description of the analysis.AnalysisDataStructure.tags attribute.

Parameters :

datastore : DataStoreView

The datastore from which to pull data.

parameters : ParameterSet

The required parameter set.

tags : list(str), optional

Tags to attach to the AnalysisDataStructures generated by the analysis.

analyse()

This is the function calls to perform the analysis.

perform_analysis()

This is an abstract function that each analysis class has to implement. It contains the code performing the analysis.

class mozaik.analysis.analysis.TrialAveragedFiringRate(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

This analysis takes each recording in DSV that has been done in response to stimulus type ‘stimulus_type’ and calculates the average (over trials) number of spikes. For each set of equal recordings (except trial) it creates one PerNeuronValue AnalysisDataStructure instance containing the trial averaged firing rate per each recorded neuron.

perform_analysis()
class mozaik.analysis.analysis.PeriodicTuningCurvePreferenceAndSelectivity_VectorAverage(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Calculates a preference and selectvitiy tuning of a periodic variable via vector average method.

This analysis takes from the DSV all PerNeuronValues. All PerNeuronValues have to belong to stimuli of the same type and contain the same type of values (i.e. have the same value_name).

For each combination of parameters of the stimuli other than parameter_name PeriodicTuningCurvePreferenceAndSelectivity_VectorAverage creates a PerNeuronValue which corresponsd to the vector average through the periodic domain of parameter_name.

Other Parameters:
 

parameter_name : str

The name of the parameter through which to calculate the VectorAverage

required_parameters = {'parameter_name': <type 'str'>}
perform_analysis()
class mozaik.analysis.analysis.GSTA(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Computes conductance spike triggered average.

Other Parameters:
 

length : float (ms)

how long before and after spike to compute the GSTA it will be rounded down to fit the sampling frequency

neurons : list

the list of neuron ids for which to compute the GSTA

Notes

GSTA does not assume that spikes are aligned with the conductance sampling rate and will pick the bin in which the given spike falls (within the conductance sampling rate binning) as the center of the conductance vector that is included in the STA.

required_parameters = {'length': <type 'float'>, 'neurons': <type 'list'>}
perform_analysis()
class mozaik.analysis.analysis.Precision(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Computes the precision as the autocorrelation between the PSTH of different trials.

Takes all the responses in the datastore, and for each recording group that is identical except the trial number it will compute the autocorrelation between the PSTH of different trials. For each such group it will create add a AnalogSignalList instance into the datastore containing the calculated autocorrelation vector for each neuron in required_parameters.neurons.

Other Parameters:
 

bin_length : float (ms)

the size of bin to construct the PSTH from

neurons: list :

the list of neuron ids for which to compute the autocorrelation

required_parameters = {'bin_length': <type 'float'>, 'neurons': <type 'list'>}
perform_analysis()
class mozaik.analysis.analysis.TrialVariability(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

For each stimulus and neuron it calculates the trial-to-trial variability of Vm or conductance (depending on parameters). It creates a AnalogSignalList list for each recording (except trials).

Other Parameters:
 

vm : bool

calculate variability for Vm?

cond_exc : bool

calculate variability for excitatory conductance?

cond_inh : bool

calculate variability for inhibitory conductance?

required_parameters = {'cond_exc': <type 'bool'>, 'vm': <type 'bool'>, 'cond_inh': <type 'bool'>}
perform_analysis()
class mozaik.analysis.analysis.GaussianTuningCurveFit(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Fits each tuning curve with a gaussian.

It takes a dsv containing some PerNeuronValues. All PerNeuronValues have to belong to stimuli of the same type and contain the same type of values (i.e. have the same value_name).

For each combination of parameters of the stimuli other than parameter_name GaussianTuningCurveFit fits a gaussian tuning curve to the values in the PerNeuronValues that span the parameter values of the parameter_name stimulus parameter.

It stores the parameters of the fitted Gaussian in a PerNeuronValue - for each combination of parameters of the stimulus associated with the supplied PerNeuronValue with the exception of the stimulus parameter parameter_name. For each combination it stored 5 PerNeuronValue data structures, containing the calculated selectivity, preference, half-width at half-height (HWHH), maximum (‘scale’ of the gaussian) and baseline (the constant offset).

Other Parameters:
 

parameter_name : str

The stimulus parameter name through which to fit the tuning curve.

required_parameters = {'parameter_name': <type 'str'>}
perform_analysis()
class mozaik.analysis.analysis.PSTH(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

For each recording in the datastore view it creates an AnalogSignalList containing the PSTH of the neuron using the bin length required_parameters.bin_length.

Other Parameters:
 

bin_length : float

The bin length of the PSTH

required_parameters = {'bin_length': <type 'float'>}
perform_analysis()
class mozaik.analysis.analysis.TemporalBinAverage(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

For each recording or AnalogSingalList ADS with x_axis_name`=’time’ in the datastore `TemporalBinAverage creates a new AnalogSingalList, containing a down-sampled version of the signal (vm, conductances or the AnalogSingalList), such that it will bin the time axis with bin length required_parameters.bin_length and make average for each bin.

Other Parameters:
 

bin_length : float

The bin length of the PSTH

vm : bool

calculate TemporalBinAverage for Vm?

cond_exc : bool

calculate TemporalBinAverage for excitatory conductance?

cond_inh : bool

calculate TemporalBinAverage for inhibitory conductance?

required_parameters = {'bin_length': <type 'float'>, 'cond_exc': <type 'bool'>, 'vm': <type 'bool'>, 'cond_inh': <type 'bool'>}
perform_analysis()
class mozaik.analysis.analysis.ActionPotentialRemoval(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

For each recording in the datastore view it creates an AnalogSignalList containing the VMs with the spikes removed and sends it to the datastore.

Other Parameters:
 

window_length : float (ms)

The length of the window starting at a spike time in which the Vm is replaced with linear interpolation.

Notes

Vm, in the window starting at each spike time, and lasting the window_length is removed and replaced by linear interpolation between the values of Vm at the extrems of the cutout window.

required_parameters = {'window_length': <type 'float'>}
perform_analysis()
class mozaik.analysis.analysis.Irregularity(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Irregularity as defined in: Kumar, A., Schrader, S., Aertsen, A., & Rotter, S. (2008). The high-conductance state of cortical networks. Neural computation, 20(1), 1-43. It is the square of inter spike interval coefficient of variation.

It creates on PerNeuronValue ADS per each recording in the DSV.

Notes

It is not possible to compute CV for neurons with no spikes. Therefore we exclude such neurons from the analysis. This means that the resulting PerNeuronValue ADS might not contain all ids of neurons as the source recording.

perform_analysis()
class mozaik.analysis.analysis.NeuronToNeuronAnalogSignalCorrelations(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Calculates the pairwise correlation of AnalogSignal object for each pair of neurons. It creates one PerNeuronPairValue for each AnalogSignalList ADS present in the DSV.

Parameters :

convert_nan_to_zero : bool,

If true nan values in correlation coefficients which can result from non-varying varialbes will be turned to zeros.

required_parameters = {'convert_nan_to_zero': <type 'bool'>}
perform_analysis()
class mozaik.analysis.analysis.PopulationMean(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Calculates the mean value accross population of a quantity. Currently it can process PerNeuronValues and PerNeuronPairValue ADS. This list might be increased.

perform_analysis()

data_structures Module

This module contains the definition of the AnalysisDataStructure API and implementation of some basic analysis data structures.

For more documentation refer to `mozaik.analysis`_

class mozaik.analysis.data_structures.AnalysisDataStructure(tags=[], **params)

Bases: mozaik.tools.mozaik_parametrized.MozaikParametrized

Encapsulates data that a certain Analysis class generates.

The four parameters that are common to all AnalysisDataStructure classes are identified, analysis_algorithm, neuron, sheet_name and stimulus_id.

Mozaik parameters:
 
stimulus_id : SString(constant=False, default=None, period=None, readonly=False, units=None)

The stimulus for which the results were computed. None if they are not related to specific stimulus

identifier : SString(constant=False, default=None, period=None, readonly=False, units=None)

The identifier of the analysis data structure

neuron : SInteger(bounds=None, constant=False, default=None, inclusive_bounds=(True, True), period=None, readonly=False, units=None)

Neuron id to which the datastructure belongs. None if it is not neuron specific

analysis_algorithm : SString(constant=False, default=None, period=None, readonly=False, units=None)

The identifier of the analysis data structure

sheet_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

The sheet for which this results were computed. None if they do not belong to specific sheet

class mozaik.analysis.data_structures.SingleValue(**params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure

Data structure holding single value. This can be per model, if sheet parameter is None, or per sheet if sheet is specified. In principle it can also be per neuron if the neuron parameter is specified, but in most cases you probably want to use PerNeuronValue instead.

Mozaik parameters:
 
value_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

The name of the value.

period : SNumber(bounds=None, constant=False, default=None, inclusive_bounds=(True, True), period=None, readonly=False, units=None)

The period of the value. If value is not periodic period=None

value : SNumber(bounds=None, constant=False, default=None, inclusive_bounds=(True, True), period=None, readonly=False, units=None)

The value.

class mozaik.analysis.data_structures.PerNeuronValue(values, idds, value_units, **params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure

Data structure holding single value per neuron.

Parameters :

values : list

The vector of values one per neuron

value_units : quantities

Quantities unit describing the units of the value

ids : list(int)

The ids of the neurons which are stored, in the same order as in the values

Mozaik parameters:
 
value_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

The name of the value.

period : SNumber(bounds=None, constant=False, default=None, inclusive_bounds=(True, True), period=None, readonly=False, units=None)

The period of the value. If value is not periodic period=None

get_value_by_id(idds)
Parameters :

idd : int or list(int)

The ids for which the return the values.

Returns :

ids : AnalogSignal or list(AnalogSignal)

List (or single) of AnalogSignal objects corresponding to ids in idd.

class mozaik.analysis.data_structures.PerNeuronPairValue(values, idds, value_units, **params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure

Data structure holding values for each pair of neurons.

Parameters :

values : numpy.nd_array

The 2D array holding the values.

value_units : quantities

Quantities unit describing the units of the value

ids : list(int)

The ids of the neurons which are stored, in the same order as in the values (along both axis).

Mozaik parameters:
 
value_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

The name of the value.

period : SNumber(bounds=None, constant=False, default=None, inclusive_bounds=(True, True), period=None, readonly=False, units=None)

The period of the value. If value is not periodic period=None

get_value_by_ids(idds1, idds2)
Parameters :

idd : int or list(int)

The ids for which the return the values.

Returns :

ids : AnalogSignal or list(AnalogSignal)

List (or single) of AnalogSignal objects corresponding to ids in idd.

class mozaik.analysis.data_structures.AnalysisDataStructure1D(y_axis_units, **params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure

Data structure representing 1D data. All data corresponds to the same axis name and units. Explicitly specifies the axis - their name and units. Note that at this stage we do not assume the structure in which the data is stored. Also the class can hold multiple instances of 1D data.

It uses the quantities package to specify units. If at all possible all data stored in numoy arrays should be quantities arrays with matching units!

Parameters :

y_axis_units : quantities

The quantities units of y axis.

Mozaik parameters:
 
y_axis_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

the name of the y axis.

x_axis_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

the name of the x axis.

class mozaik.analysis.data_structures.AnalogSignalList(asl, ids, y_axis_units, **params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure1D

This is a simple list of Neo AnalogSignal objects.

Parameters :

asl : list(AnalogSignal)

The variable containing the list of AnalogSignal objects, in the order corresponding to the order of neurons indexes in the indexes parameter.

ids : list(int)

List of ids of neurons in the original Mozaik sheet to which the AnalogSignals correspond.

get_asl_by_id(idd)
Parameters :

idd : int or list(int)

Returns :

ids : AnalogSignal or list(AnalogSignal)

List (or single) of AnalogSignal objects corresponding to ids in idd.

class mozaik.analysis.data_structures.ConductanceSignalList(e_con, i_con, ids, **params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure1D

This is a simple list of Neurotools AnalogSignal objects representing the conductances.

The object holds two lists, one for excitatory and one for inhibitory conductances.

Parameters :

e_asl : list(AnalogSignal)

The variable containing the list of AnalogSignal objects corresponding to excitatory conductances, in the order corresponding to the order of neurons indexes in the indexes parameter.

i_asl : list(AnalogSignal)

The variable containing the list of AnalogSignal objects corresponding to inhibitory conductances, in the order corresponding to the order of neurons indexes in the indexes parameter.

ids : list(int)

List of ids of neurons in the original Mozaik sheet to which the AnalogSignals correspond.

get_econ_by_id(idd)
Parameters :

idd : int or list(int)

Returns :

ids : AnalogSignal or list(AnalogSignal)

List (or single) of AnalogSignal objects containing excitatory conductanes corresponding to ids in idd.

get_icon_by_id(idd)
Parameters :

idd : int or list(int)

Returns :

ids : AnalogSignal or list(AnalogSignal)

List (or single) of AnalogSignal objects containing inhibitory conductanes corresponding to ids in idd.

class mozaik.analysis.data_structures.Connections(weights, delays, **params)

Bases: mozaik.analysis.data_structures.AnalysisDataStructure

Data structure holding connections.

Parameters :

weights : list

List of tuples (i,j,w) where i is index of pre-synaptic neuron in sheet source_name and j is index of post-synaptic neuron in sheet target_name, and w is the weights.

delays : list

List of tuples (i,j,d) where i is index of pre-synaptic neuron in sheet source_name and j is index of post-synaptic neuron in sheet target_name, and d is the delay.

Mozaik parameters:
 
source_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

The name of the source sheet.

target_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

The name of the target sheet.

proj_name : SString(constant=False, default=None, period=None, readonly=False, units=None)

Projection name.

helper_functions Module

This module contains various utility functions often useb by analysis code.

mozaik.analysis.helper_functions.psth(spike_list, bin_length)

The function returns the psth of the spiketrains with bin length bin_length.

Parameters :

spike_list : list(SpikeTrain )

The list of spike trains. They are assumed to start and end at the same time.

bin_length : float (ms)

Bin length.

Returns :

psth : AnalogSignal

The PSTH of the spiketrain.

mozaik.analysis.helper_functions.psth_across_trials(spike_trials, bin_length)

It returns PSTH averaged across the spiketrains

Parameters :

spike_trials : list(list(SpikeTrain))

should contain a list of lists of neo spiketrains objects, first coresponding to different trials and second to different neurons. The function returns the histogram of spikes across trials with bin length bin_length.

Returns :

psth : AnalogSignal

The PSTH averages over the spiketrains in spike_trials.

technical Module

This module contains special analysis functions that relate to some tehnical mozaik architecture aspects and thus do not represent a standard analysis

class mozaik.analysis.technical.NeuronAnnotationsToPerNeuronValues(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Creates a PerNeuronValues analysis data structure per each neuron annotation that is defined for all neurons in a given sheet.

This analysis is aware of several mozaik specific annotations and adds additional appropriate information to the PerNeuronValue ADS (i.e. setting period to numpy.pi of orientation preference of initial connection fields). Users are expected to modify this class to add additional information for their new annotations if required. It is assumed that in future the handling of parameters around Mozaik might be enhanced and unified further to avoid extension of this class.

perform_analysis()

vision Module

Module containing vision specific analysis.

class mozaik.analysis.vision.ModulationRatio(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

This analysis calculates the modulation ration (as the F1/F0) for all neurons in the data using all available responses recorded to the FullfieldDriftingSinusoidalGrating stimuli. This method also requires that ‘orientation preference’ has already been calculated for all the neurons.

The ModulationRatio takes all responses recorded to the FullfieldDriftingSinusoidalGrating and calculates their PSTH. Then it collapses this list of PSTHs into groups, each containing PSTH associated with the same FullfieldDriftingSinusoidalGrating stimulus with the exception of the orientation. For each such group it then goes through each recorded neuron and selects the closest presented orientation to the orientation peference of the given neuron, and using the PSTH associated with this selected orientation it calculates the modulation ratio for that neuron. This way for each group it will calculate modulation ratios for all recorded neurons, and will store them in datastore using the PerNeuronValue data structure.

Other Parameters:
 

bin_length : float (ms)

the size of bin to construct the PSTH from

perform_analysis()
class mozaik.analysis.vision.Analog_F0andF1(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Calculates the DC and first harmonic of trial averaged vm and conductances for each neuron measured to FullfieldDriftingSinusoidalGrating. It stores them in PerNeuronValue datastructures (one for exc. one for inh. conductances).

Notes

Only neurons for which the corresponding signals were measured will be included in the PerNeuronValue data structures.

perform_analysis()
class mozaik.analysis.vision.LocalHomogeneityIndex(datastore, parameters, tags=None)

Bases: mozaik.analysis.analysis.Analysis

Calculates Local Homogeneity Index (LHI) for each neuron, of each PerNeuronValue that is present in the datastore, according to: Nauhaus, I., Benucci, A., Carandini, M., & Ringach, D. (2008). Neuronal selectivity and local map structure in visual cortex. Neuron, 57(5), 673–679.

required_parameters = {'sigma': <type 'float'>}
perform_analysis()

Previous topic

mozaik API

Next topic

connector Package

This Page