Skip to content

Commit 8683b9e

Browse files
authored
Merge pull request #391 from jo-mueller/use-sorted-semi-axes-for-curvature-calculation
fix axes ordering for curvature calculation
2 parents d924581 + 26b540a commit 8683b9e

12 files changed

Lines changed: 16697 additions & 26736 deletions

File tree

.github/workflows/test_and_deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ${{ matrix.platform }}
2020
strategy:
2121
matrix:
22-
platform: [windows-latest, ubuntu-latest, macos-latest] # ubuntu-latest is failing anyway
22+
platform: [windows-latest, ubuntu-latest] # ubuntu-latest is failing anyway
2323
python-version: ['3.9', '3.10', '3.11']
2424

2525
steps:

docs/02_interactive_usage/02_example_workflows/visualize_measurements_in_viewer.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
(point_and_click:visualize_features)=
22
# Visualize measurements
33

4-
Napari-stress (and the [measurement toolbox](toolboxes:stress_toolbox:stress_toolbox_interactive), in partciular) generate a number of measurements that can be visualized using the [napari-matplotlib](https://napari-matplotlib.github.io/) plugin. It is automatically installed with napari-stress and can be activated from the plugins menu (`Plugins > napari Matplotlib`).
5-
6-
In order to use it, check out the documentation on the [napari-matplotlib page](https://napari-matplotlib.github.io/). In the scope of napari-stress, what you will need, is the Features Histogram (`Plugins > napari Matplotlib > FeaturesHistogram`).
4+
Napari-stress (and the [measurement toolbox](toolboxes:stress_toolbox:stress_toolbox_interactive), in partciular) generate a number of measurements that can be visualized using the [napari-matplotlib](https://napari-matplotlib.github.io/) plugin. In order to use it, check out the documentation on the [napari-matplotlib page](https://napari-matplotlib.github.io/). In the scope of napari-stress, what you will need, is the Features Histogram (`Plugins > napari Matplotlib > FeaturesHistogram`).
75

86
![](./imgs/demo_visualize_featureHistogram.png)
97

setup.cfg

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,20 @@ install_requires =
3636
joblib
3737
mpmath
3838
napari
39-
napari-matplotlib>=1.1.0
40-
napari-process-points-and-surfaces>=0.4.0
39+
napari-process-points-and-surfaces
4140
napari-segment-blobs-and-things-with-membranes
4241
napari-tools-menu>=0.1.15
4342
numpy<1.24.0
4443
pandas
4544
pygeodesic
46-
pyocclient
4745
scikit-image
4846
scipy>=1.9.0
4947
seaborn
5048
tqdm
5149
vedo>=2023.5.0
5250
vispy
5351
deprecation
54-
bokeh >= 3.1.0
52+
#bokeh >= 3.1.0
5553

5654
python_requires = >=3.7
5755
include_package_data = True

src/napari_stress/_approximation/expansion.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,11 @@ def properties(self):
554554
The maximum and minimum curvatures :math:`H_{max}` and :math:`H_{min}` are calculated as follows:
555555
556556
.. math::
557-
H_{max} = 1 / (2 * a^2) + 1 / (2 * b^2)
557+
H_{max} = a / (2 * c^2) + a / (2 * b^2)
558558
559-
H_{min} = 1 / (2 * b^2) + 1 / (2 * a^2)
559+
H_{min} = c / (2 * b^2) + c / (2 * a^2)
560560
561-
where a, b are the largest and smallest axes of the ellipsoid, respectively.
561+
where a, b and c are the lengths of the ellipsoid axes along the three spatial dimensions.
562562
"""
563563
return self._properties
564564

@@ -572,20 +572,14 @@ def _measure_max_min_curvatures(self):
572572
573573
"""
574574
# get and remove the largest, smallest and medial axis
575-
axes = list(self._axes)
576-
largest_axis = max(axes)
577-
axes.remove(largest_axis)
578-
smallest_axis = min(axes)
579-
axes.remove(smallest_axis)
580-
medial_axis = axes[0]
575+
semi_axis_sorted = np.sort(self._axes)
576+
a = semi_axis_sorted[2]
577+
b = semi_axis_sorted[1]
578+
c = semi_axis_sorted[0]
581579

582580
# accoording to paper (https://www.biorxiv.org/content/10.1101/2021.03.26.437148v1.full)
583-
maximum_mean_curvature = largest_axis / (
584-
2 * smallest_axis**2
585-
) + largest_axis / (2 * medial_axis**2)
586-
minimum_mean_curvature = smallest_axis / (
587-
2 * medial_axis**2
588-
) + smallest_axis / (2 * largest_axis**2)
581+
maximum_mean_curvature = a / (2 * c**2) + a / (2 * b**2)
582+
minimum_mean_curvature = c / (2 * b**2) + c / (2 * a**2)
589583

590584
self._properties["maximum_mean_curvature"] = maximum_mean_curvature
591585
self._properties["minimum_mean_curvature"] = minimum_mean_curvature
@@ -672,7 +666,7 @@ def _extract_characteristics(self, coefficients: np.ndarray):
672666
coefficients[6] / 2.0,
673667
coefficients[7] / 2.0,
674668
coefficients[8] / 2.0,
675-
-1,
669+
coefficients[9],
676670
],
677671
]
678672
)

src/napari_stress/_measurements/toolbox.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,12 @@ def comprehensive_analysis(
500500
)
501501

502502
max_min_anisotropy = (
503-
Expander_ellipsoid.properties["maximum_mean_curvature"]
504-
- Expander_ellipsoid.properties["minimum_mean_curvature"]
503+
2
504+
* gamma
505+
* (
506+
Expander_ellipsoid.properties["maximum_mean_curvature"]
507+
- Expander_ellipsoid.properties["minimum_mean_curvature"]
508+
)
505509
)
506510

507511
result = measurements.tissue_stress_tensor(

src/napari_stress/_measurements/toolbox.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<number>3</number>
7070
</property>
7171
<property name="value">
72-
<double>3.000000000000000</double>
72+
<double>3.300000000000000</double>
7373
</property>
7474
</widget>
7575
</item>

0 commit comments

Comments
 (0)