wingtorres / morphometrix

A PyQt5 Gui for photogrammetry and morphometry
MIT License
17 stars 7 forks source link

Issues Measuring Widths #6

Closed eihwood closed 1 year ago

eihwood commented 2 years ago

I'm using development code updated for PyQt6 (running on 2021 Macbook Pro with M1 Pro in native arm64 - OS 12.0.1 Monterey) and noticed an issue with measuring widths related to the Bezier Fit function - the three scenarios / behaviors are described below - all were done with 20 percentile width segments.

  1. Uncheck Bezier checkbox and measure TL with two points, double clicking second point to finish the measurement:

    • Measure Widths option button greyed out and not selectable
  2. Check Bezier (default when opening program) and measure TL with two points

    • Measure Widths option button is clickable, but clicking it crashes Python with the following Traceback: Traceback (most recent call last): File "/Users/eihwood/Morphs/morphometrix/morphometrix/main.py", line 707, in measure_widths self.slopes = self.m[:,self.inddec] TypeError: 'NoneType' object is not subscriptable zsh: abort python -m morphometrix
  3. Check Bezier and measure TL with > 2 points

    • Executes width measuring functionality as expected
wingtorres commented 2 years ago

hey @heyelle thanks for letting me know! I just pushed some changes that should fix those issues. can you pull the new version and test it out on your system when you get the chance?

eihwood commented 2 years ago

hey @wingtorres - just responding here as I see that I never quite got back to you re: Bezier curve functionality. Below describes the scenarios and issues, which I think just hasn't been fixed from above...

  1. Import image, change appropriate parameters, select "Measure Length" with Bezier Fit selected, measure whale selecting >2 points along whale length axis. Click "Measure Widths", program behaves normally and I can measure and export all width / length measurements.
  2. Select "Measure Length" with Bezier fit selected, measure whale selecting only rostrum and fluke notch points, select "Measure Widths" and MorphoMetriX python crashes with the following error / traceback: TypeError: only size-1 arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/eheywood/morphs/morphometrix/morphometrix/main.py", line 746, in measure_widths t_i = np.array([root_scalar(gauss_legendre, x0 = s_i, bracket = [-1,1], method = "bisect", File "/Users/eheywood/morphs/morphometrix/morphometrix/main.py", line 746, in t_i = np.array([root_scalar(gauss_legendre, x0 = s_i, bracket = [-1,1], method = "bisect", File "/Users/eheywood/opt/miniconda3/envs/morphometrix/lib/python3.10/site-packages/scipy/optimize/_root_scalar.py", line 249, in root_scalar r, sol = methodc(f, a, b, args=args, **kwargs) File "/Users/eheywood/opt/miniconda3/envs/morphometrix/lib/python3.10/site-packages/scipy/optimize/_zeros_py.py", line 556, in bisect r = _zeros._bisect(f, a, b, xtol, rtol, maxiter, args, full_output, disp) File "/Users/eheywood/morphs/morphometrix/morphometrix/main.py", line 53, in gauss_legendre x, w = np.polynomial.legendre.leggauss(degree) File "/Users/eheywood/opt/miniconda3/envs/morphometrix/lib/python3.10/site-packages/numpy/polynomial/legendre.py", line 1556, in leggauss ideg = pu._deprecate_as_int(deg, "deg") File "/Users/eheywood/opt/miniconda3/envs/morphometrix/lib/python3.10/site-packages/numpy/polynomial/polyutils.py", line 733, in _deprecate_as_int return operator.index(x) SystemError: returned a result with an exception set zsh: abort python -m morphometrix

  1. Select "Measure Length" with Piecewise selected, measure whale selecting only 2 points (rostrum and fluke notch) , select "Measure Widths" and MorphoMetriX python crashes with the following error / traceback: js: Error with Permissions-Policy header: Unrecognized feature: 'interest-cohort'. Traceback (most recent call last): File "/Users/eheywood/morphs/morphometrix/morphometrix/main.py", line 746, in measure_widths t_i = np.array([root_scalar(gauss_legendre, x0 = s_i, bracket = [-1,1], method = "bisect", File "/Users/eheywood/morphs/morphometrix/morphometrix/main.py", line 747, in args = (bezier, self.Q, self.kb-1, True, s, self.l) ).root for s in s_i]) AttributeError: 'imwin' object has no attribute 'Q' zsh: abort python -m morphometrix

  2. Lastly, when I have "piecewise" selected and I select >2 points for the whale length measurement, "Measure Widths" option is greyed out and not selectable. I am assuming that piecewise is for perfectly straight whales where you only need a straight-line 2 point length measurement...

Thanks for any insight on this!