Mentions légales du service

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

dealt with parameters issues (pixel-micron + arguments in fct) + some refactoring

parent 110f487c
No related branches found
No related tags found
No related merge requests found
......@@ -46,10 +46,6 @@ import skimage.morphology as mp_
from scipy import ndimage as im_
ext_min_area_c = 100
ext_selem_micron_c = 0.24050024
class extension_t(glial_cmp_t):
#
# soma_uid: connected to a soma somewhere upstream
......@@ -86,7 +82,7 @@ class extension_t(glial_cmp_t):
@property
def end_points_as_array(self) -> array_t:
#
pty_name = extension_t.end_points_as_array.__name__
pty_name = 'end_points_as_array'
if pty_name not in self.__cache__:
self.__cache__[pty_name] = np_.array(self.end_points)
......@@ -176,17 +172,15 @@ class extension_t(glial_cmp_t):
return enhanced_img, scale_map
@staticmethod
def CoarseMap(image: array_t, low: float, high: float, voxel_micron: array_t, ext_selem_micron=ext_selem_micron_c) -> array_t:
def CoarseMap(image: array_t, low: float, high: float, selem: array_t) -> array_t:
#
result = __HysterisisImage__(image, low, high)
selem = mp_.disk(in_.ToPixel(ext_selem_micron, voxel_micron))
result = __MorphologicalCleaning__(result, selem)
return result
@staticmethod
def FilteredCoarseMap(map_: array_t) -> array_t:
def FilteredCoarseMap(map_: array_t, ext_min_area_c: int) -> array_t:
#
result = map_.copy()
lmp = ms_.label(map_)
......
......@@ -107,7 +107,7 @@ def FindVoxelDimensionInMicron(data_path: str) -> array_t:
return np_.array(size_voxel_in_micron)
else:
print('The size of a voxel is not specified in the parameters.')
print('/!\ The size of a voxel is not specified in the parameters.')
try:
with Image.open(data_path) as img: # Find the voxels dimensions in micron in the metadata.
......@@ -124,12 +124,12 @@ def FindVoxelDimensionInMicron(data_path: str) -> array_t:
voxel_size.append(re.findall(pattern, metadata)[0])
voxel_size = np_.array(list(map(float, voxel_size)))
voxel_size_micron = 1.0e6 * voxel_size
print('Voxel dimension in the image is [X Y Z] =', voxel_size_micron, 'in micron.')
voxel_size_micron = 1.0e6 * voxel_size # Conversion meters in micron
print('VOXEL DIM: [X Y Z] =', voxel_size_micron, 'micron.')
return voxel_size_micron
except:
print('Unable to find the voxel dimensions in micron in the metadata. Please specify it in the parameters.')
print('/!\ Unable to find the voxel dimensions in micron in the metadata. Please specify it in the parameters.')
def ToPixel(micron: float, voxel_size_micron: array_t) -> int:
......
......@@ -89,7 +89,7 @@ start_time = tm_.time()
# --- Images
voxel_micron = in_.FindVoxelDimensionInMicron(data_path)
size_voxel_in_micron = in_.FindVoxelDimensionInMicron(data_path)
image = io_.imread(data_path)
......@@ -128,7 +128,8 @@ axes = {}
# --- Somas
print("\n--- Soma Detection")
soma_selem_c = mp_.disk(in_.ToPixel(soma_selem_micron_c, voxel_micron))
soma_min_area_c = in_.ToPixel(soma_min_area_c, size_voxel_in_micron)
soma_selem_c = mp_.disk(in_.ToPixel(soma_selem_micron_c, size_voxel_in_micron))
som_nfo["map"] = soma_t.Map(image_for_soma, soma_low_c, soma_high_c, soma_selem_c)
som_nfo["map"], som_lmp = soma_t.FilteredMap(som_nfo["map"], soma_min_area_c)
......@@ -153,9 +154,13 @@ if with_plot:
# -- Extentions
print("\n--- Extension Detection")
ext_min_area_c = in_.ToPixel(ext_min_area_c, size_voxel_in_micron)
ext_selem_pixel_c = mp_.disk(in_.ToPixel(ext_selem_micron_c, size_voxel_in_micron))
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, voxel_micron)
ext_nfo["coarse_map"], ext_lmp = extension_t.FilteredCoarseMap(ext_nfo["coarse_map"])
ext_nfo["coarse_map"] = extension_t.CoarseMap(enhanced_ext, ext_low_c, ext_high_c, ext_selem_pixel_c)
ext_nfo["coarse_map"], ext_lmp = extension_t.FilteredCoarseMap(ext_nfo["coarse_map"], ext_min_area_c)
ext_nfo["map"] = extension_t.FineMapFromCoarseMap(ext_nfo["coarse_map"])
ext_nfo["map"][som_nfo["map"] > 0] = 0
# ext_nfo["lmp"], n_extensions = ms_.label(ext_nfo["map"], return_num=True)
......
......@@ -30,6 +30,7 @@
# knowledge of the CeCILL license and that you accept its terms.
# TODO: Use the .ini file instead of the .py file
[Input]
data_path: "./data/DIO_6H_6_1.70bis_2.2_3.tif"
channel: 'G'
......@@ -39,19 +40,20 @@ size_voxel_in_micron: None
[Somas]
soma_low_c: 0.15
soma_high_c: 0.7126
soma_selem_micron_c: 0.48100048
soma_selem_micron_c: 0.24050024 * 2
# soma_selem_c = mp_.disk(2)
soma_min_area_c: 1000
soma_min_area_c: 0.24050024 * 1000
;soma_min_area_c: 1000
[Extensions]
ext_low_c: 0.2
# 0.02 # 0.2 # ext_low_c = 9.0e-4
ext_high_c: 0.6
# 0.04 # 0.6 # high_ext = 8.0e-3
ext_selem_micron_c: 0.24050024
# ext_selem_c = mp_.disk(1) /!\ Not directly used in brick/component #TODO direct use of param ?
ext_min_area_c: 100
# /!\ Not directly used in brick/component #TODO direct use of param ?
ext_selem_micron_c: 0.24050024 * 1
# ext_selem_c = mp_.disk(1)
ext_min_area_c: 0.24050024 * 100
;ext_min_area_c: 100 # pixels
[Connexions]
max_straight_sq_dist_c: 30 ** 2
......
......@@ -33,7 +33,7 @@
data_path = "./data/DIO_6H_6_1.70bis_2.2_3.tif"
channel = 'G'
size_voxel_in_micron = None # -> list [X,Y,Z]
with_plot = True
with_plot = False
soma_low_c = 0.15
soma_high_c = 0.7126
......@@ -41,14 +41,16 @@ ext_low_c = 0.2 # 0.02 # 0.2 # ext_low_c = 9.0e-4
ext_high_c = 0.6 # 0.04 # 0.6 # high_ext = 8.0e-3
# soma_selem_c = mp_.disk(2)
soma_selem_micron_c = 0.48100048
soma_selem_micron_c = 0.24050024 * 2
# ext_selem_c = mp_.disk(1)
ext_selem_micron_c = 0.24050024 # /!\ Not directly used in brick/component #TODO direct use of param ?
ext_selem_micron_c = 0.24050024 * 1
max_straight_sq_dist_c = 30 ** 2
max_weighted_length_c = 20.0
soma_min_area_c = 1000
ext_min_area_c = 100 # /!\ Not directly used in brick/component #TODO direct use of param ?
soma_min_area_c = 1000 * 0.24050024
ext_min_area_c = 100 * 0.24050024
# soma_min_area_c = 1000
# ext_min_area_c = 100
in_parallel = False
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