MOOSE documentation is split into Python documentation and builtin documentation. The functions and classes that are only part of the Python interface can be viewed via Python’s builtin help function:
>>> help(moose.connect)
...
The documentation built into main C++ code of MOOSE can be accessed via the module function doc:
>>> moose.doc('Neutral')
...
To get documentation about a particular field:
>>> moose.doc('Neutral.childMsg')
Classes:
this is the unique identifier of a MOOSE object. Note that you can create multiple references to the same MOOSE object in Python, but as long as they have the same path/id value, they all point to the same entity in MOOSE.
Constructor:
You can create a new vec using the constructor:
vec(path, dimension, classname)
Fields:
value – unsigned integer representation of id of this vec
path – string representing the path corresponding this vec
shape – tuple containing the dimensions of this vec
Apart from these, every vec exposes the fields of all its elements in a vectorized form. For example:
>>> iaf = moose.vec('/iaf', (10), 'IntFire')
>>> iaf.Vm = range(10)
>>> print iaf[5].Vm
5.0
>>> print iaf.Vm
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
Methods:
vec implements part of the sequence protocol:
len(em) – the first dimension of em.
em[n] – the n-th element in em.
em[n1:n2] – a tuple containing n1 to n2-th (exclusive) element in em.
elem in em – True if elem is contained in em.
Single moose object. It has three numbers to uniquely identify it:
id - id of the vec containing this element
dataIndex - index of this element in the container vec
fieldIndex - if this is a tertiary object, i.e. acts as a field in another element (like synapse[0] in IntFire[1]), then the index of this field in the containing element.
Methods:
getId – vec object containing this element. vec() – vec object containing this element.
getDataIndex() – unsigned integer representing the index of this element in containing MOOSE object.
getFieldIndex() – unsigned integer representing the index of this element as a field in the containing Element.
getFieldType(field) – human readable datatype information of field
getField(field) – get value of field
setField(field, value) – assign value to field
getFieldNames(fieldType) – tuple containing names of all the fields of type fieldType. fieldType can be valueFinfo, lookupFinfo, srcFinfo, destFinfo and sharedFinfo. If nothing is passed, a union of all of the above is used and all the fields are returned.
connect(srcField, destObj, destField, msgType) – connect srcField of this element to destField of destObj.
melement is something like an abstract base class in C++. The concrete base class is Neutral. However you do not need to cast objects down to access their fields. The PyMOOSE interface will automatically do the check for you and raise an exception if the specified field does not exist for the current element.
To create the objects of concrete subclasses of melement, the class can be called as follows:
melement(path, dims, dtype, parent)
path: This is like unix filesystem path and is the concatenation of name of the element to be created and that of all its ancestors spearated by /. For example, path=`/a/b` will create the element named b under element a. Note that if a does not exist, this will raise an error. However, if parent is specified, path should contain only the name of the element.
dims: (optional) tuple specifying the dimension of the containing melement to be created. It is (1,) by default.
dtype: string specifying the class name of the element to be created.
parent: (optional) string specifying the path of the parent element or the Id or the ObjId of the parent element or a reference to the parent element. If this is specified, the first argument path is treated as the name of the element to be created.
All arguments can be passed as keyword arguments.
For concrete subclasses of melement, you do not need to pass the class argument because the class name is passed automatically to melement __init__ method.
a = Neutral(‘alpha’) # Creates element named alpha under current working element b = Neutral(‘alpha/beta’) # Creates the element named beta under alpha c = Cell(‘charlie’, parent=a) # creates element charlie under alpha d = DiffAmp(‘delta’, parent=’alpha/beta’) # creates element delta under beta
element(path) - returns a reference to an existing object converted to the right class. Raises ValueError if path does not exist.
copy(src=<src>, dest=<dest>, name=<name_of_the_copy>, n=<num_copies>, copyMsg=<whether_to_copy_messages) – make a copy of source object as a child of the destination object.
move(src, dest) – move src object under dest object.
useClock(tick, path, update_function) – schedule <update_function> of every object that matches <path> on clock no. <tick>. Most commonly the function is ‘process’. NOTE: unlike earlier versions, now autoschedule is not available. You have to call useClock for every element that should be updated during the simulation.
The sequence of clockticks with the same dt is according to their number. This is utilized for controlling the order of updates in various objects where it matters.
The following convention should be observed when assigning clockticks to various components of a model:
Clock ticks 0-3 are for electrical (biophysical) components, 4 and 5 are for chemical kinetics, 6 and 7 are for lookup tables and stimulus, 8 and 9 are for recording tables.
Generally, ‘process’ is the method to be assigned a clock tick. Notable exception is ‘init’ method of Compartment class which is assigned tick 0.
0 : Compartment: ‘init’ 1 : Compartment: ‘process’ 2 : HHChannel and other channels: ‘process’ 3 : CaConc : ‘process’ 4,5 : Elements for chemical kinetics : ‘process’ 6,7 : Lookup (tables), stimulus : ‘process’ 8,9 : Tables for plotting : process
Example: moose.useClock(0, ‘/model/compartment_1’, ‘init’) moose.useClock(1, ‘/model/compartment_1’, ‘process’)
setClock(tick, dt) – set dt of clock no <tick>.
start(runtime) – start simulation of <runtime> time.
reinit() – reinitialize simulation.
stop() – stop simulation
isRunning() – true if simulation is in progress, false otherwise.
exists(path) – true if there is a pre-existing object with the specified path.
loadModel(filepath, modelpath) – load file in <filepath> into node <modelpath> of the moose model-tree.
setCwe(obj) – set the current working element to <obj> - which can be either a string representing the path of the object in the moose model-tree, or an vec. ce(obj) – an alias for setCwe.
getCwe() – returns vec containing the current working element. pwe() – an alias for getCwe.
showfields(obj) – print the fields in object in human readable format
le(obj) – list element under object, if no parameter specified, list elements under current working element
Print present working element. Convenience function for GENESIS users. If you want to retrieve the element in stead of printing the path, use moose.getCwe()
List elements under el or current element if no argument specified.
Parameters : | el : str/melement/vec/None
|
---|---|
Returns : | None |
Set the current working element. ‘ce’ is an alias of this function
Show the fields of the element el, their data types and values in human readable format. Convenience function for GENESIS users.
Parameters : | el : melement/str
field : str
showtype : bool
|
---|---|
Returns : | None |
Print the incoming and outgoing messages of el.
Parameters : | el : melement/vec/str
|
---|---|
Returns : | None |
Display the documentation for class or field in a class.
Parameters : | arg : str/class/melement/vec
paged: bool
|
---|---|
Returns : | None |
Raises : | NameError
|
Convert a path or an object to the appropriate builtin moose class instance
Parameters : | arg : str/vec/moose object
|
---|---|
Returns : | melement
|
Get a tuple containing the name of all the fields of finfoType kind.
Parameters : | className : string
finfoType : string
|
---|---|
Returns : | tuple
|
Make copies of a moose object.
Parameters : | src : vec, element or str
dest : vec, element or str
name : str
n : int
toGlobal : int
copyExtMsg : int
|
---|---|
Returns : | vec
|
Move a vec object to a destination.
Delete the underlying moose object. This does not delete any of the Python objects referring to this vec but does invalidate them. Any attempt to access them will raise a ValueError.
Parameters : | id : vec
|
---|---|
Returns : | None |
Schedule objects on a specified clock
Set the dt of a clock.
Run simulation for t time. Advances the simulator clock by t time.
After setting up a simulation, YOU MUST CALL MOOSE.REINIT() before CALLING MOOSE.START() TO EXECUTE THE SIMULATION. Otherwise, the simulator behaviour will be undefined. Once moose.reinit() has been called, you can call moose.start(t) as many time as you like. This will continue the simulation from the last state for t time.
Parameters : | t : float
|
---|---|
Returns : | None |
See also
Reinitialize simulation.
This function (re)initializes moose simulation. It must be called before you start the simulation (see moose.start). If you want to continue simulation after you have called moose.reinit() and moose.start(), you must NOT call moose.reinit() again. Calling moose.reinit() again will take the system back to initial setting (like clear out all data recording tables, set state variables to their initial values, etc.
Stop simulation
True if the simulation is currently running.
True if there is an object with specified path.
Export biochemical model to an SBML file.
Import SBML model to Moose.
Load model from a file to a specified path.
Parameters : | filename : str
modelpath : str
solverclass : str, optional
|
---|---|
Returns : | vec
|
Save model rooted at source to file filename.
Parameters : | source : vec/element/str
filename : str
|
---|---|
Returns : | None |
Create a message between src_field on src object to dest_field on dest object.
Parameters : | src : element/vec/string
src_field : str
dest : element/vec/string
dest_field : str
message_type : str (optional)
|
---|---|
Returns : | melement
|
Get the current working element. ‘pwe’ is an alias of this function.
Set the current working element. ‘ce’ is an alias of this function
Get dictionary of field names and types for specified class.
Parameters : | className : str
finfoType : str (optional)
|
---|---|
Returns : | dict
|
Notes
This behaviour is different from getFieldNames where only valueFinfo`s are returned when `finfoType remains unspecified.
getField(element, field, fieldtype) – Get specified field of specified type from object vec.
Reseed MOOSE random number generator.
Parameters : | seed : int
|
---|---|
Returns : | None |
Returns : | float in [0, 1) real interval generated by MT19937. |
---|
Find an object by wildcard.
Parameters : | expression : str
|
---|
Finalize MOOSE threads and quit MOOSE. This is made available for debugging purpose only. It will automatically get called when moose module is unloaded. End user should not use this function.
,