Mentions légales du service

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

some modifs

parent 5a3fbfdc
No related branches found
No related tags found
No related merge requests found
......@@ -252,11 +252,11 @@ def __HysterisisImage__(image: array_t, low: float, high: float) -> array_t:
# high = 0.04
nonzero_sites = (image > 0).nonzero()
nonzero_values = image[nonzero_sites]
# print(nonzero_values.min(), image.max())
print(nonzero_values.min(), image.max())
low = low * nonzero_values.min()
high = high * image.max()
# print("low=", low, " high=", high)
print("low=", low, " high=", high)
# lowt = low*(x_image_f-min_image_f)+max_image_f
# hight = high*(max_image_f- min_image_f)+min_image_f
# lowt = (image_f >lowt).astype(int)
......
......@@ -106,6 +106,7 @@ def FindVoxelDimensionInMicron(data_path: str, size_voxel_in_micron: list = None
'''
#
if size_voxel_in_micron is not None:
print('VOXEL DIM: [X Y Z] =', size_voxel_in_micron, 'micron.')
return np_.array(size_voxel_in_micron)
else:
......@@ -131,7 +132,7 @@ def FindVoxelDimensionInMicron(data_path: str, size_voxel_in_micron: list = None
return voxel_size_micron
except:
print('/!\ Unable to find the voxel dimensions in micron in the metadata. Please specify it in the parameters.')
raise('/!\ 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, dimension: tuple = (0,), decimals: int = None) -> int:
......
......@@ -81,6 +81,7 @@ soma_high_c = None
soma_selem_micron_c = None
soma_min_area_c = None
soma_max_area_c = None
adapt_hist_equalization = None
ext_low_c = None
ext_high_c = None
ext_selem_micron_c = None
......@@ -132,7 +133,7 @@ image = in_.ImageVerification(image, channel)
# iv_.image_verification(image, channel) # -> PySide2 user interface # TODO: must return the modified image!
# /!\ conflicts between some versions of PySide2 and Python3
# image = image[:, 512:, 512:] # 512 # 562 # Just for development
image = image[:, :512, :512] # 512 # 562 # Just for development
img_shape = image.shape
#
......@@ -164,7 +165,7 @@ som_nfo["map_"] = soma_t.Map(image_for_soma, soma_low_c, soma_high_c, soma_selem
som_nfo["map_"], som_lmp_ = soma_t.FilteredMap_(som_nfo["map_"], soma_min_area_c) # Deletion of too small
som_nfo["map"], som_lmp = soma_t.FilteredMap(som_nfo["map_"], soma_max_area_c) # and too big somas
som_nfo["lmp"], n_somas = ms_.label(som_nfo["map"], return_num=True) # Labelling of somas
# po_.MaximumIntensityProjectionZ(som_nfo["lmp"])
po_.MaximumIntensityProjectionZ(som_nfo["lmp"])
# Use relabel instead of label to optimize the algorithm. But BUG.
# som_nfo["lmp"] = relabel_sequential(som_lmp)[0]
......@@ -204,14 +205,14 @@ if ext_selem_micron_c == 0:
else:
ext_selem_pixel_c = mp_.disk(in_.ToPixel(ext_selem_micron_c, size_voxel_in_micron))
scale_range_pixel = []
# scale_range_pixel = []
# #
# for value in scale_range:
# value_in_pixel = in_.ToPixel(value, size_voxel_in_micron, decimals=1)
# scale_range_pixel.append(value_in_pixel)
# scale_range = tuple(scale_range_pixel)
#
for value in scale_range:
value_in_pixel = in_.ToPixel(value, size_voxel_in_micron, decimals=1)
scale_range_pixel.append(value_in_pixel)
scale_range = tuple(scale_range_pixel)
#
scale_step = in_.ToPixel(scale_step, size_voxel_in_micron, decimals=1)
# scale_step = in_.ToPixel(scale_step, size_voxel_in_micron, decimals=1)
# Perform frangi feature enhancement (via python or c - faster - implementation)
enhanced_ext, ext_scales = extension_t.EnhancedForDetection(
......@@ -231,16 +232,22 @@ print(f"Elapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}\n")
# po_.MaximumIntensityProjectionZ(enhanced_ext, cmap="OrRd")
# Creation of the enhanced maps
enhanced_ext = ex_.adjust_log(enhanced_ext, 1) # Not necessary, log contrast adjustment
enhanced_ext = ex_.equalize_hist(enhanced_ext) # necessary, histogram equalisation (global)
# po_.MaximumIntensityProjectionZ(enhanced_ext, cmap="OrRd")
# enhanced_ext = ex_.adjust_log(enhanced_ext, 1) # Not necessary, log contrast adjustment
if adapt_hist_equalization:
enhanced_ext = ex_.equalize_adapthist(enhanced_ext) # necessary, histogram equalisation (global)
else:
enhanced_ext = ex_.equalize_hist(enhanced_ext) # necessary, histogram equalisation (global)
po_.MaximumIntensityProjectionZ(enhanced_ext, cmap="OrRd")
enhanced_ext = ex_.rescale_intensity(enhanced_ext, out_range=(0, 255)) # necessary, rescaling by stretching the values btw 0 and 255
ext_nfo["coarse_map"] = extension_t.CoarseMap(enhanced_ext, ext_low_c, ext_high_c, ext_selem_pixel_c) # seuillage
po_.MaximumIntensityProjectionZ(ext_nfo["coarse_map"])
ext_nfo["coarse_map"], ext_lmp = extension_t.FilteredCoarseMap(ext_nfo["coarse_map"], ext_min_area_c) # min
po_.MaximumIntensityProjectionZ(ext_nfo["coarse_map"])
ext_nfo["map"] = extension_t.FineMapFromCoarseMap(ext_nfo["coarse_map"]) # skeleton
# ext_nfo["map"] = extension_t.FilteredSkeletonMap(ext_nfo["coarse_map"], ext_max_length_c) # TODO delete too long extensions
# po_.MaximumIntensityProjectionZ(ext_nfo["map"])
po_.MaximumIntensityProjectionZ(ext_nfo["map"])
ext_nfo["map"][som_nfo["map"] > 0] = 0
po_.MaximumIntensityProjectionZ(ext_nfo["map"])
ext_nfo["lmp"], n_extensions = ms_.label(ext_nfo["map"], return_num=True)
# Use relabel instead of label to optimize the algorithm. BUT PROBLEM WITH THE NUMBER OF EXTENSIONS DETECTED !
# ext_nfo["lmp"] = relabel_sequential(ext_lmp)[0]
......@@ -258,8 +265,6 @@ print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}")
if with_plot:
fb_.PlotExtensions(extensions, ext_nfo, img_shape)
# Delete too big somas
# -- Preparation for Connections
dijkstra_costs = in_.DijkstraCosts(image, som_nfo["map"], ext_nfo["map"])
......
......@@ -49,8 +49,7 @@ parameter3 : None
; then your parameter has the value string: 'None', and not None
[Input]
data_path : D:\MorganeNadal\IBA1-Microglies\CHO_1H_D_1.70_3.3\CHO_1H_D_1.70_3.3_8.tif
# D:\MorganeNadal\IBA1-Microglies\standard conditions\020620_ST8_20W_1_2.lif - Position 3.tif
data_path : D:\MorganeNadal\IBA1-Microglies\standard conditions\020620_ST8_20W_1_2.lif - Position 3.tif
; direct data path to the image
file_path
# D:\\MorganeNadal\\IBA1-Microglies
......@@ -63,7 +62,7 @@ conditions
channel
; Can take the values R, G or B.
; Can also be set to None (cf. README above).
size_voxel_in_micron
size_voxel_in_micron : [0.071, 0.071, 0.4997]
; size_voxel_in_micron -> [X,Y,Z]
; Can also be set to None (cf. README above).
save_images
......@@ -79,6 +78,7 @@ soma_min_area_c : 58
soma_max_area_c : 580
[Extensions]
adapt_hist_equalization : True
; for hysteresis
ext_low_c : 10
#7.5e-8
......@@ -96,11 +96,11 @@ max_straight_sq_dist_c : 216.45
max_weighted_length_c : 4.81
[Frangi]
scale_range : (0.024,0.745)
; Stop at max 3.1 (<=> 0.745) for number of Z stacks < 18
scale_range : (0.1,6.1)
; Stop at max 3.1 for number of Z stacks < 18
; write min,max scale range
scale_step : 0.24
# 1.0
scale_step : 2.5
# 1.0 for Z stacks < 18
alpha : 0.8
# 0.8
beta : 0.5
......
......@@ -63,6 +63,7 @@ soma_min_area_c = IfNotFloat('Somas', 'soma_min_area_c')
soma_max_area_c = IfNotFloat('Somas', 'soma_max_area_c')
# [Extensions]
adapt_hist_equalization = parameters.getboolean('Extensions', 'adapt_hist_equalization')
ext_low_c = IfNotFloat('Extensions', 'ext_low_c')
ext_high_c = IfNotFloat('Extensions', 'ext_high_c')
ext_selem_micron_c = IfNotFloat('Extensions', 'ext_selem_micron_c')
......
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