coor: (x, y) coordinates.connections:number of neighbours, can be 2, 3, 4, 6, or 8.neighbours: return the neighbour nodes of current node. Number of neighbours is determined byself.connections.__hash__(): operator overloading, used for comparison and inset.__eq__(): operator overloading, used for comparison.__repr__(): operator overloading, representation.
origin: one of the nodes the path is connecting. Origin node.dest: the other node the path is connecting. Destination node. Grow direction of path isself.origin->self.dest.length: length of path.alive: ifTrue, the path can grow at next step, otherwise it cannot grow.max_length: the max allowed length of current path. The path will be divided into 2 or more paths inNeuron.clean()ifself.length>self.max_length.died(): Turn a path to dead state by settingself.aliveto False.grow(): increaseself.length.__hash__(): operator overloading, used for comparison and inset.__eq__(): operator overloading, used for comparison.__repr__(): operator overloading, representation.
A neuron is a collection of Nodes and Paths. It grows as time passes.
Basic properties
origin: the neuron's starting node.speed: the grow speed for each path.vertex: number of neighbours for each node.hand: number of neurites one neuron has at the beginning of a simulation.split_prob: probability for one neurite to split into 2 neurites on a node. A neurite will split only when it encounters a new node.
Conformation properties
connected: True if the neuron is connected to any other neurons.nodes: nodes that are occupied by one neuron.boundary_nodes: nodes that are in the grow direction of one neuron.paths: paths that are fully occupied by one neuron.boundary_paths: paths that are partially occupied by one neuron.
Methods
born(): initiate bare neuron with hands. Updateboundary_pathsandboundary_nodes.grow(): increase the length of one neuron's aliveboundary_pathsby amount ofspeed.clean(): check if any path inboundary_pathshas exceeded its maximum length. If one path exceeds its maximum length:- include the destination node to current neuron's
nodes. - Decide whether to split or not by using
split_check(). - Decide which way to grow by using
way_to_go(). - Include new boundary paths and boundary nodes to
boundary_pathsandboundary_nodes.
- include the destination node to current neuron's
connect(): Turnself.connectedto True.check_alive(): Check paths inboundary_pathsif they are alive or not.split_check(): Decide whether to split at a node by usingself.split_prob. ReturnTrueorFalseto decide whether to split and possible boundary nodes forway_to_go()to choose.way_to_go(): Decide which way to go when encountering a new node. Just choose from possible destination nodessplit_check()passes.cal_end(self, path): calculate coordinates of a endpoint for a path.draw(): Draw origin node and current paths on aDrawobject.
Simulation class placeholder.
- Check if any two neurons are connected. If two neurons are connected, call
their
connect()method to update their status. - Connections can only occur between boundary nodes.
- Checking method:
- Store a list of connected tuples (neuron1, neuron2), do not check for these combinations.
- For each combination
n1andn2:- Check
n1.nodesandn2.nodesfor duplication. If there are duplications, markn1andn2as connected and stop checking. If no duplications, go to step 2. - Check for duplications between
n1.boundary_nodesandn2.boundary_nodes. If there are duplications, sayn1.boundary_nodeandn2.boundary_node, letpath1be the boundary path forn1that ends withn2.boundary_node, andpath2be the boundary path forn2that ends withn1.boundary_node. Check the sum forpath1.lengthandpath2.length. If the sum exceeds maximum path length, markn1andn2as connected, else stop checking.
- Check
Count the percentage of connected neurons.
Check equality for two pairs of float coordinates.
Generate pattern grid for type 2 and type 4. Then randomly select nodes as neuron origin nodes.
Generate pattern grid for type 6. Then randomly select nodes as neuron origin nodes.
- Initiate grid and neurons.
T = 0, For each neuron, born().T > 0, for each time step:- For each neuron
grow(). - For each neuron
clean(). - For each neuron
check_alive(). check_connections().
- For each neuron
- If percentage of connected neurons exceeds the pre-defined max-percentage, stop iteration.