:mod:`neuron_morphology.layered_point_depths.__main__` ====================================================== .. py:module:: neuron_morphology.layered_point_depths.__main__ Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: neuron_morphology.layered_point_depths.__main__.translate_field neuron_morphology.layered_point_depths.__main__.setup_interpolator neuron_morphology.layered_point_depths.__main__.containing_layer neuron_morphology.layered_point_depths.__main__.tuplize neuron_morphology.layered_point_depths.__main__.step_from_node neuron_morphology.layered_point_depths.__main__.get_node_intersections neuron_morphology.layered_point_depths.__main__.setup_layers neuron_morphology.layered_point_depths.__main__.run_layered_point_depths neuron_morphology.layered_point_depths.__main__.main .. function:: translate_field(field: xr.DataArray, by_x: float, by_y: float, inplace: bool = False) Translate a spatial xarray dataset :Parameters: **field** : to be translated .. **by_x** : =the translation along x .. **by_y** : the translation along y .. **inplace** : If True, modify this dataarray, otherwise modify a copy .. :Returns: translated dataarray, potentiall the same as the input .. .. !! processed by numpydoc !! .. function:: setup_interpolator(field: xr.DataArray, dim: Optional[str], **kwargs) -> RegularGridInterpolator Build a regular grid interpolator from a dataarray :Parameters: **field** : Must have dimensions "x" and "y". May have dimension "dim" .. **dim** : base the interpolator on values from this dim slice. If None, ignore dim **\*\*kwargs** : passed to interpolator constructor .. :Returns: a callable interpolator .. .. !! processed by numpydoc !! .. function:: containing_layer(pos: Tuple[float, float], layers: List[Dict]) -> Optional[str] Find the layer in which a point is contained :Parameters: **pos** : the coordinate of the point .. **layers** : Each has "name" - a string and "bounds" - a Polygon .. :Returns: The name of the containing layer or None if no containing layer was found .. .. !! processed by numpydoc !! .. function:: tuplize(arr: np.array) -> Tuple Convert an array to a tuple .. !! processed by numpydoc !! .. function:: step_from_node(pos: Tuple[float, float], depth_interp: RegularGridInterpolator, dx_interp: RegularGridInterpolator, dy_interp: RegularGridInterpolator, surface: LineString, step_size: float, max_iter: int, adaptive_scale: int = 32) -> Optional[float] Walk through a gradient field, until a defined surface is passed. :Parameters: **pos** : the start position .. **depth_interp** : callable mapping positions to scalar depth values .. **dx_interp** : callable mapping positions to the x component of the gradient .. **dy_interp** : callable mapping positions to the y component of the gradient .. **surface** : Check for the intersection of the path with this surface .. **step_size** : Each step proceeds in the direction of the local gradient, scaled to this step size **max_iter** : give up (return None) if the surface is not intersected in this many steps :Returns: The depth of the intersection between the path walked and the given surface .. .. !! processed by numpydoc !! .. function:: get_node_intersections(node: Dict, depth_interp: RegularGridInterpolator, dx_interp: RegularGridInterpolator, dy_interp: RegularGridInterpolator, layers: List[Dict], step_size: float, max_iter: int) -> Dict Given a node, find its layer and intersection depths. Then return a row of LayeredPointDepths for this node. :Parameters: **node** : Of a Morphology. must have: "id" - unique identifier "type" - which kind of node is this? "x", "y" - positions in x and y of this node **depth_interp** : callable mapping positions to scalar depth values .. **dx_interp** : callable mapping positions to the x component of the gradient .. **dy_interp** : callable mapping positions to the y component of the gradient .. **layers** : Each has "name" - an identifier "bounds" - a Polygon describing the entire boundary "pia_surface" - a LineString describing the piaward surface of this layer "wm_surface" - a LineString describing the white matter-wise surface of this layer **step_size** : Each step proceeds in the direction of the local gradient, scaled to this step size **max_iter** : give up (return None) if the surface is not intersected in this many steps :Returns: A dictionary representing a single row of LayeredPointDepths. Has Keys: "ids" - the identifier of this node "layer_name" - the layer containing this node "depth" - the depth of this node "local_layer_pia_side_depth" - the depth of the intersection between this node's steepest ascent path and the piaward surface of its containing layer "local_layer_wm_side_depth" - the depth of the intersection between this node's steepest ascent path and the white matterward surface of its containing layer "point_type": The type of this node .. !! processed by numpydoc !! .. function:: setup_layers(layers: List[Dict]) Convert layer bounds, pia, and white matter surfaces to shapely objects :Parameters: **layers** : Mutated inplace. Has keys: "bounds" - a Polygon describing the entire boundary "pia_surface" - a LineString describing the piaward surface of this layer "wm_surface" - a LineString describing the white matter-wise surface of this layer .. !! processed by numpydoc !! .. function:: run_layered_point_depths(swc_path: str, depth: Dict, layers: List[Dict], step_size: float, max_iter: int, output_path: str) .. function:: main()