Commit 4d3a2eac authored by Wallenfang, Nils's avatar Wallenfang, Nils

save marked preview in preview directory

parent d68f7834
......@@ -8,10 +8,10 @@ Tasks related to the quality check algorithms.
## Previews
- [ ] Put font file in resources directory
- [X] Put font file in resources directory
- [x] Add checkbox to mark outlier pixels in preview
- Also save clean preview
- [ ] Save marked preview in preview directory
- [X] Save marked preview in preview directory
## GUI / UX
......@@ -24,7 +24,7 @@ Tasks related to the quality check algorithms.
## Technical
- [ ] validate config input
- [ ] add requirements.txt or setup.py
- [ ] use default config file that is used when no config is found
- [X] use default config file that is used when no config is found
# DONE
- [X] introduce pixel sampling quality check
- [X] automatically filter tiles without tissue
\ No newline at end of file
......@@ -127,7 +127,7 @@ def insert_labels(preview, xdim, ydim):
img = Image.fromarray(preview)
draw = ImageDraw.Draw(img)
preview_tile_x = preview.shape[0] / xdim
font = ImageFont.truetype(config['PREVIEWS']['font_path'], int(preview_tile_x*0.08))
font = ImageFont.truetype('resources/DejaVuSans.ttf', int(preview_tile_x*0.08))
# TODO scale font with resolution
# tile dimensions
......
......@@ -134,9 +134,11 @@ def clicked_start(frame):
if frame.mark_outliers_state.get(): # generate preview with marked outliers
# TODO catch error when no preview was generated
marked_preview = mark_preview(preview, error_matrix, outlier_coords, filtered_coords)
plt.imsave('marked_preview.png', marked_preview)
# TODO fix path (not program dir)
subprocess.Popen([config['PREVIEWS']['fiji_path'], 'marked_preview.png'])
norm = os.path.normpath(path)
# identify the section that is being analysed by its directory name
dir_name = norm.split(os.sep)[-2] + '_marked'
save_preview(marked_preview, frame, dir_name)
frame.print(f'')
frame.progress_text.set('Done!')
......@@ -144,13 +146,10 @@ def clicked_start(frame):
threading.Thread(target=logic_thread_task).start()
def save_preview(preview, frame, tiff_path):
def save_preview(preview, frame, dir_name):
preview_root = config['PREVIEWS']['preview_path']
# save preview to a fixed path
time_stamp = datetime.now(tzlocal()).strftime('%Y%m%d_%H-%M')
norm = os.path.normpath(tiff_path)
# identify the section that is being analysed by its directory name
dir_name = norm.split(os.sep)[-2]
preview_path = f'{preview_root}/{dir_name}_{time_stamp}.png'
# TODO ensure no file overrides happen
......@@ -206,7 +205,10 @@ def process_preview_gen(frame, tiff_path):
time_post = time.time()
frame.print(f'Generated preview in {time_post - time_pre:.2f}s')
save_preview(preview, frame, tiff_path)
norm = os.path.normpath(tiff_path)
# identify the section that is being analysed by its directory name
dir_name = norm.split(os.sep)[-2]
save_preview(preview, frame, dir_name)
return preview
......
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