-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_parameters_sptPALM_GUI.py
More file actions
656 lines (534 loc) · 30.9 KB
/
set_parameters_sptPALM_GUI.py
File metadata and controls
656 lines (534 loc) · 30.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This work is licensed under the CC BY 4.0 License.
You are free to share and adapt this work, even for commercial purposes,
as long as you provide appropriate credit to the original creator.
Original Creator: Johannes Hohlbein (Wageningen University & Research)
Date of Creation: September, 2024
Full license details can be found at https://creativecommons.org/licenses/by/4.0/
"""
import tkinter as tk
import os
from tkinter import filedialog
from set_parameters_sptPALM import set_parameters_sptPALM
from ast import literal_eval # Safely parse the string back to a list of lists
import pickle
import numpy as np
def set_parameters_sptPALM_GUI(para = None):
print("\nRun 'set_parameters_sptPALM_GUI.py'")
if not para:
print(" Run 'set_parameters_sptPALM.py'")
para = set_parameters_sptPALM()
# Function to create the GUI
def browse_directory():
dirname = filedialog.askdirectory()
if dirname:
data_dir_entry.delete(0, tk.END)
dirname = os.path.join(dirname, '')
data_dir_entry.insert(0, dirname)
def browse_files_csv():
files = filedialog.askopenfilenames(filetypes=[("CSV files", "*.csv")])
filenames = [os.path.basename(file) for file in files]
if filenames:
fn_locs_entry.delete(0, tk.END)
fn_locs_entry.insert(0, ', '.join(filenames))
def browse_files_tif():
files = filedialog.askopenfilenames(filetypes=[("TIF files", "*.tif")])
filenames = [os.path.basename(file) for file in files]
if filenames:
fn_proc_brightfield_entry.delete(0, tk.END)
fn_proc_brightfield_entry.insert(0, ', '.join(filenames))
def load_params(): #careful, we need to overwrite all default parameters
filename = filedialog.askopenfilename(
filetypes = [("pickle file", "*.pkl")],
title = "Select input_parameter.pkl file obtained from running 'set_parameters_sptPALM.py + GUI'")
if filename:
with open(filename, 'rb') as f:
new_para = pickle.load(f)
print("Input parameters loaded")
# Update the entries with the newly loaded parameters
data_dir_entry.delete(0, tk.END)
data_dir_entry.insert(0, new_para['data_dir'])
fn_locs_entry.delete(0, tk.END)
fn_locs_entry.insert(0, ', '.join(map(str, new_para['fn_locs'])))
fn_proc_brightfield_entry.delete(0, tk.END)
fn_proc_brightfield_entry.insert(0, ', '.join(map(str, new_para['fn_proc_brightfield'])))
condition_names_entry.delete(0, tk.END)
condition_names_entry.insert(0, ', '.join(map(str, new_para['condition_names'])))
condition_files_entry.delete(0, tk.END)
condition_files_entry.insert(0, ', '.join(map(str, new_para['condition_files'])))
# condition_to_select_MCDDA_entry.delete(0, tk.END)
# condition_to_select_MCDDA_entry.insert(0, new_para['condition_to_select_MCDDA'])
copynumber_intervals_entry.delete(0, tk.END)
copynumber_intervals_entry.insert(0, ', '.join(map(str, new_para['copynumber_intervals'])))
default_output_dir_entry.delete(0, tk.END)
default_output_dir_entry.insert(0, new_para['default_output_dir'])
fn_csv_handle_entry.delete(0, tk.END)
fn_csv_handle_entry.insert(0, new_para['fn_csv_handle'])
# fn_dict_handle_entry.delete(0, tk.END)
# fn_dict_handle_entry.insert(0, new_para['fn_dict_handle'])
# fn_diffs_handle_entry.delete(0, tk.END)
# fn_diffs_handle_entry.insert(0, new_para['fn_diffs_handle'])
fn_movies_entry.delete(0, tk.END)
fn_movies_entry.insert(0, new_para['fn_movies'])
fn_combined_movies_entry.delete(0, tk.END)
fn_combined_movies_entry.insert(0, new_para['fn_combined_movies'])
pixelsize_entry.delete(0, tk.END)
pixelsize_entry.insert(0, new_para['pixelsize'])
cellarea_min_entry.delete(0, tk.END)
cellarea_min_entry.insert(0, new_para['cellarea_pixels_min'])
cellarea_max_entry.delete(0, tk.END)
cellarea_max_entry.insert(0, new_para['cellarea_pixels_max'])
number_tracks_per_cell_min_entry.delete(0, tk.END)
number_tracks_per_cell_min_entry.insert(0, new_para['number_tracks_per_cell_min'])
number_tracks_per_cell_max_entry.delete(0, tk.END)
number_tracks_per_cell_max_entry.insert(0, new_para['number_tracks_per_cell_max'])
frametime_entry.delete(0, tk.END)
frametime_entry.insert(0, new_para['frametime'])
loc_error_entry.delete(0, tk.END)
loc_error_entry.insert(0, new_para['loc_error'])
track_steplength_entry.delete(0, tk.END)
track_steplength_entry.insert(0, new_para['track_steplength_max'])
track_memory_entry.delete(0, tk.END)
track_memory_entry.insert(0, new_para['track_memory'])
diff_avg_steps_min_entry.delete(0, tk.END)
diff_avg_steps_min_entry.insert(0, new_para['diff_avg_steps_min'])
diff_avg_steps_max_entry.delete(0, tk.END)
diff_avg_steps_max_entry.insert(0, new_para['diff_avg_steps_max'])
tracklength_locs_min_entry.delete(0, tk.END)
tracklength_locs_min_entry.insert(0, new_para['tracklength_locs_min'])
tracklength_locs_max_entry.delete(0, tk.END)
tracklength_locs_max_entry.insert(0, new_para['tracklength_locs_max'])
diff_hist_min_entry.delete(0, tk.END)
diff_hist_min_entry.insert(0, new_para['plot_diff_hist_min'])
diff_hist_max_entry.delete(0, tk.END)
diff_hist_max_entry.insert(0, new_para['plot_diff_hist_max'])
binwidth_entry.delete(0, tk.END)
binwidth_entry.insert(0, new_para['binwidth'])
plot_option_axes_var.set(new_para['plot_option_axes'])
plot_option_save_var.set(new_para['plot_option_save'])
fontsize_entry.delete(0, tk.END)
fontsize_entry.insert(0, new_para['fontsize'])
dpi_entry.delete(0, tk.END)
dpi_entry.insert(0, new_para['dpi'])
linewidth_entry.delete(0, tk.END)
linewidth_entry.insert(0, new_para['linewidth'])
use_segmentations_var.set(new_para['use_segmentations'])
plot_norm_histograms_var.set(new_para['plot_norm_histograms'])
use_plot_frame_number_var.set(new_para['plot_frame_number'])
scta_vis_cells_var.set(new_para['scta_vis_cells'])
scta_vis_interactive_var.set(new_para['scta_vis_interactive'])
cmap_applied_var.set(new_para['cmap_applied'])
scta_plot_cell_window_entry.delete(0, tk.END)
scta_plot_cell_window_entry.insert(0, new_para['scta_plot_cell_window'])
scta_vis_rangemax_entry.delete(0, tk.END)
scta_vis_rangemax_entry.insert(0, new_para['scta_vis_rangemax'])
else:
raise ValueError("No file selected!")
def exit_GUI():
para_function()
root.quit() # Exits the Tkinter event loop
root.destroy() # Destroys the Tkinter window
# Collect all parameters from the GUI
# required to fill in new variables into para after pressing "Save" or "Exit"
def para_function():
nonlocal para
para = {
# File and directory selection
'data_dir': data_dir_entry.get(),
'default_output_dir': default_output_dir_entry.get(),
'fn_locs': list(map(str.strip, fn_locs_entry.get().split(','))),
'fn_proc_brightfield': list(map(str.strip, fn_proc_brightfield_entry.get().split(','))),
'condition_names': list(map(str.strip, condition_names_entry.get().split(','))),
'condition_files': literal_eval(f'[{condition_files_entry.get()}]'), # Wrap with [] to make it a valid list of lists
'copynumber_intervals': literal_eval(f'[{copynumber_intervals_entry.get()}]'),
# 'condition_to_select_MCDDA': int(condition_to_select_MCDDA_entry.get()),
'fn_csv_handle': fn_csv_handle_entry.get(),
# 'fn_dict_handle': fn_dict_handle_entry.get(),
# 'fn_diffs_handle': fn_diffs_handle_entry.get(),
'fn_movies': fn_movies_entry.get(),
'fn_combined_movies': fn_combined_movies_entry.get(),
# Pixelsize and segmentation
'pixelsize': float(pixelsize_entry.get()),
'cellarea_pixels_min': int(cellarea_min_entry.get()),
'cellarea_pixels_max': int(cellarea_max_entry.get()),
'use_segmentations': bool(use_segmentations_var.get()),
'track_steplength_max': float(track_steplength_entry.get()),
'track_memory': int(track_memory_entry.get()),
'frametime': float(frametime_entry.get()),
'loc_error': float(loc_error_entry.get()),
'diff_avg_steps_min': int(diff_avg_steps_min_entry.get()),
'diff_avg_steps_max': int(diff_avg_steps_max_entry.get()),
'tracklength_locs_min': int(tracklength_locs_min_entry.get()),
'tracklength_locs_max': int(tracklength_locs_max_entry.get()),
'number_tracks_per_cell_min': int(number_tracks_per_cell_min_entry.get()),
'number_tracks_per_cell_max': int(number_tracks_per_cell_max_entry.get()),
'scta_vis_cells': bool(scta_vis_cells_var.get()),
'scta_plot_cell_window': int(scta_plot_cell_window_entry.get()),
'scta_vis_interactive': bool(scta_vis_interactive_var.get()),
'scta_vis_rangemax': float(scta_vis_rangemax_entry.get()),
'plot_diff_hist_min': float(diff_hist_min_entry.get()),
'plot_diff_hist_max': float(diff_hist_max_entry.get()),
'binwidth': float(binwidth_entry.get()),
'fontsize': int(fontsize_entry.get()),
'plot_option_axes': plot_option_axes_var.get(),# whether to plot D_histograms logarithmic or linear
'plot_option_save': plot_option_save_var.get(),# whether to save figs as png, pdf, svg
'linewidth': int(linewidth_entry.get()),
'plot_norm_histograms': plot_norm_histograms_var.get(),
'plot_frame_number': bool(use_plot_frame_number_var.get()),
'dpi': int(dpi_entry.get()),
'cmap_applied': cmap_applied_var.get()
}
para['tracklengths_steps'] = np.arange(para['tracklength_locs_min']-1,
para['tracklength_locs_max'])
def save_params():
# Get data from GUI
para_function()
# Ask the user where to save the file, default filename is input_parameter.pkl
save_file_path = filedialog.asksaveasfilename(
defaultextension=".pkl",
initialdir=para['data_dir'], # Set the initial directory if provided
filetypes=[("Pickle files", "*.pkl")],
initialfile="input_parameter.pkl",
title="Save input_parameter as"
)
if save_file_path: # If the user selects a file path
with open(save_file_path, 'wb') as file:
pickle.dump(para, file) # Save the dictionary to the file
print(f"input_parameter saved to {save_file_path}")
else:
print("Save operation canceled.")
root = tk.Tk()
root.title("SPT-PALM Parameter GUI (defaults imported from set_parameter_sptPALM.py)")
# Adjust the column configuration of the root window to split into two
root.grid_columnconfigure(0, weight=1) # First column gets full width (file_frame)
root.grid_columnconfigure(1, weight=1) # Second column (numeric_frame) gets half width
# Create two separate container frames for left and right columns
left_frame = tk.Frame(root)
left_frame.grid(row=1, column=0, padx=0, pady=0, sticky="nsew") # Left half
right_frame = tk.Frame(root)
right_frame.grid(row=1, column=1, padx=0, pady=0, sticky="nsew") # Right half
"""
# Frame for File Selection and Directory Input
"""
file_frame = tk.LabelFrame(root, text="File & directory selection", padx=10, pady=10)
file_frame.grid(row=0, column=0, padx=10, pady=10, sticky="ew", columnspan=2)
width_text_labels = 20
width_text_fileIO = 95
width_text_box = 8
row_index = 0;
# Data Directory
tk.Label(file_frame, text="Data directory", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
data_dir_entry = tk.Entry(file_frame, width=width_text_fileIO)
data_dir_entry.grid(row=row_index, column=1)
data_dir_entry.insert(0, para['data_dir'])
tk.Button(file_frame, text="Browse...", command=browse_directory).grid(row=row_index, column=2)
row_index+=1
# File Names for Localizations
tk.Label(file_frame, text="Localization file(s) (*.csv)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
fn_locs_entry = tk.Entry(file_frame, width=width_text_fileIO)
fn_locs_entry.grid(row=row_index, column=1)
fn_locs_entry.insert(0, ', '.join(map(str, para['fn_locs'])))
tk.Button(file_frame, text="Browse...", command=browse_files_csv).grid(row=row_index, column=2)
row_index+=1
# Brightfield Image Files
tk.Label(file_frame, text="Proc. brightf. file(s) (*.tiff)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
fn_proc_brightfield_entry = tk.Entry(file_frame, width=width_text_fileIO)
fn_proc_brightfield_entry.grid(row=row_index, column=1)
fn_proc_brightfield_entry.insert(0, ', '.join(map(str, para['fn_proc_brightfield'])))
tk.Button(file_frame, text="Browse...", command=browse_files_tif).grid(row=row_index, column=2)
row_index+=1
# Name of conditions
tk.Label(file_frame, text="Name(s) of conditions", width = width_text_labels,
anchor="w").grid(row=3, column=0, sticky=tk.W)
condition_names_entry = tk.Entry(file_frame, width=width_text_fileIO)
condition_names_entry.grid(row=3, column=1)
condition_names_entry.insert(0, ', '.join(map(str, para['condition_names'])))
row_index+=1
# Condition files
tk.Label(file_frame, text="Condition files, e.g., [0,1],[2,3]", width = width_text_labels,
anchor="w").grid(row=4, column=0, sticky=tk.W)
condition_files_entry = tk.Entry(file_frame, width=width_text_fileIO)
condition_files_entry.grid(row=4, column=1)
condition_files_entry.insert(0, ', '.join(map(str, para['condition_files'])))
row_index+=1
# Histogramming of diffusion coefficients per copynumber
tk.Label(file_frame, text="Copy number intervals", width = width_text_labels,
anchor="w").grid(row=5, column=0, sticky=tk.W)
copynumber_intervals_entry = tk.Entry(file_frame, width=width_text_fileIO)
copynumber_intervals_entry.grid(row=5, column=1)
copynumber_intervals_entry.insert(0, ', '.join(map(str, para['copynumber_intervals'])))
row_index+=1
# Handle: output directory
tk.Label(file_frame, text="Handle: output directory", width = width_text_labels,
anchor="w").grid(row=6, column=0, sticky=tk.W)
default_output_dir_entry = tk.Entry(file_frame, width=width_text_fileIO)
default_output_dir_entry.grid(row=6, column=1)
default_output_dir_entry.insert(0, para['default_output_dir'])
row_index+=1
# Handle: CSV File
tk.Label(file_frame, text="Handle: csv files", width = width_text_labels,
anchor="w").grid(row=7, column=0, sticky=tk.W)
fn_csv_handle_entry = tk.Entry(file_frame, width=width_text_fileIO)
fn_csv_handle_entry.grid(row=7, column=1)
fn_csv_handle_entry.insert(0, para['fn_csv_handle'])
# row_index+=1
# # Handle: fn_dict_handle
# tk.Label(file_frame, text="Handle: dictionary ", width = width_text_labels,
# anchor="w").grid(row=8, column=0, sticky=tk.W)
# fn_dict_handle_entry = tk.Entry(file_frame, width=width_text_fileIO)
# fn_dict_handle_entry.grid(row=8, column=1)
# fn_dict_handle_entry.insert(0, para['fn_dict_handle'])
# row_index+=1
# # Handle: fn_diffs_handle
# tk.Label(file_frame, text="Handle: diffusion coeff. ", width = width_text_labels,
# anchor="w").grid(row=9, column=0, sticky=tk.W)
# fn_diffs_handle_entry = tk.Entry(file_frame, width=width_text_fileIO)
# fn_diffs_handle_entry.grid(row=9, column=1)
# fn_diffs_handle_entry.insert(0, para['fn_diffs_handle'])
row_index+=1
# Handle: fn_movies
tk.Label(file_frame, text="Handle: movies", width = width_text_labels,
anchor="w").grid(row=10, column=0, sticky=tk.W)
fn_movies_entry = tk.Entry(file_frame, width=width_text_fileIO)
fn_movies_entry.grid(row=10, column=1)
fn_movies_entry.insert(0, para['fn_movies'])
row_index+=1
# Handle: fn_combined_movies
tk.Label(file_frame, text="Handle: combined-movies", width = width_text_labels,
anchor="w").grid(row=11, column=0, sticky=tk.W)
fn_combined_movies_entry = tk.Entry(file_frame, width=width_text_fileIO)
fn_combined_movies_entry.grid(row=11, column=1)
fn_combined_movies_entry.insert(0, para['fn_combined_movies'])
"""
# Frame for Segmentation inputs
"""
segmentation_frame = tk.LabelFrame(left_frame, text="Pixelsize and segmentation", padx=10, pady=10)
segmentation_frame.grid(row=1, column=0, padx=10, pady=10, sticky="new")
row_index = 0
# Pixelsize
tk.Label(segmentation_frame, text="Pixel size (µm)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
pixelsize_entry = tk.Entry(segmentation_frame, width=width_text_box)
pixelsize_entry.grid(row=row_index, column=1)
pixelsize_entry.insert(1, para['pixelsize'])
row_index+=1
# Use Segmentations
use_segmentations_var = tk.BooleanVar(value = para['use_segmentations'])
tk.Checkbutton(segmentation_frame, text="Use segmentations", variable=use_segmentations_var,
width = width_text_labels, anchor="w").grid(row=row_index, column=0, sticky=tk.W)
row_index+=1
# Cell area (min/max)
tk.Label(segmentation_frame, text="Min. cell area (pixels)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
cellarea_min_entry = tk.Entry(segmentation_frame, width=width_text_box)
cellarea_min_entry.grid(row=row_index, column=1)
cellarea_min_entry.insert(0, para['cellarea_pixels_min'])
tk.Label(segmentation_frame, text="Max. cell area (pixels)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
cellarea_max_entry = tk.Entry(segmentation_frame, width=width_text_box)
cellarea_max_entry.grid(row=row_index, column=3)
cellarea_max_entry.insert(0, para['cellarea_pixels_max'])
row_index+=1
# Minimum number tracks/cell
tk.Label(segmentation_frame, text="Min. number tracks/cell", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
number_tracks_per_cell_min_entry = tk.Entry(segmentation_frame, width=width_text_box)
number_tracks_per_cell_min_entry.grid(row=row_index, column=1)
number_tracks_per_cell_min_entry.insert(0, para['number_tracks_per_cell_min'])
# Maximum number tracks/cell
tk.Label(segmentation_frame, text="Max. number tracks/cell", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
number_tracks_per_cell_max_entry = tk.Entry(segmentation_frame, width=width_text_box)
number_tracks_per_cell_max_entry.grid(row=row_index, column=3)
number_tracks_per_cell_max_entry.insert(0, para['number_tracks_per_cell_max'])
"""
# Frame for Tracking inputs
"""
tracking_frame = tk.LabelFrame(left_frame, text="Tracking and diffusion analysis",
padx=10, pady=10)
tracking_frame.grid(row=2, column=0, padx=10, pady=10, sticky="new")
row_index = 0
# Frame time (sec)
tk.Label(tracking_frame, text="Frame time (sec)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
frametime_entry = tk.Entry(tracking_frame, width=width_text_box)
frametime_entry.grid(row=row_index, column=1)
frametime_entry.insert(0, para['frametime'])
# Localisation error
tk.Label(tracking_frame, text="Loc. error (µm)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
loc_error_entry = tk.Entry(tracking_frame, width=width_text_box)
loc_error_entry.grid(row=row_index, column=3)
loc_error_entry.insert(0, para['loc_error'])
row_index+=1
# Track steplength
tk.Label(tracking_frame, text="Max. steplength (µm)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
track_steplength_entry = tk.Entry(tracking_frame, width=width_text_box)
track_steplength_entry.grid(row=row_index, column=1)
track_steplength_entry.insert(0, para['track_steplength_max'])
# Track memory
tk.Label(tracking_frame, text="Track memory (frames)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
track_memory_entry = tk.Entry(tracking_frame, width=width_text_box)
track_memory_entry.grid(row=row_index, column=3)
track_memory_entry.insert(0, para['track_memory'])
row_index+=1
# Min locks per track
tk.Label(tracking_frame, text="Min. locs per track", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
tracklength_locs_min_entry = tk.Entry(tracking_frame, width=width_text_box)
tracklength_locs_min_entry.grid(row=row_index, column=1)
tracklength_locs_min_entry.insert(0, para['tracklength_locs_min'])
# Max locks per track
tk.Label(tracking_frame, text="Max. locs per track", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
tracklength_locs_max_entry = tk.Entry(tracking_frame, width=width_text_box)
tracklength_locs_max_entry.grid(row=row_index, column=3)
tracklength_locs_max_entry.insert(0, para['tracklength_locs_max'])
row_index+=1
# Minimum number of steps per track
tk.Label(tracking_frame, text="Min. steps (avg. Diff. calc)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
diff_avg_steps_min_entry = tk.Entry(tracking_frame, width=width_text_box)
diff_avg_steps_min_entry.grid(row=row_index, column=1)
diff_avg_steps_min_entry.insert(0, para['diff_avg_steps_min'])
# Maximum number of steps per track
tk.Label(tracking_frame, text="Max. steps (avg. Diff. calc)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
diff_avg_steps_max_entry = tk.Entry(tracking_frame, width=width_text_box)
diff_avg_steps_max_entry.grid(row=row_index, column=3)
diff_avg_steps_max_entry.insert(0, para['diff_avg_steps_max'])
"""
# Frame for plotting
"""
plotting_frame = tk.LabelFrame(right_frame, text="Plotting and data output", padx=10, pady=10)
plotting_frame.grid(row=1, column=1, padx=10, pady=10, sticky="new") # Right half
row_index = 0
# plot_diff_avg_min
tk.Label(plotting_frame, text="Diff. hist. min (µm^2/s)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
diff_hist_min_entry = tk.Entry(plotting_frame, width=width_text_box)
diff_hist_min_entry.grid(row=row_index, column=1)
diff_hist_min_entry.insert(0, para['plot_diff_hist_min'])
# plot_diff_hist_max
tk.Label(plotting_frame, text="Diff. avg. max (µm^2/s)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
diff_hist_max_entry = tk.Entry(plotting_frame, width=width_text_box)
diff_hist_max_entry.grid(row=row_index, column=3)
diff_hist_max_entry.insert(0, para['plot_diff_hist_max'])
row_index+=1
# Binwidth
tk.Label(plotting_frame, text="Binwith histograms", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
binwidth_entry = tk.Entry(plotting_frame, width=width_text_box)
binwidth_entry.grid(row=row_index, column=1)
binwidth_entry.insert(0, para['binwidth'])
# fontsize
tk.Label(plotting_frame, text="Font size (px)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
fontsize_entry = tk.Entry(plotting_frame, width=width_text_box)
fontsize_entry.grid(row=row_index, column=3)
fontsize_entry.insert(0, para['fontsize'])
row_index+=1
# dpi
tk.Label(plotting_frame, text="Resolution figures (dpi)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
dpi_entry = tk.Entry(plotting_frame, width=width_text_box)
dpi_entry.grid(row=row_index, column=1)
dpi_entry.insert(0, para['dpi'])
# linewidth
tk.Label(plotting_frame, text="Line width (px)", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
linewidth_entry = tk.Entry(plotting_frame, width=width_text_box)
linewidth_entry.grid(row=row_index, column=3)
linewidth_entry.insert(0, para['linewidth'])
row_index+=1
# Plot frame numbers next to tracks
use_plot_frame_number_var = tk.BooleanVar(value=para['plot_frame_number'])
tk.Checkbutton(plotting_frame, text="Plot frame_id next to tracks", variable=use_plot_frame_number_var,
width = width_text_labels, anchor="w").grid(row=row_index, column=0, sticky=tk.W)
row_index+=1
# Show individual cells
scta_vis_cells_var = tk.BooleanVar(value=para['scta_vis_cells'])
tk.Checkbutton(plotting_frame, text="Show individual cells", variable=scta_vis_cells_var,
width = width_text_labels, anchor="w").grid(row=row_index, column=0, sticky=tk.W)
# Cycle through cells
scta_vis_interactive_var = tk.BooleanVar(value=para['scta_vis_interactive'])
tk.Checkbutton(plotting_frame, text="Cycle through cells", variable=scta_vis_interactive_var,
width = width_text_labels, anchor="w").grid(row=row_index, column=2, sticky=tk.W)
row_index+=1
# Dropdown Menu for Colormap Selection
tk.Label(plotting_frame, text="Select color map", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
cmap_applied_var = tk.StringVar()
cmap_applied_var.set("gist_ncar") # Default option
cmap_applied_entry = tk.OptionMenu(plotting_frame, cmap_applied_var, "gist_ncar", "nipy_spectral", "tab20c")
cmap_applied_entry.config(width=width_text_box) # Adjust width as needed
cmap_applied_entry.grid(row=row_index, column=1, sticky=tk.W)
row_index+=1
# Dropdown Menu for plotting diffusion histogram selection
tk.Label(plotting_frame, text="Select plotting option", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
plot_norm_histograms_var = tk.StringVar()
plot_norm_histograms_var.set("probability") # Default option
plot_norm_histograms_entry = tk.OptionMenu(plotting_frame, plot_norm_histograms_var,
"probability", "counts")
plot_norm_histograms_entry.config(width=width_text_box) # Adjust width as needed
plot_norm_histograms_entry.grid(row=row_index, column=1, sticky=tk.W)
row_index+=1
# Dropdown Menu for plotting option selection
tk.Label(plotting_frame, text="Plot option Diff. (log or linear)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
plot_option_axes_var = tk.StringVar()
plot_option_axes_var.set(para['plot_option_axes']) # Default option
plot_option_axes_entry = tk.OptionMenu(plotting_frame, plot_option_axes_var, "linear", "logarithmic")
plot_option_axes_entry.config(width=width_text_box) # Adjust width as needed
plot_option_axes_entry.grid(row=row_index, column=1, sticky=tk.W)
row_index+=1
# Dropdown Menu for plotting option selection
tk.Label(plotting_frame, text="Plot option (log or linear)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
plot_option_save_var = tk.StringVar()
plot_option_save_var.set(para['plot_option_save']) # Default option
plot_option_save_entry = tk.OptionMenu(plotting_frame, plot_option_save_var, "png", "svg", "pdf")
plot_option_save_entry.grid(row=row_index, column=1, sticky=tk.W)
row_index+=1
# Radius in pixels for plotting individual cells and their tracks
tk.Label(plotting_frame, text="Radius plotting cells (px)", width = width_text_labels,
anchor="w").grid(row=row_index, column=0, sticky=tk.W)
scta_plot_cell_window_entry = tk.Entry(plotting_frame, width=width_text_box)
scta_plot_cell_window_entry.grid(row=row_index, column=1)
scta_plot_cell_window_entry.insert(0, para['scta_plot_cell_window'])
# Color-coding in the range of [0:plot_DiffHist_max)], default: 0.4
tk.Label(plotting_frame, text="Color-coding [0:D_max)]", width = width_text_labels,
anchor="w").grid(row=row_index, column=2, sticky=tk.W)
scta_vis_rangemax_entry = tk.Entry(plotting_frame, width=width_text_box)
scta_vis_rangemax_entry.grid(row=row_index, column=3)
scta_vis_rangemax_entry.insert(0, para['scta_vis_rangemax'])
# row_index+=1
# # Select condition to be transfered to MCDDA
# tk.Label(plotting_frame, text="Condition MCDDA", width = width_text_labels,
# anchor="w").grid(row=row_index, column=0, sticky=tk.W)
# condition_to_select_MCDDA_entry = tk.Entry(plotting_frame, width=width_text_box)
# condition_to_select_MCDDA_entry.grid(row=row_index, column=1)
# condition_to_select_MCDDA_entry.insert(0, para['condition_to_select_MCDDA'])
#############################
# Load, Save, and Exit buttons
#############################
button_frame = tk.Frame(right_frame)
button_frame.grid(row=4, column=1, pady=10)
tk.Button(button_frame, text="Load...",
command=load_params).grid(row=0, column=0, padx=5)
tk.Button(button_frame, text="Save...",
command=save_params).grid(row=0, column=1, padx=5)
tk.Button(button_frame, text="Exit",
command=exit_GUI).grid(row=0, column=4, padx=5)
root.mainloop()
# Return collected parameters after window closes
return para