Commit 1055c3dd authored by Félix Hartmann's avatar Félix Hartmann
Browse files

Cleaning, and a few comments.

parent d92cf181
......@@ -118,7 +118,7 @@ base_pts_out = None
base_dir_path = None
cur_image = None
cur_tige = None
toptige = None
toptige = None # top level window for the settings of an organ
add_tige = False
nbclick = 0
base_tiges = []
......@@ -267,7 +267,6 @@ def convert_pkl_to_hdf(pklfile, hdf5file, display_message=False, display_progres
if display_progress:
# On augmente la barre de progression du GUI
dstep = 1/float(Nimgs) * 100.
#print(dstep)
interekt.prog_bar.step(dstep)
interekt.prog_bar.update_idletasks()
interekt.master.update()
......@@ -509,7 +508,6 @@ def onChangeImage(event):
try:
sender = event.widget
idx = sender.curselection()
#print("idx %i"%idx)
interekt.plot_image(idx[0], keep_zoom=True)
except Exception as e:
print("Erreur de chargement !!!")
......@@ -570,6 +568,8 @@ def destroy_list_images():
def get_time_data():
"""Returns useful variables for plotting time series.
The time unit is chosen based on the total duration of the experiment.
Returns:
--------
- times: 1D array of photo times
......@@ -710,9 +710,7 @@ def _export_to_csv():
data_out = data_out.append(data_tmp, ignore_index=True)
#Add some usefull data
#Ntige = data_out.tige.unique()
output = []
#print Ntige
for tige, datatige in data_out.groupby('tige'):
# print(dataout.tige)
......@@ -897,7 +895,6 @@ def _export_meandata_for_each_tiges():
data_out = data_out.append(data_tmp, ignore_index=True)
#Loop over tiges
# Ntige = dataframe.tige.unique()
for tige, datatige in data_out.groupby('tige'):
#Compute dt (min)
if interekt.get_photo_datetime.get():
......@@ -1062,7 +1059,7 @@ def launch_process():
new_data_tige = {"Tiges_seuil_offset": Tiges_seuil_offset[i]}
h5store.save_tige_dict_to_hdf(hdf5file, hdf5_tigeid, new_data_tige)
except Exception as e:
print("La mise à jour des options a raté")
print("Failed to update options")
print(e)
if hdf5_tigeid in hdf_tiges_percent_diam:
......@@ -1079,7 +1076,7 @@ def launch_process():
new_data_tige = {'Tiges_percent_diam': Tiges_percent_diam[i]}
h5store.save_tige_dict_to_hdf(hdf5file, hdf5_tigeid, new_data_tige)
except Exception as e:
print("La mise à jour des options a raté")
print("Failed to update options")
print(e)
if Nimgs > 0:
......@@ -1100,8 +1097,6 @@ def launch_process():
output_function=none_print)
tiges_x = traite_tiges2(pre_data[0]['tiges_data'], pas=detection_step)[0]
#print(tiges_tailles/0.3)
#print(tiges_x.shape)
max_array_size = tiges_x.shape[2] + 100
print("Maximum size for iterations: %i" % max_array_size)
......@@ -1189,7 +1184,6 @@ def load_postprocessed_data(hdf5file, hdf_tige_id):
Voir la fonction Traite_data()
"""
print("Chargement des données de la tige %s depuis le fichier h5" % hdf_tige_id)
# Recuperation des données dont on a besoin
tige_x = h5store.get_postprocessing(hdf5file, 'smooth_xc', hdf_tige_id)
tige_y = h5store.get_postprocessing(hdf5file, 'smooth_yc', hdf_tige_id)
......@@ -1200,8 +1194,6 @@ def load_postprocessed_data(hdf5file, hdf_tige_id):
tige_measure_zone = h5store.get_postprocessing(hdf5file, 'angle_zone_de_mesure',
hdf_tige_id).tolist()
print("Chargement fini!")
# Masque les données invalide qui ont une valeur de -30000
badval = -30000
tige_x = ma.masked_equal(tige_x, badval)
......@@ -1329,14 +1321,14 @@ def save_tige_options():
#besoin de recup l'id de la tiges dans le fichier hdf5
h5store.save_tige_dict_to_hdf(hdf5file, hdf5_tigeid, new_data_tige)
except Exception as e:
print("La mise à jour des options a raté")
print("Failed to update options")
print(e)
# Rechargement des données des tiges a partir du hdf5
load_hdf5_tiges(hdf5file)
# Replot the main image
interekt.plot_image(cur_image, keep_zoom=False, force_clear=True)
interekt.plot_image(cur_image, keep_zoom=True, force_clear=True)
def show_tige_options():
......@@ -1618,8 +1610,7 @@ def show_heatmaps():
angles_i = angles[i, cutoff_left:imax-cutoff_right]
s_i = s[i, cutoff_left:imax-cutoff_right]
R_i = radii[i, cutoff_left:imax-cutoff_right]
C_i, smooth_angles_i = get_tige_curvature(angles_i, s_i,
smoothing=True, window_width=W)
C_i, d = get_tige_curvature(angles_i, s_i, smoothing=True, window_width=W)
smooth_s[i, :len(s_i)] = s_i
C[i, :len(C_i)] = C_i
R[i, :len(R_i)] = R_i
......@@ -2675,7 +2666,7 @@ def show_beta_tilde():
select_end.set_xdata((t2, t2))
fit_beta()
except:
print("Erreur dans l'initiation de l'ajustement.")
print("Error while initiating the fit for beta.")
print(t1, t2)
# Automatic setting of the boundaries for the fit
i2 = tip_angles.argmax() - 2
......@@ -2993,15 +2984,14 @@ def show_gamma_tilde():
i2 = -5
t1, t2 = times[i1], times[i2]
except:
print("""Échec de l'ajustement automatique.\nSélectionnez les bornes
manuellement.""")
print("""The automatic fitting failed.\nSelect the bounds manually.""")
t1, t2 = times[0], times[-1]
try:
select_start.set_xdata((t1, t1))
select_end.set_xdata((t2, t2))
fit_gamma()
except:
print("Erreur dans l'initiation de l'ajustement.")
print("Error when initiating the fit for beta.")
print(t1, t2)
# Taquets mobiles pour définir la plage de fit
......@@ -3237,9 +3227,8 @@ def show_B(tige_id=None):
def fit_angles(s_gz, log_angles):
min_func = lambda p, x, y: sum( sqrt( (x*p[0] - y)**2 ) )
min_func_exp = lambda p, x, y: sum( sqrt( (ma.exp(-x/p[0]) - y)**2 ) )
#p0 = signal.std()/s_gz[~signal.mask].std()
#print(p0)
#p0 = signal.std()/s_gz[~signal.mask].std()
# opt_params = fmin(min_func, [1.0],
# args=(s_gz[~log_angles.mask], log_angles[~log_angles.mask]))
......@@ -3481,7 +3470,7 @@ def pixel_calibration():
if scale_cmpix is not None:
cm_distance.insert(0, str('%0.4f'%scale_cmpix))
Label(calframe, text='pixel:').pack()
Label(calframe, text=_("pixels") + ':').pack()
pixel_distance.pack()
Label(calframe, text='cm:').pack()
cm_distance.pack()
......@@ -3906,6 +3895,15 @@ class Interekt:
#options_menu.add_checkbutton(label="Photos noires (<5Mo)", onvalue=True, offvalue=False, variable=check_black)
# options_menu.add_command(label="Test detection", command=test_detection) # TODO: BUG WITH THREAD
# Set the scale
options_menu.add_command(label=_("Scale"), command=pixel_calibration)
# Set the space step for skeleton detection process
self.detection_step = Tk.DoubleVar()
self.detection_step.set(DETECTION_STEP_DEFAULT)
options_menu.add_command(label=_("Step for skeleton detection"),
command=detection_step_setting)
# If we want to select an image as steady state
self.steady_state_image = None # number of the image at steady state
self.exclude_steady_state_from_time_series = Tk.BooleanVar()
......@@ -3914,14 +3912,6 @@ class Interekt:
label=_("Select steady-state image"),
command=select_steady_state_image)
# Set the scale
options_menu.add_command(label=_("Scale"), command=pixel_calibration)
# Set the space step for skeleton detection process
self.detection_step = Tk.DoubleVar()
self.detection_step.set(DETECTION_STEP_DEFAULT)
options_menu.add_command(label=_("Step for skeleton detection"), command=detection_step_setting)
#TODO: Pour trier ou non les photos
#sort_photo_num = Tk.BooleanVar()
#sort_photo_num.set(True)
......@@ -4130,7 +4120,7 @@ class Interekt:
def on_key_event(self, event):
global nbclick, add_tige, add_mark
print('you pressed %s'%event.key)
# print('you pressed %s'%event.key)
key_press_handler(event, self.canvas, self.toolbar)
if event.key == '+':
......@@ -4316,13 +4306,6 @@ class Interekt:
if line_type == "base" or line_type == "tige":
tige_id = int(label)
tige_hdf_id = get_hdf5_tigeid(hdf5file, tige_id)
try:
print(u'Selection de la tige %s' % tiges_names[tige_id])
print(u'Enregistrée dans le fichier hdf sous tige%i ' % tige_hdf_id)
print(u'Position dans la liste du gui %i' % tige_id)
except:
print(u'Selection de la tige %i du gui'%(tige_id))
print(u'Enregistrée sous le nom tige%i dans le fichier hdf' % tige_id_hdf)
if event.mouseevent.button == 1: # left click
if line_type == "tige":
......@@ -4430,6 +4413,7 @@ class Interekt:
# Remet l'id pour tk after a None
self.update_imgid = None
#global pour sauvegarde la résolution utilisée cela permet de faire
#suivre les xlims ylims de la figure correctement
used_scale = 1
......@@ -4583,7 +4567,6 @@ class Interekt:
self.ax.set_ylim(oldylims)
self.canvas.draw()
print(u'fin de mise à jour de la figure à la résolution %i' % image_resolution)
# Mise a jour de la memoire de la résolution utilisée
if img_num is not None:
......@@ -4634,8 +4617,6 @@ class Interekt:
"""
global btige_plt, btige_text, btige_arrow
print('plot base tige')
oldxlims = self.ax.get_xlim()
oldylims = self.ax.get_ylim()
......
......@@ -899,15 +899,15 @@ def get_tigesmanager(hdf5file):
# Creation du tiges manager
if Sshape == 0:
print('Pas de données pour les tiges')
# print('Pas de données pour les tiges')
output = None
else:
print(u'Création du tableau des tiges en mémoire')
# print(u'Création du tableau des tiges en mémoire')
output = TigesManager(len(tiges_ids), Nimg, Sshape)
#Ajout des données
for i, tid in enumerate(tiges_ids):
print("Chargement de la tige (gui: %i, h5: tige%i)" % (i, tid))
# print("Chargement de la tige (gui: %i, h5: tige%i)" % (i, tid))
for comp in ('xc', 'yc', 'theta', 'diam', 'xb1',
'yb1', 'xb2', 'yb2'):
# Test si il y a des données pour la tige
......@@ -916,13 +916,13 @@ def get_tigesmanager(hdf5file):
tmp = getattr(output, comp)
tmp[i, :, :] = f[h5_data_loc][:,:]
else:
print("Pas de données pour la tige (gui: %i, h5: tige%i)" % (i, tid))
print("No data for the organ (gui: %i, h5: tige%i)" % (i, tid))
output.Mask_invalid()
print("Fin du chargement")
# print("Fin du chargement")
else:
output = None
print('Pas de tiges dans le fichier hdf5')
# print('Pas de tiges dans le fichier hdf5')
return output
......
Supports Markdown
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