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

saving at any time

parent c663f82a
......@@ -27,7 +27,7 @@ def statistics(path_read, file, paht_save, sample_name):
print("extracting labels...")
labels = np.unique(image)
labels = labels[labels !=0]
print("{} labels where found !".format(len(labels)))
print("{} labels were found !".format(len(labels)))
# number of pores
num_pores = len(labels)
......@@ -35,50 +35,49 @@ def statistics(path_read, file, paht_save, sample_name):
# Variables
v = np.zeros(num_pores, dtype = int) # volume of pores
x0 = np.zeros(num_pores, dtype = int)
y0 = np.zeros(num_pores, dtype = int)
z0 = np.zeros(num_pores, dtype = int)
y0 = np.zeros(num_pores, dtype = int)
z0 = np.zeros(num_pores, dtype = int)
xf = np.zeros(num_pores, dtype = int)
yf = np.zeros(num_pores, dtype = int)
zf = np.zeros(num_pores, dtype = int)
yf = np.zeros(num_pores, dtype = int)
zf = np.zeros(num_pores, dtype = int)
print('computing ...')
for i in range(num_pores):
label = labels[i]
#print(label)
pore = (image == label)
v[i] = np.count_nonzero(pore)
#print("executing np.where...")
coords = np.where(image == label) # z, y, x
#print("computations...")
x0[i] = np.min(coords[2])
y0[i] = np.min(coords[1])
z0[i] = np.min(coords[0])
xf[i] = np.max(coords[2])
yf[i] = np.max(coords[1])
zf[i] = np.max(coords[0])
delta_x = xf - x0
delta_y = yf - y0
delta_z = zf - z0
connected_to_top = (z0 == 0)
my_data = dict()
frame = pd.DataFrame(my_data)
frame["Label"] = labels
frame["volume (vox)"] = v
frame["x0"] = x0
frame["xf"] = xf
frame["delta_x"] = delta_x
frame["y0"] = y0
frame["yf"] = yf
frame["delta_y"] = delta_y
frame["z0"] = z0
frame["zf"] = zf
frame["delta_z"] = delta_z
frame["connected to top"] = np.array(connected_to_top, dtype = np.int)
chdir(path_save)
frame.to_csv("statistics_CR_{}.csv".format(sample_name) ,sep = ';')
delta_x = xf - x0
delta_y = yf - y0
delta_z = zf - z0
connected_to_top = (z0 == 0)
#print("saving ..")
my_data = dict()
frame = pd.DataFrame(my_data)
frame["Label"] = labels
frame["volume (vox)"] = v
frame["x0"] = x0
frame["xf"] = xf
frame["delta_x"] = delta_x
frame["y0"] = y0
frame["yf"] = yf
frame["delta_y"] = delta_y
frame["z0"] = z0
frame["zf"] = zf
frame["delta_z"] = delta_z
frame["connected to top"] = np.array(connected_to_top, dtype = np.int)
chdir(path_save)
frame.to_csv("statistics_CR_{}.csv".format(sample_name) ,sep = ';')
print('finished treating sample {}'.format(sample_name))
path_read = '/home/german.martinez-carvajal/Desktop/These/Connecting_CR/test'
......
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