samuroi.masks package¶
Classes¶
-
class
samuroi.masks.branch.
BranchMask
(data=None, name=None)[source]¶ Bases:
samuroi.masks.mask.Mask
Represent a dendrite branch, or part of a dendrite branch. Provide functionality for splitting, joining and iterating over segments.
-
changed
= None¶ The event which will be triggered when the branch mask was changed.
-
children
¶ Get the list of child segments of this branch.
Warning
Do not modify this list manually. Instead use
samuroi.masks.branch.BranchMask.split()
.Returns: the list of children.
-
data
¶ Returns: return the data of the wrapped samuroi.util.branch.Branch
object.
-
linescan
(data, mask)[source]¶ Calculate the trace for all children and return a 2D array of traces. :param data: the data to apply on. :param mask: some additional overlay mask :return: 2D numpy array holding traces for all children
-
outline
¶ Returns: return the outline of the wrapped samuroi.util.branch.Branch
object.
-
segments
= None¶ Child masks aka segments of the branch.
-
split
(nsegments=2, length=None, k=1, s=0)[source]¶ Split this branch and create a set of child segments.
Note
One can either provide a nsegments or length.
Splitting of a branch will modify the
samuroi.masks.branch.BranchMask.children
attribute and hence trigger asamuroi.masks.branch.BranchMask.changed
event.Parameters: - nsegments – the number of segments.
- length – the length of each segment (the last segment will have the remainder of modulo division).
- k – smoothness parameter for spline interpolation
- s – smoothness parameter for spline interpolation
-
-
class
samuroi.masks.circle.
CircleMask
(center, radius, name=None)[source]¶ Bases:
samuroi.masks.mask.Mask
-
center
¶
-
move
(offset)[source]¶ Move the circle mask in the direction defined by offset. Will trigger the changed event. :param offset: list with two elements denoting x (positive right, negative left) and y (positive up, negative down).
-
radius
¶
-
-
class
samuroi.masks.mask.
Mask
(name=None)[source]¶ If a mask is mutable, it needs to provide a changed signal, which is supposed to be triggered upon modification.
-
__call__
(data, mask)[source]¶ Apply self on data and calculate the time trace. Before the application of self, the data is masked with the mask provided in the parameters. I.e. the final resulting mask is an and composition of self and mask.
Parameters: - data – the video data .
- mask – a 2D mask array with same shape as video resolution.
Returns: 1D numpy array holding the time trace of this mask.
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
samuroi.masks.pixel.
PixelMask
(name=None, xy=None, x=None, y=None)[source]¶ Bases:
samuroi.masks.mask.Mask
-
x
¶
-
y
¶
-
-
class
samuroi.masks.polygon.
PolygonMask
(outline, name=None)[source]¶ Bases:
samuroi.masks.mask.Mask
A mask that is defined by the corners of a polygon
-
lowerleft
¶
-
outline
¶
-
upperright
¶
-
weights
¶ Generate the weight mask of the rectangular area covering the given polygon.
-
-
class
samuroi.masks.segment.
SegmentMask
(data, parent)[source]¶ Bases:
samuroi.masks.mask.Mask
-
data
¶ Returns: return the data of the wrapped samuroi.util.branch.Branch
object.
-
join
(next=True)[source]¶ - Join two segments into one. Arguments:
- next: True or False, denote whether to join the segment with the preceding or succeeding one.
-
move
(offset)[source]¶ Move the segment don’t trigger any event since this will be handled by the parent branch object.
-
outline
¶ Returns: return the outline of the wrapped samuroi.util.branch.Branch
object.
-
-
class
samuroi.masks.segmentation.
Segmentation
(data, name=None)[source]¶ Bases:
samuroi.masks.mask.Mask
Represent a full segmentation of the 2D array. The segmentation should be immutable. Maybe a special handling for index 0 would be nice?!?
-
class
Child
(parent, index)[source]¶ Bases:
samuroi.masks.mask.Mask
A proxy object that implements the mask interface but is just a facade around one index of the segmentation
-
parent
¶
-
x
¶
-
y
¶
-
-
Segmentation.
children
¶
-
Segmentation.
data
¶
-
class