spine.vis.box

Defines functions used to draw finite-sized boxes.

These tools are typically used to represent the extent of a voxel or a voxel neighborhood in an image. In the context of the Point-Proposal Network, this helps represent the region proposed by the network at layers deeper than the original resolution of the image.

The box_trace() function is also used to represent the extent of the active volume of the modules that make up a detector.

Functions

box_trace(lower, upper[, draw_faces, line, ...])

Function which produces a plotly trace of a box given its lower bounds and upper bounds in x, y and z.

box_traces(lowers, uppers[, draw_faces, ...])

Function which produces a list of plotly traces of boxes given a list of lower bounds and upper bounds in x, y and z.

scatter_boxes(coords, dimension[, ...])

Function which produces a list of plotly traces of boxes given a list of coordinates and a box dimension.

spine.vis.box.box_trace(lower: np.ndarray, upper: np.ndarray, draw_faces: bool = False, line: dict[str, Any] | None = None, linewidth: float | None = None, color: ColorInput = None, cmin: float | None = None, cmax: float | None = None, colorscale: str | dict | None = None, intensity: IntensityInput = None, hovertext: HoverTextInput = None, showscale: bool = False, **kwargs: Any) go.Scatter3d | go.Mesh3d[source]

Function which produces a plotly trace of a box given its lower bounds and upper bounds in x, y and z.

Parameters:
  • lower (np.ndarray) –

    1. Vector of lower boundaries in x, z and z

  • upper (np.ndarray) –

    1. Vector of upper boundaries in x, z and z

  • draw_faces (bool, default False) – Weather or not to draw the box faces, or only the edges

  • line (dict, optional) – Dictionary which specifies box line properties

  • linewidth (int, optional) – Width of the box edge lines

  • color (Union[str, int, float, Sequence], optional) – Color of the box. Can be a single Plotly color, a single numeric value, or a per-vertex sequence of scalar values.

  • cmin (float, optional) – Minimum value of the color range

  • cmax (float, optional) – Maximum value of the color range

  • colorscale (Union[str, dict]) – Colorscale

  • intensity (Union[int, float, Sequence], optional) – Color intensity of the box along the colorscale axis. Can be a single numeric value or a per-vertex sequence.

  • hovertext (Union[int, float, str, Sequence], optional) – Text associated with the box. Can be a scalar label or a per-vertex sequence of labels.

  • showscale (bool, default False) – If True, show the colorscale of the plotly.graph_objs.Mesh3d

  • **kwargs (dict, optional) – List of additional arguments to pass to plotly.graph_objs.Scatter3D or plotly.graph_objs.Mesh3D, depending on what the draw_faces parameter is set to.

Returns:

Box trace

Return type:

Union[plotly.graph_objs.Scatter3D, plotly.graph_objs.Mesh3D]

spine.vis.box.box_traces(lowers: np.ndarray, uppers: np.ndarray, draw_faces: bool = False, color: ColorInput = None, linewidth: float | None = None, hovertext: HoverTextInput = None, cmin: float | None = None, cmax: float | None = None, shared_legend: bool = True, legendgroup: str | None = None, showlegend: bool = True, name: str | None = None, **kwargs: Any) list[go.Scatter3d | go.Mesh3d][source]

Function which produces a list of plotly traces of boxes given a list of lower bounds and upper bounds in x, y and z.

Parameters:
  • lowers (np.ndarray) – (N, 3) List of vector of lower boundaries in x, z and z

  • uppers (np.ndarray) – (N, 3) List of vector of upper boundaries in x, z and z

  • draw_faces (bool, default False) – Weather or not to draw the box faces, or only the edges

  • color (Union[str, int, float, Sequence], optional) – Color of the boxes, either as one shared value or one value per box.

  • linewidth (int, default 2) – Width of the box edge lines

  • hovertext (Union[int, float, str, Sequence], optional) – Text associated with the boxes, either as one shared label or one label per box.

  • cmin (float, optional) – Minimum value along the color scale

  • cmax (float, optional) – Maximum value along the color scale

  • shared_legend (bool, default True) – If True, the plotly legend of all boxes is shared as one

  • legendgroup (str, optional) – Legend group to be shared between all boxes

  • showlegend (bool, default True) – Whether to show legends on not

  • name (str, optional) – Name of the trace(s)

  • **kwargs (dict, optional) – List of additional arguments to pass to plotly.graph_objs.Scatter3D or plotly.graph_objs.Mesh3D, depending on what the draw_faces parameter is set to.

Returns:

Box traces

Return type:

Union[List[plotly.graph_objs.Scatter3D], List[plotly.graph_objs.Mesh3D]]

spine.vis.box.scatter_boxes(coords: np.ndarray, dimension: float | np.ndarray, draw_faces: bool = True, color: str | float | np.ndarray = 'orange', hovertext: int | str | np.ndarray | None = None, linewidth: float = 2, shared_legend: bool = True, **kwargs: Any) list[go.Scatter3d | go.Mesh3d][source]

Function which produces a list of plotly traces of boxes given a list of coordinates and a box dimension.

This function assumes that the coordinates represent the lower bounds of the voxels they point at. This follows the MinkowskiEngine convention, which is the package used for space convolutions. This can be used to represent the PPN regions of interest in a space compressed by a factor (b_x, b_y, b_z) from the original image resolution.

Parameters:
  • coords (np.ndarray) – (N, 3) Coordinates of in multiples of box lengths in each dimension

  • dimension (Union[float, np.ndarray]) – Dimensions of the boxes. Specify it as either a single number (for cubes) or an array of values in each dimension, i.e. (b_x, b_y, b_z)

  • draw_faces (bool, default True) – Weather or not to draw the box faces, or only the edges

  • color (Union[str, np.ndarray], default 'orange') – Color of boxes or list of color of boxes

  • hovertext (Union[int, str, np.ndarray], optional) – Text associated with every box or each box

  • linewidth (int, default 2) – Width of the box edge lines

  • shared_legend (bool, default True) – If True, the plotly legend of all boxes is shared as one

  • **kwargs (dict, optional) – List of additional arguments to pass to plotly.graph_objs.Scatter3D or plotly.graph_objs.Mesh3D, depending on what the draw_faces parameter is set to.

Returns:

Box traces

Return type:

Union[List[plotly.graph_objs.Scatter3D], List[plotly.graph_objs.Mesh3D]]