haesleinhuepf / napari-process-points-and-surfaces

Process and analyze surfaces using vedo in napari.
BSD 3-Clause "New" or "Revised" License
21 stars 4 forks source link

Change error in spherefitted curvature to a warning #39

Closed haesleinhuepf closed 1 year ago

haesleinhuepf commented 1 year ago

I'm wondering if the tools would be easier to use if we suppressed this error and replaced it with a warning. This could be done here:

https://github.com/haesleinhuepf/napari-process-points-and-surfaces/blob/a6c9113b4860917cbf6beb2b6c535e9ecced1d25/napari_process_points_and_surfaces/_quantification.py#L247-L254

By writing something like:

     except Exception: 
         curvature[idx] = np.nan 
         residues[idx] = np.nan

 if np.nan in curvature: 
     warnings.warn(f"The chosen curvature radius ({radius})" 
                       "was too small to calculate curvatures. Increase "  
                       "the radius to silence this warning.") 
haesleinhuepf commented 1 year ago

Hi Johannes @jo-mueller ,

I'm wondering what's your opinion here. I tried the above implementation in a branch and you can find an example notebook here. Read the last columns of the two tables there carefully. As far as I can see, the proposed code-change will enable us to use the function in more scenarios, because only some values are NaNs and no error happens.

Let me know what you think! Thanks!

Best, Robert

jo-mueller commented 1 year ago

Hi @haesleinhuepf ,

I think that's very reasonable to do. The NaNs are also already accounted for in the cluster plotter so I wouldn't expect them to do much harm. Also, I like using the mesh average size as a way to standardize the measurement!

haesleinhuepf commented 1 year ago

Thanks for the feedback @jo-mueller !

Also, I like using the mesh average size as a way to standardize the measurement!

Yeah, I also like it. Unfortunately, this doesn't allow inter-sample comparison. I'll open another issue for this.