neuron_morphology.snap_polygons.image_outputter
¶
Utilites for writing diagnostic overlay images
Module Contents¶
Classes¶
ImageOutputter |
Overlays polygons and surfaces on provided images. Writes the |
Functions¶
write_figure (fig: plt.Figure, *args, **kwargs) |
Write a matplotlib figure without respect to the current figure. |
read_image (path: str, decimate: int = 1) |
Read an image. Dispatch to an appropriate library based on that |
read_with_ndimage (path: str, decimate: int) |
Read (and symmetrically decimate) an image file into a numpy array |
read_jp2 (path: str, decimate: int) |
Read (and symmetrically decimate) a jp2 file into a numpy array |
fname_suffix (path: str, suffix: str) |
Utility for adding a suffix to a path string. The suffix will be |
make_pathpatch (vertices: Sequence[Tuple[float, float]], **patch_kwargs) → mpl.patches.PathPatch |
Utility for building a matplotlib pathpatch from an array of vertices |
-
class
neuron_morphology.snap_polygons.image_outputter.
ImageOutputter
(native_geo: Geometries, result_geo: Geometries, image_specs: Optional[Sequence[Dict]], alpha: float = 0.4, color_cycle: Optional[Sequence] = None, savefig_kwargs: Optional[Dict] = None)¶ Overlays polygons and surfaces on provided images. Writes the results to files.
Parameters: - native_geo : Layer geometries before gaps are filled
- result_geo : Layer geometries after gaps are filled
- image_specs : Each is a dictionary defining a single image. Must
- provide string keys:
- input_path : read from here
- output_path : write to (siblings of) this path
- downsample : the image will be scaled by this factor in each
- dimension
- overlay_types : produce these kinds of overlay for this image
- alpha : of the transparent overlays
- color_cycle : as polygon fills are drawn, cycle through these colors
- savefig_kwargs : Passed directly to pyplot’s savefig, use to specify
e.g dpi.
-
DEFAULT_COLOR_CYCLE
= ['c', 'm', 'y', 'k', 'r', 'g', 'b']¶
-
OVERLAY_TYPES
¶
-
_draw_geometries
(self, geometries: Geometries, image: np.ndarray)¶ Utility for overlaying polygons and surfaces on an image. See draw_before and draw_after for more details.
-
draw_before
(self, image: np.ndarray, scale: float = 1.0)¶ 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
-
draw_after
(self, image: np.ndarray, scale: float = 1.0)¶ 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
-
write_images
(self)¶ 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.
write_figure
(fig: plt.Figure, *args, **kwargs)¶ Write a matplotlib figure without respect to the current figure.
Parameters: - fig : the figure to be writter
- *args, **kwargs : passed to plt.savefig
-
neuron_morphology.snap_polygons.image_outputter.
read_image
(path: str, decimate: int = 1)¶ 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_with_ndimage
(path: str, decimate: int)¶ Read (and symmetrically decimate) an image file into a numpy array
-
neuron_morphology.snap_polygons.image_outputter.
read_jp2
(path: str, decimate: int)¶ Read (and symmetrically decimate) a jp2 file into a numpy array
-
neuron_morphology.snap_polygons.image_outputter.
fname_suffix
(path: str, suffix: str)¶ 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) → mpl.patches.PathPatch¶ 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