diff --git a/TODO.md b/TODO.md index 445b92f98b1acdb71f216b0191e73e8dee1a5baf..12b81948196e803a94bb70c7cf301fa5d7026684 100644 --- a/TODO.md +++ b/TODO.md @@ -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 diff --git a/generate_preview.py b/generate_preview.py index 7aafa3941be937eb2f0d1a2158c10ac80fd49ce5..c1dfaf2503899eb22f8cc4a826c49a17e6e8c427 100644 --- a/generate_preview.py +++ b/generate_preview.py @@ -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 diff --git a/quality_check_gui.py b/quality_check_gui.py index e4f57bf4dc1d668c8f70881ea039b4537117dd8d..78555aa822ecc62f2b8dcd1a44a00eabf1eca3ac 100644 --- a/quality_check_gui.py +++ b/quality_check_gui.py @@ -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 diff --git a/resources/DejaVuSans.ttf b/resources/DejaVuSans.ttf new file mode 100644 index 0000000000000000000000000000000000000000..725d11748a4b21c56750abe5603a854ca4ca4f04 Binary files /dev/null and b/resources/DejaVuSans.ttf differ