From 413a4314405b4f3ae37343d3f9129baa9a756ec5 Mon Sep 17 00:00:00 2001 From: Carl Johnsen Date: Sun, 6 Oct 2024 21:09:26 +0200 Subject: [PATCH] #41 Changed from clearing figures to closing them, as pyplot suggests close rather than clf --- src/processing_steps/0225_generate_hdf5_novisim.py | 2 +- src/processing_steps/1050_compute_ridges.py | 2 +- src/processing_steps/1550_segment_osteocyt.py | 2 +- src/processing_steps/1600_bic.py | 2 +- src/processing_steps/1800_healthy_bone.py | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/processing_steps/0225_generate_hdf5_novisim.py b/src/processing_steps/0225_generate_hdf5_novisim.py index 2a39011..0ffb4a1 100644 --- a/src/processing_steps/0225_generate_hdf5_novisim.py +++ b/src/processing_steps/0225_generate_hdf5_novisim.py @@ -85,7 +85,7 @@ plt.vlines([scaled_valley], 0, smoothed[valley].astype(int), color='g') print (f'The valley is at {scaled_valley}') plt.savefig(f"{plotting_dir}/histogram.pdf", bbox_inches='tight') - plt.clf() + plt.close() # Print metadata keys and attributes if args.verbose >= 1: diff --git a/src/processing_steps/1050_compute_ridges.py b/src/processing_steps/1050_compute_ridges.py index 4a691b9..1bf2f7c 100644 --- a/src/processing_steps/1050_compute_ridges.py +++ b/src/processing_steps/1050_compute_ridges.py @@ -892,7 +892,7 @@ def update_config(): else: # Preload pyplot, as the first figure takes around 3 seconds to compute. For timing only plt.figure() - plt.clf() + plt.close() gui() if not args.dry_run: save_config() diff --git a/src/processing_steps/1550_segment_osteocyt.py b/src/processing_steps/1550_segment_osteocyt.py index f12f9eb..8702be3 100644 --- a/src/processing_steps/1550_segment_osteocyt.py +++ b/src/processing_steps/1550_segment_osteocyt.py @@ -99,7 +99,7 @@ if args.verbose >= 1: print (f'Plotting histogram of ellipsoid errors to {plotting_dir}/') plt.hist(errors, bins=100, log=True) plt.savefig(f'{plotting_dir}/{args.sample}_ellipsoid_errors.png') - plt.clf() + plt.close() # Final osteocyte segmentation osteocyte_segments = np.argwhere(osteocyte_sized & (~weirdly_long) & (~weirdly_shaped)).flatten().astype(np.uint64) diff --git a/src/processing_steps/1600_bic.py b/src/processing_steps/1600_bic.py index 569800b..a398842 100644 --- a/src/processing_steps/1600_bic.py +++ b/src/processing_steps/1600_bic.py @@ -82,7 +82,7 @@ if args.plotting: bics_path = f'{plotting_dir}/bics.pdf' if args.verbose >= 1: print (f'Plotting BICs to {bics_path}') - plt.plot(bics); plt.savefig(f"{bics_path}", bbox_inches='tight'); plt.clf() + plt.plot(bics); plt.savefig(f"{bics_path}", bbox_inches='tight'); plt.close() if args.verbose >= 1: print (f'Saving BICs to {output_dir}') np.save(f"{output_dir}/bics.npy", bics) \ No newline at end of file diff --git a/src/processing_steps/1800_healthy_bone.py b/src/processing_steps/1800_healthy_bone.py index 6b5b995..4187709 100644 --- a/src/processing_steps/1800_healthy_bone.py +++ b/src/processing_steps/1800_healthy_bone.py @@ -92,7 +92,7 @@ plt.figure(figsize=(10,10)) plt.imshow(plane) plt.savefig(f'{plotting_dir}/soft_{name}.pdf', bbox_inches='tight') - plt.clf() + plt.close() del soft if args.verbose >= 1: print (f'Loading the bone probabilities from {bone_path}') @@ -110,7 +110,7 @@ plt.figure(figsize=(10,10)) plt.imshow(plane) plt.savefig(f'{plotting_dir}/bone_{name}.pdf', bbox_inches='tight') - plt.clf() + plt.close() bone_bp = bitpack_encode(bone_threshed, verbose=args.verbose) bone_bp_opened = open_3d(bone_bp, opening_voxels, args.verbose) @@ -125,7 +125,7 @@ plt.figure(figsize=(10,10)) plt.imshow(plane) plt.savefig(f'{plotting_dir}/bone_opened_{name}.pdf', bbox_inches='tight') - plt.clf() + plt.close() if args.verbose >= 1: print (f'Computing the distance field') disted_bp = soft_bp & bone_bp_opened @@ -139,7 +139,7 @@ plt.figure(figsize=(10,10)) plt.imshow(plane) plt.savefig(f'{plotting_dir}/dist_{name}.pdf', bbox_inches='tight') - plt.clf() + plt.close() bone_count = np.sum(bone_opened) dist_count = np.sum(disted)