From 5606b12aeb6bed9a1bfcbc9497af242bac936885 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Mon, 27 May 2024 14:56:06 +0200 Subject: [PATCH 1/4] clean doc lints --- doc/source/api.rst | 3 +++ doc/source/morph_stats.rst | 3 +-- doc/source/quickstart.rst | 6 +++--- neurom/features/__init__.py | 1 - neurom/morphmath.py | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index d19b1c75..eb4a70db 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -38,6 +38,8 @@ API Documentation :nosignatures: :toctree: _neurom_build + neurom + neurom.get neurom.morphmath neurom.features neurom.features.population @@ -53,6 +55,7 @@ API Documentation neurom.core.soma neurom.core.dataformat neurom.io.utils + neurom.view neurom.view.dendrogram neurom.view.matplotlib_utils neurom.view.matplotlib_impl diff --git a/doc/source/morph_stats.rst b/doc/source/morph_stats.rst index 47917a43..28073def 100644 --- a/doc/source/morph_stats.rst +++ b/doc/source/morph_stats.rst @@ -86,8 +86,7 @@ Here, there are two feature categories, 2. ``neuron``: these are morphometrics that can be applied to a whole morphology, e.g. the soma radius, the trunk radii, etc. -Each category sub-item (section_lengths, soma_radius, etc) corresponds to a -:py:func:`neurom.get` feature, and each one of its sub-items corresponds to a statistic aggregating +Each category sub-item (section_lengths, soma_radius, etc) corresponds to a :py:func:`neurom.get` feature, and each one of its sub-items corresponds to a statistic aggregating function, e.g. * ``raw``: array of raw values diff --git a/doc/source/quickstart.rst b/doc/source/quickstart.rst index 1ac86515..40764e11 100644 --- a/doc/source/quickstart.rst +++ b/doc/source/quickstart.rst @@ -85,13 +85,13 @@ we apply a simple user defined function to the apical dendrites in a population: stuff = [x for x in nm.iter_neurites(pop, user_func, lambda n : n.type == nm.APICAL_DENDRITE)] -View morphologies with :mod:`neurom.viewer` +View morphologies with :mod:`neurom.view` ------------------------------------------- There are also helper functions to plot a morphology in 2 and 3 dimensions. -:func:`neurom.viewer.draw` function allows the user to make two and three-dimensional -plots of neurites, somata and morphologies. It also has a dendrogram morphology plotting mode. +:func:`neurom.view` function allows the user to make two and three-dimensional plots of neurites, somata and morphologies. +It also has a dendrogram morphology plotting mode. Extract morphometrics into JSON files diff --git a/neurom/features/__init__.py b/neurom/features/__init__.py index 87a67915..8269871a 100644 --- a/neurom/features/__init__.py +++ b/neurom/features/__init__.py @@ -37,7 +37,6 @@ >>> ax_sec_len = features.get('section_lengths', m, neurite_type=neurom.AXON) """ -import inspect import operator from enum import Enum from functools import partial, reduce, wraps diff --git a/neurom/morphmath.py b/neurom/morphmath.py index 513913d6..8139da12 100644 --- a/neurom/morphmath.py +++ b/neurom/morphmath.py @@ -120,7 +120,7 @@ def path_fraction_id_offset(points, fraction, relative_offset=False): Args: points: an iterable of indexable objects with indices - 0, 1, 2 correspoding to 3D cartesian coordinates + 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0.0 <= fraction <= 1.0) relative_offset: return absolute or relative segment distance @@ -236,7 +236,7 @@ def angle_3points(p0, p1, p2): Args: p0, p1, p2: indexable objects with - indices 0, 1, 2 corresponding to 3D cartesian coordinates. + indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: Angle in radians between (p1-p0) and (p2-p0). From 28587e3564dea887551730366e3ad5924beca8a2 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Tue, 28 May 2024 13:54:00 +0200 Subject: [PATCH 2/4] progress --- doc/source/conf.py | 7 +++++-- neurom/check/morphology_checks.py | 18 ++++++++---------- neurom/check/morphtree.py | 6 +++--- neurom/features/__init__.py | 8 ++++---- neurom/features/morphology.py | 6 +++--- neurom/features/population.py | 4 ++-- neurom/morphmath.py | 26 ++++++++++---------------- neurom/view/matplotlib_impl.py | 28 ++++++++++++++-------------- neurom/view/matplotlib_utils.py | 7 ++++--- 9 files changed, 53 insertions(+), 57 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 362abdb2..69023912 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -40,8 +40,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys -import os import importlib.metadata VERSION = importlib.metadata.version('neurom') @@ -63,6 +61,11 @@ 'sphinx.ext.doctest', ] +napoleon_type_aliases = { + "Number": "float|int", + #"floats": "", +} + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/neurom/check/morphology_checks.py b/neurom/check/morphology_checks.py index 0cdc9ef0..6f14c8ea 100644 --- a/neurom/check/morphology_checks.py +++ b/neurom/check/morphology_checks.py @@ -98,8 +98,8 @@ def has_no_flat_neurites(morph, tol=0.1, method='ratio'): Arguments: morph(Morphology): The morphology object to test tol(float): tolerance - method(string): way of determining flatness, 'tolerance', 'ratio' \ - as described in :meth:`neurom.check.morphtree.get_flat_neurites` + method(str): way of determining flatness, 'tolerance', 'ratio' + as described in :meth:`neurom.check.morphtree.get_flat_neurites` Returns: CheckResult with result @@ -184,8 +184,7 @@ def has_no_jumps(morph, max_distance=30.0, axis='z'): Arguments: morph(Morphology): the morphology to test - max_distance(float): value above which consecutive z-values are - considered a jump + max_distance(float): value above which consecutive z-values are considered a jump axis(str): one of x/y/z, which axis to check for jumps Returns: @@ -228,11 +227,11 @@ def has_no_fat_ends(morph, multiple_of_mean=2.0, final_point_count=5): Arguments: morph(Morphology): the morphology to test multiple_of_mean(float): how many times larger the final radius - has to be compared to the mean of the final points + has to be compared to the mean of the final points final_point_count(int): how many points to include in the mean Returns: - CheckResult with result list of ids of bad sections + CheckResult with a list of all ids of bad sections Note: A fat end is defined as a leaf segment whose last point is larger @@ -321,14 +320,13 @@ def has_no_narrow_neurite_section( Arguments: morph(Morphology): the morphology to test - neurite_filter(callable): filter the neurites by this callable + neurite_filter(Callable): filter the neurites by this callable radius_threshold(float): radii below this are considered narro considered_section_min_length(float): sections with length below - this are not taken into account + this are not taken into account Returns: - CheckResult with result. `result.info` contains the narrow section ids and their - first point + CheckResult with result. `result.info` contains the narrow section ids and their first point """ considered_sections = ( sec diff --git a/neurom/check/morphtree.py b/neurom/check/morphtree.py index fbb59141..f4efb604 100644 --- a/neurom/check/morphtree.py +++ b/neurom/check/morphtree.py @@ -68,7 +68,7 @@ def is_flat(neurite, tol, method='tolerance'): Args: neurite(Neurite): neurite to operate on tol(float): tolerance - method(string): the method of flatness estimation: + method(str): the method of flatness estimation: 'tolerance' returns true if any extent of the tree is smaller than the given tolerance 'ratio' returns true if the ratio of the smallest directions @@ -196,7 +196,7 @@ def is_back_tracking(neurite): neurite(Neurite): neurite to operate on Returns: - True Under the following scenaria: + bool: True when; 1. A segment endpoint falls back and overlaps with a previous segment's point 2. The geometry of a segment overlaps with a previous one in the section """ @@ -270,7 +270,7 @@ def get_flat_neurites(morph, tol=0.1, method='ratio'): Args: morph(Morphology): morphology to operate on tol(float): the tolerance or the ratio - method(string): 'tolerance' or 'ratio' described in :meth:`is_flat` + method(str): 'tolerance' or 'ratio' described in :meth:`is_flat` Returns: Bool list corresponding to the flatness check for each neurite diff --git a/neurom/features/__init__.py b/neurom/features/__init__.py index 8269871a..d2ea0186 100644 --- a/neurom/features/__init__.py +++ b/neurom/features/__init__.py @@ -173,12 +173,12 @@ def get(feature_name, obj, **kwargs): For Population features see :mod:`neurom.features.population`. Arguments: - feature_name(string): feature to extract + feature_name(str): feature to extract obj: a morphology, a morphology population or a neurite tree kwargs: parameters to forward to underlying worker functions Returns: - List|Number: feature value as a list or a single number. + List|float: feature value as a list or a single number. """ return _get_feature_value_and_func(feature_name, obj, **kwargs)[0] @@ -213,8 +213,8 @@ def feature(shape, namespace: NameSpace, name=None): Arguments: shape(tuple): the expected shape of the feature values - namespace(string): a namespace, see :class:`NameSpace` - name(string): name of the feature, used to access the feature via `neurom.features.get()`. + namespace(str): a namespace, see :class:`NameSpace` + name(str): name of the feature, used to access the feature via `neurom.features.get()`. """ def inner(func): diff --git a/neurom/features/morphology.py b/neurom/features/morphology.py index f7af9312..fe0e73ab 100644 --- a/neurom/features/morphology.py +++ b/neurom/features/morphology.py @@ -595,7 +595,7 @@ def sholl_crossings(morph, neurite_type=NeuriteType.all, center=None, radii=None morph(Morphology|list): morphology or a list of neurites neurite_type(NeuriteType): Type of neurite to use. By default ``NeuriteType.all`` is used. center(Point): center point, if None then soma center is taken - radii(iterable of floats): radii for which crossings will be counted, + radii: iterable of floats for which crossings will be counted, if None then soma radius is taken Returns: @@ -658,8 +658,8 @@ def sholl_frequency(morph, neurite_type=NeuriteType.all, step_size=10, bins=None morph(Morphology): a morphology neurite_type(NeuriteType): which neurites to operate on step_size(float): step size between Sholl radii - bins(iterable of floats): custom binning to use for the Sholl radii. If None, it uses - intervals of step_size between min and max radii of ``morphologies``. + bins: iterable of floats defining custom binning to use for the Sholl radii. + If None, it uses intervals of step_size between min and max radii of ``morphologies``. Note: Given a morphology, the soma center is used for the concentric circles, diff --git a/neurom/features/population.py b/neurom/features/population.py index edc18888..aa9279b5 100644 --- a/neurom/features/population.py +++ b/neurom/features/population.py @@ -63,8 +63,8 @@ def sholl_frequency(morphs, neurite_type=NeuriteType.all, step_size=10, bins=Non morphs(list|Population): list of morphologies or morphology population neurite_type(NeuriteType): which neurites to operate on step_size(float): step size between Sholl radii - bins(iterable of floats): custom binning to use for the Sholl radii. If None, it uses - intervals of step_size between min and max radii of ``morphs``. + bins(Iterable[float]: custom binning to use for the Sholl radii. + If None, it uses intervals of step_size between min and max radii of ``morphs``. use_subtrees (bool): Enable mixed subtree processing. Note: diff --git a/neurom/morphmath.py b/neurom/morphmath.py index 8139da12..807069d2 100644 --- a/neurom/morphmath.py +++ b/neurom/morphmath.py @@ -50,8 +50,7 @@ def vector(p1, p2): """Compute vector between two 3D points. Args: - p1, p2: indexable objects with - indices 0, 1, 2 corresponding to 3D cartesian coordinates. + p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: 3-vector from p1 - p2 @@ -149,7 +148,7 @@ def path_fraction_point(points, fraction): Args: points: an iterable of indexable objects with indices - 0, 1, 2 correspoding to 3D cartesian coordinates + 0, 1, 2 correspoding to 3D cartesian coordinates fraction: path length fraction (0 <= fraction <= 1) Returns: @@ -163,8 +162,7 @@ def scalar_projection(v1, v2): """Compute the scalar projection of v1 upon v2. Args: - v1, v2: iterable - indices 0, 1, 2 corresponding to cartesian coordinates + v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v @@ -176,8 +174,7 @@ def vector_projection(v1, v2): """Compute the vector projection of v1 upon v2. Args: - v1, v2: iterable - indices 0, 1, 2 corresponding to cartesian coordinates + v1, v2: iterable indices 0, 1, 2 corresponding to cartesian coordinates Returns: 3-vector of the projection of point p onto the direction of v @@ -206,8 +203,7 @@ def point_dist2(p1, p2): """Compute the square of the euclidian distance between two 3D points. Args: - p1, p2: indexable objects with - indices 0, 1, 2 corresponding to 3D cartesian coordinates. + p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: The square of the euclidian distance between the points. @@ -220,8 +216,7 @@ def point_dist(p1, p2): """Compute the euclidian distance between two 3D points. Args: - p1, p2: indexable objects with - indices 0, 1, 2 corresponding to 3D cartesian coordinates. + p1, p2: indexable objects with indices 0, 1, 2 corresponding to 3D cartesian coordinates. Returns: The euclidian distance between the points. @@ -392,9 +387,8 @@ def segment_radial_dist(seg, pos): Arguments: seg: tree segment - - pos: origin to which distances are measured. It must have at lease 3 - components. The first 3 components are (x, y, z). + pos: origin to which distances are measured. + It must have at lease 3 components. The first 3 components are (x, y, z). """ return point_dist(pos, np.divide(np.add(seg[0], seg[1]), 2.0)) @@ -475,10 +469,10 @@ def principal_direction_extent(points): directions of the covariance matrix of the points. Args: - points : a 2D numpy array of points with 2 or 3 columns for (x, y, z) + points: a 2D numpy array of points with 2 or 3 columns for (x, y, z) Returns: - extents : the extents for each of the eigenvectors of the cov matrix + the extents for each of the eigenvectors of the cov matrix Note: Direction extents are ordered from largest to smallest. diff --git a/neurom/view/matplotlib_impl.py b/neurom/view/matplotlib_impl.py index 200b9a8f..b9a51960 100644 --- a/neurom/view/matplotlib_impl.py +++ b/neurom/view/matplotlib_impl.py @@ -128,8 +128,8 @@ def plot_tree( """Plots a 2d figure of the tree's segments. Args: - tree(neurom.core.Section or neurom.core.Neurite): plotted tree - ax(matplotlib axes): on what to plot + tree(Section or Neurite): plotted tree + ax: on what matplotlib axes to plot plane(str): Any pair of 'xyz' diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None @@ -196,8 +196,8 @@ def plot_soma( """Generates a 2d figure of the soma. Args: - soma(neurom.core.Soma): plotted soma - ax(matplotlib axes): on what to plot + soma(Soma): plotted soma + ax: on what matplotlib axes to plot plane(str): Any pair of 'xyz' soma_outline(bool): should the soma be drawn as an outline linewidth(float): all segments are plotted with this width, but only if diameter_scale=None @@ -264,7 +264,7 @@ def plot_morph( Args: neurite_type(NeuriteType|tuple): an optional filter on the neurite type - ax(matplotlib axes): on what to plot + ax: on what matplotlib axes to plot morph(Morphology): morphology to be plotted soma_outline(bool): should the soma be drawn as an outline plane(str): Any pair of 'xyz' @@ -322,12 +322,12 @@ def plot_tree3d( ): """Generates a figure of the tree in 3d. - If the tree contains one single point the plot will be empty \ + If the tree contains one single point the plot will be empty since no segments can be constructed. Args: - tree(neurom.core.Section or neurom.core.Neurite): plotted tree - ax(matplotlib axes): on what to plot + tree(Section or Neurite): plotted tree + ax: on what matplotlib axes to plot diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None color(str or None): Color of plotted values, None corresponds to default choice @@ -352,8 +352,8 @@ def plot_soma3d(soma, ax=None, color=None, alpha=_ALPHA): """Generates a 3d figure of the soma. Args: - soma(neurom.core.Soma): plotted soma - ax(matplotlib axes): on what to plot + soma(Soma): plotted soma + ax: on what matplotlib axes to plot color(str or None): Color of plotted values, None corresponds to default choice alpha(float): Transparency of plotted values """ @@ -393,7 +393,7 @@ def plot_morph3d( Args: morph(Morphology): morphology to be plotted - ax(matplotlib axes): on what to plot + ax: on what matplotlib axes to plot neurite_type(NeuriteType): an optional filter on the neurite type diameter_scale(float): Scale factor multiplied with segment diameters before plotting linewidth(float): all segments are plotted with this width, but only if diameter_scale=None @@ -475,9 +475,9 @@ def plot_dendrogram(obj, ax=None, show_diameters=True): """Plots Dendrogram of `obj`. Args: - obj (neurom.Morphology, neurom.Section): morphology or section - ax: matplotlib axes - show_diameters (bool): whether to show node diameters or not + obj(Morphology, Section): morphology or section + ax: on what matplotlib axes to plot + show_diameters(bool): whether to show node diameters or not """ dendrogram = Dendrogram(obj) positions = layout_dendrogram(dendrogram, np.array([0, 0])) diff --git a/neurom/view/matplotlib_utils.py b/neurom/view/matplotlib_utils.py index 437e7268..af067258 100644 --- a/neurom/view/matplotlib_utils.py +++ b/neurom/view/matplotlib_utils.py @@ -312,7 +312,7 @@ def plot_ticks( Args: ax: matplotlib axes tick_fontsize (int): Defines the size of the ticks' font - xticks([list of ticks]): Defines the values of x ticks in the figure + xticks(1D array-like): Defines the values of x ticks in the figure xticks_args(dict): Passsed into matplotlib as xticks arguments yticks([list of ticks]): Defines the values of y ticks in the figure yticks_args(dict): Passsed into matplotlib as yticks arguments @@ -421,8 +421,8 @@ def project_cylinder_onto_2d( Args: ax: matplotlib axes plane(tuple of int): where x, y, z = 0, 1, 2, so (0, 1) is the xy axis - start(np.array): start coordinates - end(np.array): end coordinates + start(list of float): start coordinates + end(list of float): end coordinates start_radius(float): start radius end_radius(float): end radius color: matplotlib color @@ -432,6 +432,7 @@ def project_cylinder_onto_2d( 3d outline is calculated, the non-used plane coordinates are dropped, a tight convex hull is found, and that is used for a filled polygon """ + start, end = np.asarray(start), np.asarray(end) points = generate_cylindrical_points(start, end, start_radius, end_radius, 10) points = np.vstack([points[plane[0]].ravel(), points[plane[1]].ravel()]) points = points.T From c3ff5c37f1a9bcb86aa49176799ab27c3393a0e2 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Tue, 28 May 2024 15:24:45 +0200 Subject: [PATCH 3/4] clean of doc warnings --- CHANGELOG.rst | 7 +++---- doc/source/conf.py | 13 ++++++++----- doc/source/morph_stats.rst | 6 +++--- neurom/core/population.py | 2 +- neurom/core/types.py | 3 +-- neurom/features/neurite.py | 3 +-- neurom/view/dendrogram.py | 8 ++++---- neurom/view/matplotlib_utils.py | 14 +++++++------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d7e606ff..83eb12e9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -145,8 +145,8 @@ Version 2.3.1 Version 2.3.0 ------------- -- Introduce a new method to calculate partition asymmetry by Uylings. See docstring of - :func:`neurom.features.neuritefunc.partition_asymmetries`. +- Introduce a new method to calculate partition asymmetry by Uylings. + See docstring of `neurom.features.neuritefunc.partition_asymmetries`. - Follow the same morphology validation rules as in MorphIO. See the :ref:`doc page` about it. - Remove the cli command ``neurom features`` that listed all possible features. Instead a proper @@ -161,8 +161,7 @@ Version 2.2.1 Version 2.2.0 ------------- - Don't force loading of neurons into memory for Population (#922). See new API of - :class:`Population` and - :func:`load_neurons` + :class:`Population` and `load_neurons` - Move ``total_length`` feature to from ``neuritefunc`` to ``neuronfunc``. Use ``neurite_lengths`` feature for neurites - Include morphology filename extension into Neuron's name diff --git a/doc/source/conf.py b/doc/source/conf.py index 69023912..22280e61 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -61,11 +61,14 @@ 'sphinx.ext.doctest', ] -napoleon_type_aliases = { - "Number": "float|int", - #"floats": "", -} - +nitpicky = True +nitpick_ignore = [ + ("py:class", "Path"), + ("py:class", "morphio.Morphology"), + ("py:class", "morphio.mut.Morphology"), + ("py:class", "morphio.Section"), + ("py:class", "morphio.Soma"), +] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/source/morph_stats.rst b/doc/source/morph_stats.rst index 28073def..5bbed3ad 100644 --- a/doc/source/morph_stats.rst +++ b/doc/source/morph_stats.rst @@ -139,9 +139,9 @@ The new format: - requires to use ``sum`` instead of ``total`` statistic aggregating function. - allows to specify features arguments. -For example, ``partition_asymmetry`` feature has additional arguments like ``method`` and -``variant`` (see :py:func:`neurom.features.neurite.partition_asymmetries`). Before it wasn't -possible to set them. Here is how you can set them now: +For example, ``partition_asymmetry`` feature has additional arguments like ``method`` and ``variant``. +Before it wasn't possible to set them. +Here is how you can set them now: .. code-block:: yaml diff --git a/neurom/core/population.py b/neurom/core/population.py index f85d4a0c..e2f0fa55 100644 --- a/neurom/core/population.py +++ b/neurom/core/population.py @@ -64,7 +64,7 @@ def __init__( """Construct a morphology population. Arguments: - files (collections.abc.Sequence[str|Path|Morphology]): collection of morphology files or + files (Sequence[str|Morphology|Path]): collection of morphology files or paths to them or instances of ``Morphology``. name (str): Optional name for this Population ignored_exceptions (tuple): NeuroM and MorphIO exceptions that you want to ignore when diff --git a/neurom/core/types.py b/neurom/core/types.py index d5387460..c2496365 100644 --- a/neurom/core/types.py +++ b/neurom/core/types.py @@ -184,8 +184,7 @@ def tree_type_checker(*ref): """Tree type checker functor. Args: - *ref(NeuriteType|tuple): Either a single NeuriteType or a variable list of them or a tuple - of them. + *ref(NeuriteType|tuple): Either a single NeuriteType, list of them or a tuple of them. Returns: Functor that takes a tree, and returns true if that tree matches any of diff --git a/neurom/features/neurite.py b/neurom/features/neurite.py index 1875105a..2a74cede 100644 --- a/neurom/features/neurite.py +++ b/neurom/features/neurite.py @@ -317,8 +317,7 @@ def partition_asymmetry( Variant: length is a different definition, as the absolute difference in downstream path lenghts, relative to the total neurite path length - Method: 'petilla' or 'uylings'. The former is default. The latter uses ``-2`` shift. See - :func:`neurom.features.bifurcationfunc.partition_asymmetry` + Method: 'petilla' or 'uylings'. The former is default. The latter uses ``-2`` shift. """ if variant not in {'branch-order', 'length'}: raise ValueError( diff --git a/neurom/view/dendrogram.py b/neurom/view/dendrogram.py index 7a32d49c..6ba11394 100644 --- a/neurom/view/dendrogram.py +++ b/neurom/view/dendrogram.py @@ -90,7 +90,7 @@ def layout_dendrogram(dendrogram, origin): Args: dendrogram (Dendrogram): dendrogram - origin (np.array): xy coordinates of layout origin + origin: np.array xy coordinates of layout origin Returns: Dict of positions per each dendrogram node. When placed in those positions, dendrogram nodes @@ -138,7 +138,7 @@ def get_size(positions): """Get the size of bounding rectangle that embodies positions. Args: - positions (dict of Dendrogram: np.array): positions xy coordinates of dendrograms + positions: dict of Dendrogram: np.array positions xy coordinates of dendrograms Returns: Tuple of width and height of bounding rectangle. @@ -154,8 +154,8 @@ def move_positions(positions, to_origin): """Move positions to a new origin. Args: - positions (dict of Dendrogram: np.array): positions - to_origin (np.array): where to move. np.array of (2,) shape for x,y coordindates. + positions: positions (dict of Dendrogram: np.array) + to_origin: where to move. np.array of (2,) shape for x,y coordindates. Returns: Moved positions. diff --git a/neurom/view/matplotlib_utils.py b/neurom/view/matplotlib_utils.py index af067258..45851e32 100644 --- a/neurom/view/matplotlib_utils.py +++ b/neurom/view/matplotlib_utils.py @@ -184,7 +184,7 @@ def plot_style( """Set the basic options of a matplotlib figure, to be used by viewing - plotting functions. Args: - fig(matplotlib figure): figure + fig: matplotlib figure ax(matplotlib axes, belonging to `fig`): axes pretitle(str): String to include before the general title of the figure @@ -202,11 +202,11 @@ def plot_style( zlabel_arg(dict): Passsed into matplotlib as zlabel arguments tick_fontsize (int): Defines the size of the ticks' font - xticks([list of ticks]): Defines the values of x ticks in the figure + xticks: Defines the values of x ticks in the figure (1D array-like) xticks_args(dict): Passsed into matplotlib as xticks arguments - yticks([list of ticks]): Defines the values of y ticks in the figure + yticks: Defines the values of y ticks in the figure( 1D array-like) yticks_args(dict): Passsed into matplotlib as yticks arguments - zticks([list of ticks]): Defines the values of z ticks in the figure + zticks: Defines the values of z ticks in the figure (1D array-like) zticks_args(dict): Passsed into matplotlib as zticks arguments white_space(float): whitespace added to surround the tight limit of the data @@ -312,11 +312,11 @@ def plot_ticks( Args: ax: matplotlib axes tick_fontsize (int): Defines the size of the ticks' font - xticks(1D array-like): Defines the values of x ticks in the figure + xticks: Defines the values of x ticks in the figure (1D array-like) xticks_args(dict): Passsed into matplotlib as xticks arguments - yticks([list of ticks]): Defines the values of y ticks in the figure + yticks: Defines the values of y ticks in the figure (1D array-like) yticks_args(dict): Passsed into matplotlib as yticks arguments - zticks([list of ticks]): Defines the values of z ticks in the figure + zticks: Defines the values of z ticks in the figure (1D array-like) zticks_args(dict): Passsed into matplotlib as zticks arguments """ if xticks is not None: From a1e2c3fd63788573180fb6dbfbbd885a7e7c283e Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Tue, 28 May 2024 15:33:52 +0200 Subject: [PATCH 4/4] fix pylints --- neurom/features/bifurcation.py | 8 ++++++++ neurom/features/population.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/neurom/features/bifurcation.py b/neurom/features/bifurcation.py index 3fadaf6b..e4ab796a 100644 --- a/neurom/features/bifurcation.py +++ b/neurom/features/bifurcation.py @@ -156,13 +156,17 @@ def sibling_ratio(bif_point, method='first'): if method not in {'first', 'mean'}: raise ValueError('Please provide a valid method for sibling ratio, found %s' % method) + n = m = 0 + if method == 'first': # the first point is the same as the parent last point n = bif_point.children[0].points[1, COLS.R] m = bif_point.children[1].points[1, COLS.R] + if method == 'mean': n = neurom.features.section.section_mean_radius(bif_point.children[0]) m = neurom.features.section.section_mean_radius(bif_point.children[1]) + return min(n, m) / max(n, m) @@ -181,15 +185,19 @@ def diameter_power_relation(bif_point, method='first'): if method not in {'first', 'mean'}: raise ValueError('Please provide a valid method for sibling ratio, found %s' % method) + d_child = d_child1 = d_child2 = 0 + if method == 'first': # the first point is the same as the parent last point d_child = bif_point.points[-1, COLS.R] d_child1 = bif_point.children[0].points[1, COLS.R] d_child2 = bif_point.children[1].points[1, COLS.R] + if method == 'mean': d_child = neurom.features.section.section_mean_radius(bif_point) d_child1 = neurom.features.section.section_mean_radius(bif_point.children[0]) d_child2 = neurom.features.section.section_mean_radius(bif_point.children[1]) + return (d_child / d_child1) ** (1.5) + (d_child / d_child2) ** (1.5) diff --git a/neurom/features/population.py b/neurom/features/population.py index aa9279b5..3e37277e 100644 --- a/neurom/features/population.py +++ b/neurom/features/population.py @@ -63,7 +63,7 @@ def sholl_frequency(morphs, neurite_type=NeuriteType.all, step_size=10, bins=Non morphs(list|Population): list of morphologies or morphology population neurite_type(NeuriteType): which neurites to operate on step_size(float): step size between Sholl radii - bins(Iterable[float]: custom binning to use for the Sholl radii. + bins(Iterable[float]): custom binning to use for the Sholl radii. If None, it uses intervals of step_size between min and max radii of ``morphs``. use_subtrees (bool): Enable mixed subtree processing.