QI2lab / napari-spot-detection

Detect diffraction limited spots in 2D and 3D, in standard or skewed microscopy images.
GNU General Public License v3.0
3 stars 0 forks source link

spot filtering not working #2

Closed AlexCoul closed 10 months ago

AlexCoul commented 10 months ago

After localizing, when I hit "filter spots", there is the following error in the GUI. Looks like the function signature needs to be updated for the new filtered parameters.

starting filter spots
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/Projects/napari-spot-detection_private/src/napari_spot_detection/_widget.py:1200, in SpotDetection._filter_spots(self=<napari_spot_detection._widget.SpotDetection object>)
   1198 if self._verbose > 0:
   1199     print("starting filter spots")
-> 1200 self._spots3d.run_filter_spots(return_values=True)
        self._spots3d = <opm_merfish_analysis.SPOTS3D.SPOTS3D object at 0x7f5f89b6cdc0>
        self = <napari_spot_detection._widget.SpotDetection object at 0x7f6036392440>
   1201 if self._verbose > 0:
   1202     print("finished filter spots")

File ~/miniconda3/envs/fish/lib/python3.10/site-packages/opm_merfish_analysis/SPOTS3D.py:606, in SPOTS3D.run_filter_spots(self=<opm_merfish_analysis.SPOTS3D.SPOTS3D object>, return_values=True)
    596         self._to_keep, self._conditions, self._condition_names, \
    597         self._filter_values, self._filter_names =\
    598             _imageprocessing.filter_localizations(self._fit_params,
   (...)
    601                                                   self._spot_filter_params,
    602                                                   return_values)
    603     else:
    604         self._to_keep, self._conditions, self._condition_names, self._filter_settings, \
    605         self._filter_values, self._filter_names =\
--> 606             localize.filter_localizations(self._fit_params,
        self = <opm_merfish_analysis.SPOTS3D.SPOTS3D object at 0x7f5f89b6cdc0>
        self._fit_params = <class 'numpy.ndarray'> (2731, 7) float32
        localize = <module 'localize_psf.localize' from '/home/qi2lab/miniconda3/envs/fish/lib/python3.10/site-packages/localize_psf/localize.py'>
        self._init_params = <class 'numpy.ndarray'> (2731, 7) float64
        self._coords = (<class 'numpy.ndarray'> (33, 1, 1) float64, <class 'numpy.ndarray'> (1, 1161, 1) float64, <class 'numpy.ndarray'> (1, 1, 1161) float64)
        self._spot_filter_params = {'sigma_min_z_factor': 0.2, 'sigma_min_xy_factor': 0.25, 'sigma_max_z_factor': 3.0, 'sigma_max_xy_factor': 8.0, 'fit_dist_max_err_z_factor': 5.0, 'fit_dist_max_err_xy_factor': 7.0, 'min_spot_sep_z_factor': 2.0, 'min_spot_sep_xy_factor': 1.0, 'amp_min': 2.0, 'dist_boundary_z_factor': 0.05, 'dist_boundary_xy_factor': 0.05, 'min_sigma_ratio': 1.25, 'max_sigma_ratio': 3.0, 'sigma_min_xy': 0.027296296296296294, 'sigma_min_z': 0.08025850200901927, 'sigma_max_xy': 0.8734814814814814, 'sigma_max_z': 1.2038775301352889, 'sigma_bounds': ((0.08025850200901927, 0.027296296296296294), (1.2038775301352889, 0.8734814814814814)), 'fit_dist_max_err': (2.0064625502254816, 0.7642962962962963), 'min_spot_sep': (0.8025850200901926, 0.10918518518518518), 'dist_boundary_min': (0.00435, 0.00435), 'sigma_ratios_bounds': (1.25, 6)}
        self._spot_filter_params['fit_dist_max_err'] = (2.0064625502254816, 0.7642962962962963)
        self._spot_filter_params['min_spot_sep'] = (0.8025850200901926, 0.10918518518518518)
        self._spot_filter_params['sigma_bounds'] = ((0.08025850200901927, 0.027296296296296294), (1.2038775301352889, 0.8734814814814814))
        self._spot_filter_params['amp_min'] = 2.0
        self._spot_filter_params['dist_boundary_min'] = (0.00435, 0.00435)
        self._spot_filter_params['sigma_ratios_bounds'] = (1.25, 6)
        return_values = True
    607                                           self._init_params,
    608                                           self._coords,
    609                                           self._spot_filter_params['fit_dist_max_err'],
    610                                           self._spot_filter_params['min_spot_sep'],
    611                                           self._spot_filter_params['sigma_bounds'],
    612                                           self._spot_filter_params['amp_min'],
    613                                           self._spot_filter_params['dist_boundary_min'],
    614                                           self._spot_filter_params['sigma_ratios_bounds'],
    615                                           return_values)
    616 else:
    617     if self._is_skewed:

TypeError: filter_localizations() takes from 6 to 8 positional arguments but 10 were given
AlexCoul commented 10 months ago

@dpshepherd I think this is because the version of localize-psf installed with pip is the one before the commit ea24cec0d36d90544a18c32a4573e56fe5f6cb1f pushed on Oct 18, 2023. I had the same issue, after a pip uninstall localize-psf then a pip install -e . in the updated localize-psf repo I could run the test script for cartesian data.

dpshepherd commented 10 months ago

That fixed the problem.