neuron_morphology.snap_polygons.image_outputter module

class neuron_morphology.snap_polygons.image_outputter.ImageOutputter(native_geo: neuron_morphology.snap_polygons.geometries.Geometries, result_geo: neuron_morphology.snap_polygons.geometries.Geometries, image_specs: Optional[Sequence[Dict[KT, VT]]], alpha: float = 0.4, color_cycle: Optional[Sequence[T_co]] = None, savefig_kwargs: Optional[Dict[KT, VT]] = None)[source]

Bases: object

Methods

draw_after(self, image, scale) Display the post-fill polygons and surfaces overlaid on an image.
draw_before(self, image, scale) Display the pre-fill polygons and surfaces overlaid on an image.
write_images(self) For each image specified in this outputter and each overlay type requested for that image, produce and save an overlay.
DEFAULT_COLOR_CYCLE = ('c', 'm', 'y', 'k', 'r', 'g', 'b')
OVERLAY_TYPES = {'after': 'draw_after', 'before': 'draw_before'}
draw_after(self, image: numpy.ndarray, scale: float = 1.0)[source]

Display the post-fill polygons and surfaces overlaid on an image.

Parameters:
image : onto which objects will be drawn
scale : required to transform from object space to image space
Returns:
A matplotlib figure containing the overlay
draw_before(self, image: numpy.ndarray, scale: float = 1.0)[source]

Display the pre-fill polygons and surfaces overlaid on an image.

Parameters:
image : onto which objects will be drawn
scale : required to transform from object space to image space
Returns:
A matplotlib figure containing the overlay
write_images(self)[source]

For each image specified in this outputter and each overlay type requested for that image, produce and save an overlay.

neuron_morphology.snap_polygons.image_outputter.fname_suffix(path: str, suffix: str)[source]

Utility for adding a suffix to a path string. The suffix will be inserted before the extension.

neuron_morphology.snap_polygons.image_outputter.make_pathpatch(vertices: Sequence[Tuple[float, float]], **patch_kwargs) → matplotlib.patches.PathPatch[source]

Utility for building a matplotlib pathpatch from an array of vertices

Parameters:
vertices : Defines the path. May be closed or open
**patch_kwargs : passed directly to pathpatch constructor
neuron_morphology.snap_polygons.image_outputter.read_image(path: str, decimate: int = 1)[source]

Read an image. Dispatch to an appropriate library based on that image’s extension.

Parameters:
path : to the image
decimate : apply a decimation of this factor along each axis of the image
neuron_morphology.snap_polygons.image_outputter.read_jp2(path: str, decimate: int)[source]
neuron_morphology.snap_polygons.image_outputter.read_with_ndimage(path: str, decimate: int)[source]
neuron_morphology.snap_polygons.image_outputter.write_figure(fig: matplotlib.figure.Figure, *args, **kwargs)[source]

Write a matplotlib figure without respect to the current figure.

Parameters:
fig : the figure to be writter
*args, **kwargs : passed to plt.savefig