Skip to content

Commit

Permalink
Only import matplotlib when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jadball committed Oct 18, 2024
1 parent 2c9fe27 commit 523f565
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ImageD11/sinograms/point_by_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import h5py
import numba
import pprint
from matplotlib import pyplot as plt

from skimage.filters import threshold_otsu
from skimage.morphology import convex_hull_image

Expand Down Expand Up @@ -573,6 +573,7 @@ def UBI(self):
return self.ubi

def plot_nuniq_hist(self):
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
ax.hist(self.nuniq, bins=np.arange(0.5, np.max(self.nuniq) + 0.51, 1))
ax.set_xlabel('Unique spots per pixel')
Expand All @@ -593,6 +594,7 @@ def choose_best(self, minpeaks=6):
self.best_eps = best_eps

def plot_best(self, minpeaks=6):
from matplotlib import pyplot as plt
fig, axs = plt.subplots(1, 2, sharex=True, sharey=True, figsize=(10, 5), constrained_layout=True)
r = np.where(self.best_nuniq > minpeaks, self.best_nuniq, 0)
axs[0].imshow(self.best_nuniq, origin="lower")
Expand Down Expand Up @@ -873,6 +875,7 @@ def setmask(self, manual_threshold=None, doplot=False, use_icolf=True):
whole_sample_mask = chull

if doplot:
from matplotlib import pyplot as plt
fig, axs = plt.subplots(1, 3, sharex=True, sharey=True, constrained_layout=True)
axs[0].imshow(recon_man_mask, vmin=0, origin="lower")
axs[1].imshow(binary, origin="lower")
Expand Down

0 comments on commit 523f565

Please sign in to comment.