Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3fbfbea8 authored by DEBREUVE Eric's avatar DEBREUVE Eric
Browse files

some refactoring

parent ccca34a1
No related branches found
No related tags found
No related merge requests found
...@@ -52,13 +52,13 @@ class extension_t(glial_cmp_t): ...@@ -52,13 +52,13 @@ class extension_t(glial_cmp_t):
# #
# soma_uid: connected to a soma somewhere upstream # 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): def __init__(self):
# #
super().__init__() super().__init__()
self.scales = None
self.end_points = None self.end_points = None
self.scales = None
self.soma_uid = None self.soma_uid = None
self.__cache__ = None self.__cache__ = None
...@@ -69,7 +69,7 @@ class extension_t(glial_cmp_t): ...@@ -69,7 +69,7 @@ class extension_t(glial_cmp_t):
bmp = lmp == uid bmp = lmp == uid
instance.InitializeFromMap(bmp, 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 end_point_lmp = end_point_map * lmp
instance.end_points = (end_point_lmp == uid).nonzero() instance.end_points = (end_point_lmp == uid).nonzero()
instance.scales = scales[instance.sites] instance.scales = scales[instance.sites]
......
...@@ -91,17 +91,3 @@ class glial_cmp_t: ...@@ -91,17 +91,3 @@ class glial_cmp_t:
def BackReferenceSoma(self, glial_cmp: glial_cmp_t) -> None: def BackReferenceSoma(self, glial_cmp: glial_cmp_t) -> None:
# #
raise NotImplementedError 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
...@@ -65,7 +65,7 @@ class soma_t(glial_cmp_t): ...@@ -65,7 +65,7 @@ class soma_t(glial_cmp_t):
bmp = lmp == uid bmp = lmp == uid
instance.InitializeFromMap(bmp, uid) instance.InitializeFromMap(bmp, uid)
contour_map = soma_t.ContourMap(bmp) contour_map = cls.ContourMap(bmp)
contour_lmp = contour_map * lmp contour_lmp = contour_map * lmp
instance.contour_points = tuple(zip(*(contour_lmp == uid).nonzero())) instance.contour_points = tuple(zip(*(contour_lmp == uid).nonzero()))
......
# 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
...@@ -39,9 +39,9 @@ ...@@ -39,9 +39,9 @@
import brick.component.connection as cn_ import brick.component.connection as cn_
import brick.component.extension as xt_ import brick.component.extension as xt_
import brick.component.glial_cmp as gl_
import brick.component.soma as sm_ import brick.component.soma as sm_
import brick.general.feedback as fb_ import brick.general.feedback as fb_
import brick.processing.normalization as nm_
# from main_prm import * # from main_prm import *
import os as os_ import os as os_
...@@ -98,8 +98,8 @@ img_shape = image.shape ...@@ -98,8 +98,8 @@ img_shape = image.shape
# #
print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}") print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}")
image_for_soma = gl_.NormalizedImage(image) image_for_soma = nm_.NormalizedImage(image)
image_for_ext = gl_.NormalizedImage(image) image_for_ext = nm_.NormalizedImage(image)
costs = 1.0 / (image + 1.0) 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}") print(f"NRM-IMG: t.{image_for_soma.dtype} m.{image_for_soma.min():.2f} M.{image_for_soma.max():.2f}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment