Skip to content

Commit

Permalink
#41 Changed from clearing figures to closing them, as pyplot suggests…
Browse files Browse the repository at this point in the history
… close rather than clf
  • Loading branch information
carljohnsen committed Oct 6, 2024
1 parent 812192e commit 413a431
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/processing_steps/0225_generate_hdf5_novisim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/processing_steps/1050_compute_ridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion src/processing_steps/1550_segment_osteocyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/processing_steps/1600_bic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions src/processing_steps/1800_healthy_bone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 413a431

Please sign in to comment.