allensdk.internal.morphology.morphvis module¶
-
allensdk.internal.morphology.morphvis.
calculate_scale
(morph, pix_width, pix_height)[source]¶ Calculates scaling factor and x,y insets required to auto-scale and center morphology into box with specified numbers of pixels
Parameters: - morph: AISDK Morphology object
- pix_width: int
- Number of image pixels on X axis
- pix_height: int
- Number of image pixels on Y axis
Returns: - real, real, real
- First return value is the scaling factor. Second is the
- number of pixels needed to adjust x-coordinates so that the
- morphology is horizontally centered. Third is the number of
- pixels needed to adjust the y-coordinates so that the morphology
- is vertically centered.
-
allensdk.internal.morphology.morphvis.
draw_density_hist
(img, morph, vert_scale, inset_left=0, inset_right=0, inset_top=0, inset_bottom=0, num_bins=None, colors=None)[source]¶ Draws density histogram onto image When no scaling is applied, and no insets are provided, the coordinates of the morphology are used directly – i.e., 100 in morphology coordinates is equal to 100 pixels.
The scale factor is multiplied to morphology coordinates before being drawn. If scale_factor=2 then 50 in morphology coordinates is 100 pixels. Left and top insets shift the coordinate axes for drawing. E.g., if left=10 and top=5 then 0,0 in morphology coordinates is 10,5 in pixel space. Bottom and right insets are ignored.
If scale_to_fit is set then scale factor is ignored. The morphology is scaled to be the maximum size that fits in the image, taking into account insets. In a 100x100 image, if all insets=10, then the image is scaled to fit into the center 80x80 pixel area, and nothing is drawn in the inset border areas.
Axons are drawn before soma and dendrite compartments.
Parameters: - img: PIL image object
- morph: AISDK Morphology object
- vert_scale: real
- This is the amout required to multiply to a moprhology
- y-coordinate to convert it to relative cortical depth (on [0,1]).
- This is the inverse of the cortical thickness.
- inset_*: real
- This is the number of pixels to use as border on top/bottom/
- right/left. If scale_to_fit is false then only the top/left
- values are used, as the scale_factor will determine how
- large the morphology is (it can be drawn beyond insets and even
- beyond image boundaries)
- num_bins: int
- The number of bins in the histogram
- colors: MorphologyColors object
- This is the color scheme used to draw the morphology. If
- colors=None then default coloring is used
Returns: - Histogram arrays: [hist, hist2, hist3, hist4]
- where hist is the histgram of all neurites, and hist[234] are
- the histograms of SWC types 2,3,4
-
allensdk.internal.morphology.morphvis.
draw_morphology
(img, morph, inset_left=0, inset_right=0, inset_top=0, inset_bottom=0, scale_to_fit=False, scale_factor=1.0, colors=None)[source]¶ Draws morphology onto image When no scaling is applied, and no insets are provided, the coordinates of the morphology are used directly – i.e., 100 in morphology coordinates is equal to 100 pixels.
The scale factor is multiplied to morphology coordinates before being drawn. If scale_factor=2 then 50 in morphology coordinates is 100 pixels. Left and top insets shift the coordinate axes for drawing. E.g., if left=10 and top=5 then 0,0 in morphology coordinates is 10,5 in pixel space. Bottom and right insets are ignored.
If scale_to_fit is set then scale factor is ignored. The morphology is scaled to be the maximum size that fits in the image, taking into account insets. In a 100x100 image, if all insets=10, then the image is scaled to fit into the center 80x80 pixel area, and nothing is drawn in the inset border areas.
Axons are drawn before soma and dendrite compartments.
Parameters: - img: PIL image object
- morph: AISDK Morphology object
- inset_*: real
- This is the number of pixels to use as border on top/bottom/
- right/left. If scale_to_fit is false then only the top/left
- values are used, as the scale_factor will determine how
- large the morphology is (it can be drawn beyond insets and even
- beyond image boundaries)
- scale_to_fit: boolean
- If true then morphology is scaled to the inset area of the
- image and scale_factor is ignored. Morphology is centered
- in the image in the sense that the top/bottom and left/right
- edges of the morphology are equidistant from image borders.
- scale_factor: real
- A scalar amount that is multiplied to morphology coordinates
- before drawing
- colors: MorphologyColors object
- This is the color scheme used to draw the morphology. If
- colors=None then default coloring is used
Returns: - 2-dimensional array, the pixel coordinates of the soma root [x,y]