diff --git a/brick/component/extension.py b/brick/component/extension.py index 2141913b0a3e5691ffce4584aa4ec1c98905b43c..d8cb9f7c4d62fb1ecbf1053ea0151f3cb8e899dc 100644 --- a/brick/component/extension.py +++ b/brick/component/extension.py @@ -52,13 +52,13 @@ class extension_t(glial_cmp_t): # # soma_uid: connected to a soma somewhere upstream # - __slots__ = ("scales", "end_points", "soma_uid", "__cache__") + __slots__ = ("end_points", "scales", "soma_uid", "__cache__") def __init__(self): # super().__init__() - self.scales = None self.end_points = None + self.scales = None self.soma_uid = None self.__cache__ = None @@ -69,7 +69,7 @@ class extension_t(glial_cmp_t): bmp = lmp == uid instance.InitializeFromMap(bmp, uid) - end_point_map = extension_t.EndPointMap(bmp) + end_point_map = cls.EndPointMap(bmp) end_point_lmp = end_point_map * lmp instance.end_points = (end_point_lmp == uid).nonzero() instance.scales = scales[instance.sites] diff --git a/brick/component/glial_cmp.py b/brick/component/glial_cmp.py index be5fa89ad3a6ba638c681e2599e46ad49aba3c72..a4584e32fd131112361e1b8c99027ed09e05e3b3 100644 --- a/brick/component/glial_cmp.py +++ b/brick/component/glial_cmp.py @@ -91,17 +91,3 @@ class glial_cmp_t: def BackReferenceSoma(self, glial_cmp: glial_cmp_t) -> None: # raise NotImplementedError - - -def NormalizedImage(image: array_t) -> array_t: - # - print("This normalization does not bring anything; left as is for now to avoid the need for changing prms") - nonextreme_values = image[np_.logical_and(image > 0.0, image < image.max())] - - if nonextreme_values.size > 0: - nonextreme_avg = nonextreme_values.mean() - result = image.astype(np_.float32) / nonextreme_avg - else: - result = image.astype(np_.float32) - - return result diff --git a/brick/component/soma.py b/brick/component/soma.py index 3388dfbfae435d52406bdfbf6d1d00001c6bba66..e360bb40a0564b204528fe6154ec40892281bf1f 100644 --- a/brick/component/soma.py +++ b/brick/component/soma.py @@ -65,7 +65,7 @@ class soma_t(glial_cmp_t): bmp = lmp == uid instance.InitializeFromMap(bmp, uid) - contour_map = soma_t.ContourMap(bmp) + contour_map = cls.ContourMap(bmp) contour_lmp = contour_map * lmp instance.contour_points = tuple(zip(*(contour_lmp == uid).nonzero())) diff --git a/brick/processing/normalization.py b/brick/processing/normalization.py new file mode 100644 index 0000000000000000000000000000000000000000..eadf2f430369c9297780d37b337fa0b904ba310c --- /dev/null +++ b/brick/processing/normalization.py @@ -0,0 +1,48 @@ +# Copyright CNRS/Inria/UNS +# Contributor(s): Eric Debreuve (since 2019) +# +# eric.debreuve@cnrs.fr +# +# This software is governed by the CeCILL license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL +# license as circulated by CEA, CNRS and INRIA at the following URL +# "http://www.cecill.info". +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# In this respect, the user's attention is drawn to the risks associated +# with loading, using, modifying and/or developing or reproducing the +# software by the user in light of its specific status of free software, +# that may mean that it is complicated to manipulate, and that also +# therefore means that it is reserved for developers and experienced +# professionals having in-depth computer knowledge. Users are therefore +# encouraged to load and test the software's suitability as regards their +# requirements in conditions enabling the security of their systems and/or +# data to be ensured and, more generally, to use and operate it in the +# same conditions as regards security. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL license and that you accept its terms. + +from brick.general.type import array_t + +import numpy as np_ + + +def NormalizedImage(image: array_t) -> array_t: + # + print("This normalization does not bring anything; left as is for now to avoid the need for changing prms") + nonextreme_values = image[np_.logical_and(image > 0.0, image < image.max())] + + if nonextreme_values.size > 0: + nonextreme_avg = nonextreme_values.mean() + result = image.astype(np_.float32) / nonextreme_avg + else: + result = image.astype(np_.float32) + + return result diff --git a/nutrimorph.py b/nutrimorph.py index 6ae72b5df2b33e9e7a33ae0977ada10bc5fe80cd..d25ce7bcf289bda4be913a682e483fcf4eaf4eb7 100644 --- a/nutrimorph.py +++ b/nutrimorph.py @@ -39,9 +39,9 @@ import brick.component.connection as cn_ import brick.component.extension as xt_ -import brick.component.glial_cmp as gl_ import brick.component.soma as sm_ import brick.general.feedback as fb_ +import brick.processing.normalization as nm_ # from main_prm import * import os as os_ @@ -98,8 +98,8 @@ img_shape = image.shape # print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}") -image_for_soma = gl_.NormalizedImage(image) -image_for_ext = gl_.NormalizedImage(image) +image_for_soma = nm_.NormalizedImage(image) +image_for_ext = nm_.NormalizedImage(image) costs = 1.0 / (image + 1.0) print(f"NRM-IMG: t.{image_for_soma.dtype} m.{image_for_soma.min():.2f} M.{image_for_soma.max():.2f}")