Skip to content

Commit

Permalink
Memoize extracted features
Browse files Browse the repository at this point in the history
Memoize extracted features during the 'extract' phase. Saving to folder
now uses the features memoized.
  • Loading branch information
alexbolfa committed Dec 19, 2023
1 parent 622bb78 commit f78410f
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/napari_psf_extractor/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def param_setter(
self.img_name = None
self.stack = None
self.mip = None
self.psf_sum = None

self.reset()

Expand Down Expand Up @@ -206,18 +207,9 @@ def save_to_folder(self):
folder_path = folder_path + "/"

try:
psf_sum, _ = extract_psf(
min_mass=self.mass_slider.value()[0],
max_mass=self.mass_slider.value()[1],
stack=self.stack,
features=self.features.get_features(),
wx=self.wx, wy=self.wy, wz=self.wz,
pcc_min=self.pcc.value()
)

# Save PSF results to folder
psfe.save_stack(
psf_sum, folder_path,
self.psf_sum, folder_path,
psx=self.psx, psy=self.psy, psz=self.psz, usf=5
)
except Exception as e:
Expand All @@ -233,7 +225,7 @@ def extract(self):
This function is called when the "Extract" button is clicked.
"""
try:
psf_sum, _ = extract_psf(
self.psf_sum, _ = extract_psf(
min_mass=self.mass_slider.value()[0],
max_mass=self.mass_slider.value()[1],
stack=self.stack,
Expand All @@ -243,7 +235,7 @@ def extract(self):
)

# Plot extracted PSFs
plot_psf(psf_sum, self.psx, self.psy, self.psz)
plot_psf(self.psf_sum, self.psx, self.psy, self.psz)

self.save_button.setEnabled(True)
except Exception as e:
Expand Down

0 comments on commit f78410f

Please sign in to comment.