pysted.temporal
Classes
|
Creates an |
|
A |
|
A |
A |
|
|
A |
|
A |
- class pysted.temporal.Ensemble(roi=((0, 0), (256, 256)))
Creates an
Ensemble
object which is responsible to handle different objects that are based on a Nodes object- append(obj)
Appends the
obj
to thenEnsemble
- Parameters:
obj – The object to append
- generate_objects_dict(obj_type='all')
Creates a dictionnary containing the pixels corresponding to the objects in the frame. This could be useful if we want to do something other than plot the ojbects, such as tagging them for flashing or something.
- Returns:
A
dict
of the objects
- generate_sequence(num_frames)
Generates the sequence of frames of the
Ensemble
- Parameters:
num_frames – The number of frames to generate
:return : A 3D
numpy.ndarray
of the sequence
- reset_force()
Applies the reset_force to all objects of the
Ensemble
- reset_speed()
Applies the reset_force to all objects of the
Ensemble
- return_frame(image=None)
Creates the frame of the current state of the
Ensemble
- Parameters:
image – (Optional) An
numpy.ndarray
to write to- Returns:
A 2D
numpy.ndarray
of the current state
- show(ax=None)
Implements a
show
function of the ensemble
- spawn(prob=0.1)
Implements a
spawn
function to randomly spawn synapses- Parameters:
prob – The probability of spawning a synapse
- update(prob=0.05, force=(0.0, 0.1), jitter=(0.0, 0.01))
Updates all objects in the
Ensemble
.If an object is out of the region of interest then it is simply removed
- Parameters:
prob – The probability of applying a force
force – A
tuple
of the force to applyjitter – A
tuple
of the jitter to apply
- class pysted.temporal.Fiber(coords=None, random_params={}, parent=None, seed=None)
A
Fiber
is a set of nodes that are connected but not closed- generate_random(num_points=(10, 50), angle=(-0.39269908169872414, 0.39269908169872414), scale=(1, 5), pos=((0, 0), (0, 0)), seed=None)
Generates a random set of points.
To do so, we incrementaly add a point to list of coordinates. It could be seen as building a serpent from the head to the tail.
- Parameters:
num_points – (min, max) values of the uniform sampling to generate the number of points of the fiber
angle – (min, max) values of the uniform sampling to generate the angle from the previous angle
scale – (min, max) values of the uniform sampling to generate the displacement
pos – Uniformly sample a position of the
Fiber
object. Should be atuple
of top-left and bottom-right corner in (y, x) coordinates
- Returns:
A (N,2)
numpy.ndarray
of coordinates
- grow(prob=0.5, angle=(-0.39269908169872414, 0.39269908169872414), scale=(2, 3))
This methods implements the growth of a
Fiber
- Parameters:
angle – (min, max) values of the uniform sampling to generate the angle from the previous angle
scale – (min, max) values of the uniform sampling to generate the displacement
- return_shape(shape=None)
Return
Fiber
indices.- Parameters:
shape – The shape of the field of view
- :returnA numpy.ndarray of row coords
A numpy.ndarray of col coords
- spawn(num=(2, 10))
Method that implements spawn of synapses
- Parameters:
num – (min, max) values of the number of synapses to spawn
- update()
Updates the position of each node based on the current forces and speeds
- class pysted.temporal.Nodes(nodes, parent=None)
A
Nodes
object is responsible to interact with a list of nodes and apply different forces or jitters to the a single node- add_node(node, pos='tail')
Methods that implements adding a node to the current nodes.
We copy the speed and acc of next node
- Parameters:
node – A (y, x) coordinates of the node to add
pos – (Optional) Where to add the node. Should be in {“tail”, “head”}
- apply_force(mean=0.0, std=0.1, field=None)
This method allows to apply a
force
on each nodes- Parameters:
mean – The mean parameter of the normal function to calculate the force
mean – The std parameter of the normal function to calculate the force
field – (Optional) A numpy.ndarray of the force field
- apply_jitter(mean=0.0, std=0.1)
This method allows to jitter the position of each nodes.
- Parameters:
mean – The
mean
parameter of the normal function to calculate jittermean – The
std
parameter of the normal function to calculate jitter
- reset_force()
Reset the current
force
that is being applied on all nodes
- reset_speed()
Reset the current
speed
that is being applied on all nodes
- return_shape()
Should be implemented in the supered classes
- update()
Updates the position of each node based on the current forces and speeds
- class pysted.temporal.NodesCombiner
A
NodesCombiner
object is responsible to combine multipleNodes
object.We store the combined objects into an objects list.
- add_object(obj)
Allows to add a
Nodes
object to theNodesCombinator
- Parameters:
obj – A
Nodes
obj
- apply_force(*args)
This method allows to apply a
force
on each nodes
- apply_jitter(*args)
This method applies a
jitter
on each nodes
- reset_force(*args)
This method allows to reset the
force
currently applied on each node
- reset_speed(*args)
This method allows to reset the
speed
of each node
- update(*args)
Updates the position of each node based on the current forces and speeds
- class pysted.temporal.Polygon(coords=None, random_params={}, parent=None)
A
Polygon
is a set ofNodes
that are closed to the exterior world- area()
Calculates the area covered by the
Polygon
.We use the Shoelace formulation
- Returns:
The area of the polygon
- expand(scale=0.1)
Implements an expand method of the
Polygon
.We assume that the polygon is exapanded from its center of mass
- Parameters:
scale – The scale factor to expand the polygon
- generate_random(num_points=(5, 25), scale=(10, 15), pos=((0, 0), (0, 0)))
Generates a random set of coords.
To do so, we make use of the Convex Hull of a random set of points
- Parameters:
num_points – Uniformly generates a number of points for the convex hull between num_points[0] and num_points[1]
scale – Uniformly generates a scale factor for the convex hull between scale[0] and scale[1]
pos – Uniformly positions the convex hull in space. Should be a
tuple
of top-left and bottom-right corner in (y, x) coordinates
- Returns:
A (N,2)
numpy.ndarray
of coordinates
- return_shape(shape=None)
Return the polygon indices
- Parameters:
shape – The shape of the field of view
- :returnA
numpy.ndarray
of row coords A
numpy.ndarray
of col coords
- update()
Updates the position of each node based on the current forces and speeds
- class pysted.temporal.Synapse(neck_coord, neck_direction, parent=None)
A
Synapse
is a protuberance that starts from aFiber
.It is defined as the combination of a
Fiber
and aPolygon
objects- grow(angle=(-0.39269908169872414, 0.39269908169872414), scale=(1, 2))
Method that implements the growth of the synapse
- Parameters:
angle – (min, max) values of the uniform sampling to generate the angle
scale – (min, max) values of the uniform sampling to generate the displacement
- return_shape(shape=None)
Return
Synapse
indices.- Parameters:
shape – The shape of the field of view
- :returnA
numpy.ndarray
of row coords A
numpy.ndarray
of col coords