Commit b28c3916 authored by Wallenfang, Nils's avatar Wallenfang, Nils

Merge branch 'config_and_refactoring'

parents ec99d172 4c8897ed
......@@ -23,21 +23,8 @@ class PreviewOptions(tkinter.LabelFrame):
# add the state variable to master frame for ease of access
master.preview_state = tkinter.IntVar()
master.preview_state.set(config.getboolean('GUI', 'state_create_preview'))
master.mark_outliers_state = tkinter.IntVar()
master.mark_outliers_state.set(0)
def clicked_chkbox_generate_preview():
# mark preview checkbox should only be enabled (tkinter.NORMAL) if generate preview checkbox is enabled.
if master.preview_state.get() == 0:
# disable and uncheck mark preview checkbox
master.mark_outliers_state.set(0)
self.chk_mark_outliers.config(state=tkinter.DISABLED)
else:
self.chk_mark_outliers.config(state=tkinter.NORMAL)
self.chk_preview = tkinter.Checkbutton(self, command=clicked_chkbox_generate_preview,
text=' Generate preview', variable=master.preview_state)
self.chk_mark_outliers = tkinter.Checkbutton(self, text=' Mark outliers', variable=master.mark_outliers_state)
self.chk_preview = tkinter.Checkbutton(self, text=' Generate preview', variable=master.preview_state)
master.overlap = tkinter.StringVar()
master.overlap.set(config['GUI']['default_overlap'])
......@@ -54,7 +41,6 @@ class PreviewOptions(tkinter.LabelFrame):
master.preview_state.trace("w", create_change_event('state_create_preview', master.preview_state))
self.chk_preview.grid(row=0, column=0, sticky='W')
self.chk_mark_outliers.grid(row=1, column=0, sticky='W')
self.overlap_label.grid(row=2, column=0)
self.overlap_entry.grid(row=2, column=1)
self.scaling_label.grid(row=3, column=0)
......
......@@ -185,14 +185,14 @@ class Preview:
"""
Display the preview by opening ImageJ with a special jar that only shows the image without the ImageJ menu.
For the java source code, see #TODO.
To save memory when processing many files, only the last 6 ImageJ processes are kept alive.
To save memory when processing many files, only the last two ImageJ processes are kept alive.
Args:
save_path: Full path to saved preview
"""
process = subprocess.Popen(['java', '-jar', 'utils/imagej_no_show.jar', save_path], shell=False)
# if there are already 6 processes running, terminate the oldest one
if len(Preview.processes) >= 6:
# if there are already 2 processes running, terminate the oldest one
if len(Preview.processes) >= 2:
process_to_be_terminated = Preview.processes.pop(0)
process_to_be_terminated.terminate()
......
......@@ -129,14 +129,14 @@ def clicked_start(frame):
error_matrix, outlier_coords, filtered_coords = process_quality_check(frame, path, log_path)
frame.print(f'Saved logfile at "{log_path}".')
if frame.mark_outliers_state.get(): # generate preview with marked outliers
marked_preview = preview.add_outlier_markings(error_matrix, outlier_coords, filtered_coords)
# save and show preview
preview_path, error_msg = marked_preview.save(config['PREVIEWS']['preview_path'])
if error_msg:
frame.print(error_msg)
else:
Preview.show(preview_path)
# generate preview with marked outliers
marked_preview = preview.add_outlier_markings(error_matrix, outlier_coords, filtered_coords)
# save and show preview
preview_path, error_msg = marked_preview.save(config['PREVIEWS']['preview_path'])
if error_msg:
frame.print(error_msg)
else:
Preview.show(preview_path)
frame.print(f'')
frame.progress_text.set('Done!')
......@@ -246,12 +246,9 @@ def process_quality_check(frame, tiff_path, logger_path):
# call the actual analysis method
time_pre = time.time()
if frame.mark_outliers_state.get() == 1:
error_matrix, outlier_coords, filtered_coords = analyze_section_with_coords(tiff_path, quality_check,
on_tile_done=progressbar_callback)
else:
error_matrix = analyze_section(
tiff_path, quality_check, on_tile_done=progressbar_callback)
error_matrix, outlier_coords, filtered_coords = analyze_section_with_coords(tiff_path, quality_check,
on_tile_done=progressbar_callback)
# save error matrix
# use name of section as file name for matrix
......
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