Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 3ff4cecf authored by NADAL Morgane's avatar NADAL Morgane
Browse files

changed label into relabel + max - modified Filtered Maps

parent 7745e79b
No related branches found
No related tags found
No related merge requests found
...@@ -191,8 +191,9 @@ class extension_t(glial_cmp_t): ...@@ -191,8 +191,9 @@ class extension_t(glial_cmp_t):
if region.area <= min_area_c: if region.area <= min_area_c:
region_sites = (lmp == region.label).nonzero() region_sites = (lmp == region.label).nonzero()
result[region_sites] = 0 result[region_sites] = 0
lmp[region_sites] = 0
return result return result, lmp
@staticmethod @staticmethod
def FineMapFromCoarseMap(coarse_map: array_t) -> array_t: def FineMapFromCoarseMap(coarse_map: array_t) -> array_t:
......
...@@ -169,8 +169,9 @@ class soma_t(glial_cmp_t): ...@@ -169,8 +169,9 @@ class soma_t(glial_cmp_t):
if region.area <= min_area: if region.area <= min_area:
region_sites = (lmp == region.label).nonzero() region_sites = (lmp == region.label).nonzero()
result[region_sites] = 0 result[region_sites] = 0
lmp[region_sites] = 0
return result return result, lmp
@staticmethod @staticmethod
def ContourMap(map_: array_t) -> array_t: def ContourMap(map_: array_t) -> array_t:
......
...@@ -53,6 +53,7 @@ import matplotlib.pyplot as pl_ ...@@ -53,6 +53,7 @@ import matplotlib.pyplot as pl_
import numpy as np_ import numpy as np_
import skimage.io as io_ import skimage.io as io_
import skimage.measure as ms_ import skimage.measure as ms_
from skimage.segmentation import relabel_sequential
print(sy_.argv, sy_.argv.__len__()) print(sy_.argv, sy_.argv.__len__())
...@@ -81,7 +82,6 @@ exec(open(sy_.argv[1]).read()) ...@@ -81,7 +82,6 @@ exec(open(sy_.argv[1]).read())
soma_t = sm_.soma_t soma_t = sm_.soma_t
extension_t = xt_.extension_t extension_t = xt_.extension_t
print(f"STARTED: {tm_.strftime('%a, %b %d %Y @ %H:%M:%S')}") print(f"STARTED: {tm_.strftime('%a, %b %d %Y @ %H:%M:%S')}")
start_time = tm_.time() start_time = tm_.time()
...@@ -93,12 +93,12 @@ image = io_.imread(data_path) ...@@ -93,12 +93,12 @@ image = io_.imread(data_path)
# Image size verification - simple version without user interface # Image size verification - simple version without user interface
image = in_.ImageVerification(image, channel) image = in_.ImageVerification(image, channel)
# TODO make a user friendly interface (PySide2) BUT bug with the importation of Shiboken2 on Windows8.1 # TODO make a user friendly interface (PySide2) BUT bug with the importation of Shiboken2 on Windows8.1.
image = image[:, 512:, 512:] # 562 image = image[:, 512:, 512:] # 562
img_shape = image.shape img_shape = image.shape
pl_.matshow(image[image.shape[0] // 2,:,:]) # pl_.matshow(image[image.shape[0] // 2, :, :])
pl_.show() # pl_.show()
# #
# max_img = image.max() # max_img = image.max()
# image.fill(image.min()) # image.fill(image.min())
...@@ -110,7 +110,6 @@ image_for_soma = in_.NormalizedImage(image) ...@@ -110,7 +110,6 @@ image_for_soma = in_.NormalizedImage(image)
image_for_ext = in_.NormalizedImage(image) image_for_ext = in_.NormalizedImage(image)
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}")
# --- Initialization # --- Initialization
som_nfo = {} som_nfo = {}
ext_nfo = {} ext_nfo = {}
...@@ -126,9 +125,11 @@ axes = {} ...@@ -126,9 +125,11 @@ axes = {}
print("\n--- Soma Detection") print("\n--- Soma Detection")
som_nfo["map"] = soma_t.Map(image_for_soma, soma_low_c, soma_high_c, soma_selem_c) som_nfo["map"] = soma_t.Map(image_for_soma, soma_low_c, soma_high_c, soma_selem_c)
som_nfo["map"] = soma_t.FilteredMap(som_nfo["map"], min_area_c) som_nfo["map"], som_lmp = soma_t.FilteredMap(som_nfo["map"], min_area_c)
#TODO: change label into relabel + max # som_nfo["lmp"], n_somas= ms_.label(som_nfo["map"], return_num=True)
som_nfo["lmp"], n_somas = ms_.label(som_nfo["map"], return_num=True) som_nfo["lmp"] = relabel_sequential(som_lmp)[0] # Use relabel instead of label to optimize the algorithm.
n_somas = som_nfo["lmp"].max()
som_nfo["dist_to_closest"], som_nfo["influence_map"] = soma_t.InfluenceMaps( som_nfo["dist_to_closest"], som_nfo["influence_map"] = soma_t.InfluenceMaps(
som_nfo["lmp"] som_nfo["lmp"]
) )
...@@ -143,16 +144,17 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}") ...@@ -143,16 +144,17 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}")
if with_plot: if with_plot:
fb_.PlotSomas(somas, som_nfo, axes) fb_.PlotSomas(somas, som_nfo, axes)
# -- Extentions # -- Extentions
print("\n--- Extension Detection") print("\n--- Extension Detection")
enhanced_ext, ext_scales = extension_t.EnhancedForDetection(image_for_ext, in_parallel=in_parallel) enhanced_ext, ext_scales = extension_t.EnhancedForDetection(image_for_ext, in_parallel=in_parallel)
ext_nfo["coarse_map"] = extension_t.CoarseMap(enhanced_ext, ext_low_c, ext_high_c) ext_nfo["coarse_map"] = extension_t.CoarseMap(enhanced_ext, ext_low_c, ext_high_c)
ext_nfo["coarse_map"] = extension_t.FilteredCoarseMap(ext_nfo["coarse_map"]) ext_nfo["coarse_map"], ext_lmp = extension_t.FilteredCoarseMap(ext_nfo["coarse_map"])
ext_nfo["map"] = extension_t.FineMapFromCoarseMap(ext_nfo["coarse_map"]) ext_nfo["map"] = extension_t.FineMapFromCoarseMap(ext_nfo["coarse_map"])
ext_nfo["map"][som_nfo["map"] > 0] = 0 ext_nfo["map"][som_nfo["map"] > 0] = 0
ext_nfo["lmp"], n_extensions = ms_.label(ext_nfo["map"], return_num=True) # ext_nfo["lmp"], n_extensions = ms_.label(ext_nfo["map"], return_num=True)
ext_nfo["lmp"] = relabel_sequential(ext_lmp)[0] # Use relabel instead of label to optimize the algorithm.
n_extensions = ext_nfo["lmp"].max()
extensions = tuple( extensions = tuple(
extension_t().FromMap(ext_nfo["lmp"], ext_scales, uid) extension_t().FromMap(ext_nfo["lmp"], ext_scales, uid)
...@@ -165,11 +167,9 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}") ...@@ -165,11 +167,9 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}")
if with_plot: if with_plot:
fb_.PlotExtensions(extensions, ext_nfo, img_shape) fb_.PlotExtensions(extensions, ext_nfo, img_shape)
# -- Preparation for Connections # -- Preparation for Connections
dijkstra_costs = in_.DijkstraCosts(image, som_nfo["map"], ext_nfo["map"]) dijkstra_costs = in_.DijkstraCosts(image, som_nfo["map"], ext_nfo["map"])
# -- Soma-Extention # -- Soma-Extention
print("\n--- Soma <-> Extension") print("\n--- Soma <-> Extension")
...@@ -205,7 +205,6 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}") ...@@ -205,7 +205,6 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}")
if with_plot: if with_plot:
fb_.PlotSomasWithExtensions(somas, som_nfo, "all") fb_.PlotSomasWithExtensions(somas, som_nfo, "all")
# -- Extention-Extention # -- Extention-Extention
print("\n--- Extension <-> Extension") print("\n--- Extension <-> Extension")
...@@ -248,7 +247,6 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}") ...@@ -248,7 +247,6 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}")
if with_plot: if with_plot:
fb_.PlotSomasWithExtensions(somas, som_nfo, "with_ext_of_ext") fb_.PlotSomasWithExtensions(somas, som_nfo, "with_ext_of_ext")
# -- Summary # -- Summary
print("\n") print("\n")
for soma in somas: for soma in somas:
......
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