Commit dd25545d authored by Martinez-Carvajal German's avatar Martinez-Carvajal German
Browse files

not very important,

eliminating unuseful lists
parent 8d4a90a9
......@@ -30,7 +30,7 @@ def sector_mask(shape,centre,radius,angle_range):
theta %= (2*np.pi)
# circular mask
circmask = r2 <= radius*radius
circmask = r2 < radius*radius
# angular mask
anglemask = theta <= (tmax-tmin)
......@@ -207,7 +207,7 @@ def extract_surface_voxels(image, phase1, file_name):
message = 'convolution (surface voxels extraction) succesful'
list_messages_out = add_message(message, list_messages_out, path_save, file_name)
# if after mean filter pixel values are still 1 then they are inner pixels
# if after mean filter pixel the value is still the same -> then they are inner pixels
print('# of inner pixels Phase 1 = {}'.format(np.count_nonzero(convolved==value)))
assert(np.count_nonzero(convolved==value)!=0), "Nummer of inner pixels = 0, bug in the extraction of surface voxels"
......@@ -218,7 +218,7 @@ def extract_surface_voxels(image, phase1, file_name):
# saving
surface = np.array(surface, dtype = np.uint8)*255
chdir(path_save)
tifffile.imsave('surface_pixels_of_{}.tif'.format(clean_name(file_name)),surface)
tifffile.imsave('surface_pixels_of_{}.tif'.format(sample_name),surface)
# saving last message
message = 'extraction of surface voxels succesful'
......@@ -255,11 +255,11 @@ def add_message(message, list_messages_output, path_save, file_name):
list_messages_output.append(message)
frame = pd.DataFrame({'Message': list_messages_output})
chdir(path_save)
name = 'messages_SSP_{}_SizeVS_{}_startVS_{}.csv'.format(clean_name(file_name), size_VS, start_VS)
name = 'messages_SSP_{}.csv'.format(sample_name)
frame.to_csv(name)
return(list_messages_output)
def compute_specific_surface_profile(start_VS, path_input, path_save, file_name, label_outside, p1, p2, size_VS, resolution, flag_relabel = False, flag_SV = True, file_SV= None):
def compute_specific_surface_profile(start_VS, path_input, path_save, file_name, sample_name, label_outside, p1, p2, size_VS, resolution, flag_relabel=False, flag_SV=True, file_SV=None):
"""
The computation works like this:
The file (i.e. the image (file_name)) may have different labels for different phases
......@@ -367,7 +367,7 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
Frame['F3'] = F3s
Frame['Sur_Vox'] = num_sur_voxs
Name = 'SS_Profile_of_{}_SizeVS_{}_vox_startVS_{}.csv'.format(clean_name(file_name),size_VS, start_VS)
Name = 'SS_Profile_of_{}.csv'.format(sample_name)
Frame.to_csv(Name, sep = ';')
plot_ssp(path_save, Name)
......@@ -377,23 +377,21 @@ def compute_specific_surface_profile(start_VS, path_input, path_save, file_name,
print('FINISHED')
def main():
global path_save, size_VS, start_VS
global path_save, size_VS, start_VS, sample_name
# Directory inputs
paths_input = []
paths_input.append('/home/german.martinez-carvajal/Desktop/These/Hashemi_segmentation/Tests/Test9_Rapide/Results/heavy_results')
# Directory input
path_input ='/home/german.martinez-carvajal/Desktop/These/Hashemi_segmentation/Tests/Test9_Rapide/Results/heavy_results'
# Directory outputs
paths_save = []
paths_save.append("/home/german.martinez-carvajal/Desktop/These/Specific_Surface_Profile/test")
path_save = "/home/german.martinez-carvajal/Desktop/These/Specific_Surface_Profile/test"
# Image Name
image_names = []
image_names.append("Hash_Segm_of_Image_Filtered_PVE_50_Tol_0.5_NumVS_1.tif")
file_name = "Hash_Segm_of_Image_Filtered_PVE_50_Tol_0.75_NumVS_1.tif"
sample_name = "MONxx"
# flag to reag SV file (surface voxels file) if already identified
# Important : surface pixels are labeled 255
flag_SV = True # True - Compute surface voxels /// False - read existing image with surface voxels
file_SV = "surface_pixels_of_Image_Filtered_PVE_50_Tol_0.5_NumVS_1.tif"
file_SV = ""
# Constant parameters
# Image resolution
......@@ -415,33 +413,24 @@ def main():
start_VS = 0
# cheking
assert len(paths_input) == len(image_names)
for i in range(len(image_names)):
path_input = paths_input[i]
path_save = paths_save[i]
image_name = image_names[i]
check_paths_and_files(path_input, path_save, image_name, file_SV, flag_SV)
check_paths_and_files(path_input, path_save, file_name, file_SV, flag_SV)
# running
for i in range(len(paths_input)):
path = paths_input[i]
path_save = paths_save[i]
file_name = image_names[i]
print('computing for file {}'.format(file_name))
params = []
params.append(start_VS)
params.append(path)
params.append(path_save)
params.append(file_name)
params.append(label_outside)
params.append(p1)
params.append(p2)
params.append(size_VS)
params.append(resolution)
params.append(flag_relabel)
params.append(flag_SV)
params.append(file_SV)
compute_specific_surface_profile(*params)
print('computing for file {}'.format(file_name))
params = []
params.append(start_VS)
params.append(path_input)
params.append(path_save)
params.append(file_name)
params.append(sample_name)
params.append(label_outside)
params.append(p1)
params.append(p2)
params.append(size_VS)
params.append(resolution)
params.append(flag_relabel)
params.append(flag_SV)
params.append(file_SV)
compute_specific_surface_profile(*params)
main()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment