tools Package

misc Module

Various helper functions.

mozaik.tools.misc.sample_from_bin_distribution(bins, number_of_samples)

Samples from a distribution defined by a vector the sum in. The vector doesn’t have to add up to one it will be automatically normalized.

Parameters :

bins : ndarray

The returned samples correspond to the bins in bins - the numpy array defining the bin distribution

number_of_samples : int

Number of samples to generate.

mozaik.tools.misc.normal_function(x, mean=0, sigma=1.0)

Returns the value of probability density of normal distribution N(mean,sigma) at point x.

mozaik.tools.misc.find_neuron(which, positions)
Finds a neuron depending on which:
‘center’ - the most central neuron in the sheet ‘top_right’ - the top_right neuron in the sheet ‘top_left’ - the top_left neuron in the sheet ‘bottom_left’ - the bottom_left neuron in the sheet ‘bottom_right’ - the bottom_right neuron in the sheet

mozaik_parametrized Module

This module contains extension of the param package, and a collection of functions that allow for powerfull filtering of sets of MozaikParametrized instances based on the values of their parameters.

When parametrizing mozaik objects we will allow only SNumber, SInteger and SString parameters. These are extension of corresponding parametrized parameters that automatically allow None value, are instantiated and allow for definition of units and period.

mozaik.tools.mozaik_parametrized.SNumber

A mozaik parameter that can hold a number. For the full range of options the parameter offers reffer to the Number class in param package.

On top of the Number class it adds the ability to specify units and period in constructor. The units should be quantities.units.

mozaik.tools.mozaik_parametrized.SInteger

A mozaik parameter that can hold an integer. For the full range of options the parameter offers reffer to the Integer class in param package.

On top of the Integer class it adds the ability to specify units in constructor. The units should be quantities.units.

mozaik.tools.mozaik_parametrized.SString

A mozaik parameter that can hold an string. For the full range of options the parameter offers reffer to the Integer class in param package.

This class is here for consistency reasons as it defines the units and period properties, just like SInteger and SNumber, but automatically sets them to None.

class mozaik.tools.mozaik_parametrized.MozaikParametrized(**params)

Bases: param.parameterized.Parameterized

We extend the topographica Parametrized package to constrain the parametrization. We allow only three parameter types (SNumber or SInteger or SString) that we have extended with further information.

This allows us to define several useful operations over such parametrized objects that we will use extensively (see above).

Currently the main use of this parametrization is for defining stimuli and analysis data structures. It allows us to write general and powerfull querying functions, automatically handle parameter units and parameter names.

For the usage of the MozaikParametrized class refer to the Parameterized in param package, as the behaviour of this class is identical, with the exception that it restricts the possbile parameters used to the trio of SNumber or SInteger or SString.

This class also adds several utility functions documented below.

name = 'MozaikParametrized'
equalParams(other)

Returns True if self and other have the same parameters and all their values match. False otherwise.

JACOMMENT: This seems to work only because get_param_values sorts the list by names which is undocumented!

equalParamsExcept(other, exceptt)

Returns True if self and other have the same parameters and all their values match with the exception of the parameter in except. False otherwise.

classmethod params(parameter_name=None)

In MozaikParametrized we hide parameters with precedence below 0 from users.

classmethod idd(obj)

This class method is used in concjuction with the MozaikParametrized.__str__ function that stores all the parameters and the class and module of an object. This method restores a ‘Shell’ object out of this str. The returned object will be of the same type as the original object and will contain all its original parameters and their values, BUT WILL NOT BE INITIALIZED and so should not be used for anything else other than examining it’s parameters!!!!

Furthermore if given an instance of MozaikParametrized instead it will convert it into the ‘Shell’ object.

mozaik.tools.mozaik_parametrized.filter_query(object_list, extra_data_list=None, allow_non_existent_parameters=False, **kwargs)

Returns a subset of object_list containing MozaikParametrized instances (and associated data if data_list!=None) for which the parameters in kwargs match.

Parameters :

object_list : list(MozaikParametrized)

The list of MozaikParametrized objects to filter.

extra_data_list : list(object)

The list of values corresponding to objects in object_list. The same subset of the vales will be returned as for the object_list.

allow_non_existent_parameters : bool

If True it will allow objects in object list that miss some of the parameters listed in kwargs, and include them in the results as long the remaining parameters match if False it will exclude them.

**kwargs : dict

The parameter names and values that have to match.

Returns :

if data_list == None : subset of object_list containing elements that match the kwargs parameters

if data_list != None : tuple (a,b) where a is a subset of object_list containing elements that match the kwargs parameters and b is the corresponding subset of data_list

mozaik.tools.mozaik_parametrized.colapse(data_list, object_list, func=None, parameter_list=[], allow_non_identical_objects=False)

It collapses the data_list against parameters of objects in object_list that are in parameter_list. This means that the new list of parameters (and associated datalist) will contain one object for each combination of parameter values not among the paramters against which to collapse. Each such object will be associated with a list of data that corresponded to object with the same parameter values, but any values for the parameters against which one is collapsing. The collapsed parameters in the object_list will be replaced with None.

Parameters :

func : bool

If not None, func is applied to each member of v.

data_list : list

The list of data corresponding to objects in object_list.

object_list : list(MozaikParametrized)

The list of object corresponding to data in data_list.

parameter_list : list

The list of parameter names against which to collapse the data.

func : func()

The function to be applied to the lists formed by data associated with the same object parametrizations with exception of the parameters in parameter_list

allow_non_identical_objects : bool, optional

unless set to True, it will not allow running this operation on StimulusDependentData that does not contain only object of the same type

Returns :

(v,object_id) : list,list

Where object_id is the new list of objects where the objects in parameter_list were ‘collapsed out’ and replaced with None. v is a list of lists. The outer list corresponds in order to the object_id list. The inner list corresponds to the list of data from data_list that mapped on the given object_id.

mozaik.tools.mozaik_parametrized.varying_parameters(parametrized_objects)

Find the varying list of params. Can be only applied on list of MozaikParametrized that have the same parameter set.

Returns :List of parameters of the `MozaikParamterrized` objects in `parametrized_objects` that have at least 2 different values within the list. :
mozaik.tools.mozaik_parametrized.parameter_value_list(parametrized_objects, param)

Returns the list of values the given parameter has in the list of MozaikParametrized instances.

Parameters :

parametrized_objects : list

A list of MozaikParametrized instances.

param : str

Name of the parameter.

Returns :

A list of different values that the parameter param has across the `MozaikParametrized` objects in `parametrized_objects` list. :

mozaik.tools.mozaik_parametrized.identical_parametrized_object_params(parametrized_objects)

Check whether the objects have the same parameters.

Returns :

True if all instances of `MozaikParametrized` in `parametrized_objects` have the same set of parameters (not values!). :

Otherwise returns False. :

mozaik.tools.mozaik_parametrized.matching_parametrized_object_params(parametrized_objects, params=None, except_params=None)

Checks whether parametrized_objects have the same parameter values for parameters in params or not in except_params.

Parameters :

parametrized_objects : list

List of MozaikParametrized object to test.

params : list,optional

List of parameters whose values have to match.

except_params : list, optional

List of parameters that do not have to match.

Returns :

if params != None :

Returns True if all MozaikParametrized objects in parametrized_objects have the same parameter values for parameters in params, otherwise returns False.

if except_params != None :

Returns True if all MozaikParametrized objects in arametrized_objects have the same parameters except those in except_params, otherwise returns False.

if except_params == None and except_params == None :

Returns True if all MozaikParametrized objects in parametrized_objects have the same parameters, otherwise returns False.

if except_params != None and except_params != None :

Throws exception

mozaik.tools.mozaik_parametrized.colapse_to_dictionary(value_list, parametrized_objects, parameter_name)

Colapse out a parameter parameter_name of a list of MozaikParametrized instances.

Parameters :

value_list : list

The list of values that correspond to instances of MozaikParametrized in parametrized_objects.

parametrized_objects : list

The list of values that correspond to instances of MozaikParametrized.

parameter_name : str

The parameter against which to colapse.

Returns :

D : dict

Where D.keys() correspond to parametrized_objects ids with the dimension parameter_name colapsed out (and replaced with None). The D.values() are tuple of lists (keys,values), where keys is the list of values that the parameter_name had in the parametrized_objects, and the values are the values from value_list that correspond to the keys.

circ_stat Module

This module contains several helper functions for working with periodic variables.

mozaik.tools.circ_stat.circular_dist(a, b, period)

Returns the distance between a and b (scalars) in a domain with period period.

mozaik.tools.circ_stat.rad_to_complex(vector)

Converts a vector/matrix of angles (0, 2*pi) to vector/matrix of complex numbers (that will lie on the unit circle) and correspond to the given angle.

mozaik.tools.circ_stat.angle_to_pi(array)

Returns angles of complex numbers in array but in (0, 2*pi) interval unlike numpy.angle the returns it in (-pi, pi).

mozaik.tools.circ_stat.circ_mean(matrix, weights=None, axis=None, low=0, high=6.283185307179586, normalize=False)

Circular mean of matrix. Weighted if weights are not none. Mean will be computed along axis axis.

Parameters :

matrix : ndarray

Matrix of data for which the compute the circular mean.

weights : ndarray, optional

If not none, matrix of the same size as matrix. It will be used as weighting for the mean.

low, high : double, optional

The min and max values that will be mapped onto the periodic interval of (0, 2pi).

axis : int, optional

Numpy axis along which to compute the circular mean.

normalize : bool

If True weights will be normalized along axis. If any weights that are to be jointly normalized are all zero they will be kept zero!

Returns :

(angle, length) : ndarray,ndarray

Where angle is the circular mean, and len is the length of the resulting mean vector.

distribution_parametrization Module

This module contains code interfacing NeuroTools parameters, and pyNN distribution interface.

In future pyNN plans to make an comprehensive merge between NeuroTools parametrization system and pyNN, in which case this code should become obsolete and mozaik should fully switch to such new system.

mozaik.tools.distribution_parametrization.load_parameters(parameter_url, modified_parameters)

A simple function for loading parameters that replaces the values in modified_parameters in the loaded parameters and subsequently expands references.

class mozaik.tools.distribution_parametrization.PyNNDistribution(name, params=(), boundaries=None, constrain='clip')

Bases: pyNN.random.RandomDistribution

This will be the wraper for the PyNN RandomDistribution

The first parameter is the name of the distribution (see pyNN.random.RandomDistribution) The params is a tuple of parameters of the corresponding numpy distribution (see pyNN.random.RandomDistribution) For the rest of the parameters see pyNN.random.RandomDistribution

class mozaik.tools.distribution_parametrization.MozaikExtendedParameterSet(initialiser, label=None, update_namespace=None)

Bases: parameters.ParameterSet

This is an extension to ParameterSet class which adds the PyNNDistribution as a possible type of a parameter.

static read_from_str(s, update_namespace=None)

misc Module

Various helper functions.

mozaik.tools.misc.sample_from_bin_distribution(bins, number_of_samples)

Samples from a distribution defined by a vector the sum in. The vector doesn’t have to add up to one it will be automatically normalized.

Parameters :

bins : ndarray

The returned samples correspond to the bins in bins - the numpy array defining the bin distribution

number_of_samples : int

Number of samples to generate.

mozaik.tools.misc.normal_function(x, mean=0, sigma=1.0)

Returns the value of probability density of normal distribution N(mean,sigma) at point x.

mozaik.tools.misc.find_neuron(which, positions)
Finds a neuron depending on which:
‘center’ - the most central neuron in the sheet ‘top_right’ - the top_right neuron in the sheet ‘top_left’ - the top_left neuron in the sheet ‘bottom_left’ - the bottom_left neuron in the sheet ‘bottom_right’ - the bottom_right neuron in the sheet

neo_object_operations Module

This file contains various operations over Neo objects. Such as sum over lists of Neo objects etc.

mozaik.tools.neo_object_operations.neo_sum(l)

This function gets a list of Neo objects and it adds them up. Importantly unlike Python sum function it starts adding to the first element of the list no to 0.

mozaik.tools.neo_object_operations.neo_mean(l)

Calculates the mean over list of Neo objects. See neo_sum for more details.

units Module

This module defines units used in mozaik project and not specified in the quantities package.

mozaik.tools.units.periodic(unit)

Checks whether a units is periodic

Returns :

(a,b): bool,double :

Where a is True if unit is periodic, and b corresponds to the period if a is True.

Previous topic

storage Package

Next topic

visualization Package

This Page