Mentions légales du service

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

corrected error in ToPixel

parent 78cca4dc
No related branches found
No related tags found
No related merge requests found
......@@ -132,17 +132,15 @@ def FindVoxelDimensionInMicron(data_path: str) -> array_t:
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:
# Conversion of pixels into micron. Used in morphomath (disk structuring element mp_.disk(n_pixel)).
# Assumes that the axes X and Y have the same ratio pixel:micron.
return round(micron/voxel_size_micron[0])
def ToPixel(micron: float, voxel_size_micron: array_t, dimension: int = 1, axis: int = 0) -> int:
# Conversion of pixels into micron.
return round(micron/(voxel_size_micron[axis]**dimension))
def ToMicron(pixel: int, voxel_size_micron: array_t) -> float:
def ToMicron(pixel: int, voxel_size_micron: array_t, dimension: int = 1, axis: int = 0) -> float:
# May not be used. if not used, delete.
# Conversion of micron into pixels.
# Assumes that the axes X and Y have the same ratio pixel:micron.
return float(pixel * voxel_size_micron[0])
return float(pixel * (voxel_size_micron[axis])**dimension)
def DijkstraCosts(image: array_t, som_map: array_t, ext_map: array_t) -> array_t:
......
......@@ -90,16 +90,17 @@ start_time = tm_.time()
# --- Images
# Find the dimension of the image voxels in micron
size_voxel_in_micron = in_.FindVoxelDimensionInMicron(data_path)
image = io_.imread(data_path)
# Image size verification - simple version without user interface
image = in_.ImageVerification(image, channel)
# iv_.image_verification(image, channel) # -> PySide2 interface # TODO: must return the modified image!
# /!\ conflicts between some versions of PySide2 and Python3
image = image[:, 512:, 512:] # 562
image = image[:, 512:, 512:] # 562 # Just for development
img_shape = image.shape
# pl_.matshow(image[image.shape[0] // 2, :, :])
# pl_.show()
......@@ -129,7 +130,7 @@ axes = {}
# --- Somas
print("\n--- Soma Detection")
soma_min_area_c = in_.ToPixel(soma_min_area_c, size_voxel_in_micron)
soma_min_area_c = in_.ToPixel(soma_min_area_c, size_voxel_in_micron, dimension=2)
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)
......@@ -155,7 +156,7 @@ if with_plot:
# -- Extentions
print("\n--- Extension Detection")
ext_min_area_c = in_.ToPixel(ext_min_area_c, size_voxel_in_micron)
ext_min_area_c = in_.ToPixel(ext_min_area_c, size_voxel_in_micron, dimension=2)
ext_selem_pixel_c = mp_.disk(in_.ToPixel(ext_selem_micron_c, size_voxel_in_micron))
......@@ -286,3 +287,5 @@ print(f"DONE: {tm_.strftime('%a, %b %d %Y @ %H:%M:%S')}")
if with_plot:
pl_.show()
# graph = skl_graph_t.FromSkeleton(soma_map) # Travailler apd squelettes (soma pas sous fore de sk)
\ No newline at end of file
......@@ -42,7 +42,7 @@ soma_low_c: 0.15
soma_high_c: 0.7126
soma_selem_micron_c: 0.24050024 * 2
# soma_selem_c = mp_.disk(2)
soma_min_area_c: 0.24050024 * 1000
soma_min_area_c: (0.24050024 ** 2) * 1000
;soma_min_area_c: 1000
[Extensions]
......@@ -52,7 +52,7 @@ ext_high_c: 0.6
# 0.04 # 0.6 # high_ext = 8.0e-3
ext_selem_micron_c: 0.24050024 * 1
# ext_selem_c = mp_.disk(1)
ext_min_area_c: 0.24050024 * 100
ext_min_area_c: (0.24050024 ** 2) * 100
;ext_min_area_c: 100 # pixels
[Connexions]
......
......@@ -37,19 +37,19 @@ with_plot = False
soma_low_c = 0.15
soma_high_c = 0.7126
ext_low_c = 3 #1e-7 ##0.2 # 0.02 # 0.2 # ext_low_c = 9.0e-4
ext_high_c = 1e-10 #1.2e-7 ##0.6 # 0.04 # 0.6 # high_ext = 8.0e-3
ext_low_c = 0.2 #3 #1e-7 ##0.2 # 0.02 # 0.2 # ext_low_c = 9.0e-4
ext_high_c = 0.6 #1e-10 #1.2e-7 ##0.6 # 0.04 # 0.6 # high_ext = 8.0e-3
# soma_selem_c = mp_.disk(2)
soma_selem_micron_c = 0.24050024 * 2
# ext_selem_c = mp_.disk(1)
soma_selem_micron_c = 0.24050024 * 2
ext_selem_micron_c = 0.24050024 * 1
max_straight_sq_dist_c = (30 ** 2) * 0.24050024
max_weighted_length_c = 20.0 * 0.24050024
soma_min_area_c = 1000 * 0.24050024
ext_min_area_c = 100 * 0.24050024
soma_min_area_c = 1000 * (0.24050024 ** 2)
ext_min_area_c = 100 * (0.24050024 ** 2)
# soma_min_area_c = 1000
# ext_min_area_c = 100
......
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