1
1
import numpy as np
2
+ from scipy .ndimage import binary_fill_holes
2
3
3
- try :
4
- from scipy .ndimage import binary_fill_holes
5
- except ImportError :
6
- from scipy .ndimage .morphology import binary_fill_holes
4
+ from saenopy .pyTFM .calculate_stress_imports .mask_interpolation import mask_interpolation
5
+ from saenopy .pyTFM .calculate_stress_imports .grid_setup_solids_py import prepare_forces
6
+ from saenopy .pyTFM .calculate_stress_imports .grid_setup_solids_py import grid_setup
7
+ from saenopy .pyTFM .calculate_stress_imports .grid_setup_solids_py import FEM_simulation
8
+ from saenopy .pyTFM .calculate_stress_imports .find_borders import find_borders
7
9
8
- from saenopy .pyTFM .grid_setup_solids_py import (
9
- interpolation ,
10
- ) # a simple function to resize the mask
11
- from saenopy .pyTFM .grid_setup_solids_py import prepare_forces
12
- from saenopy .pyTFM .grid_setup_solids_py import grid_setup , FEM_simulation
13
- from saenopy .pyTFM .grid_setup_solids_py import find_borders
14
- from saenopy .pyTFM .stress_functions import line_tension
15
- from saenopy .pyTFM .stress_functions import all_stress_measures , coefficient_of_variation
16
- from saenopy .pyTFM .stress_functions import mean_stress_vector_norm
10
+ from saenopy .pyTFM .calculate_stress_imports .stress_functions import line_tension
11
+ from saenopy .pyTFM .calculate_stress_imports .stress_functions import all_stress_measures
12
+ from saenopy .pyTFM .calculate_stress_imports .stress_functions import (
13
+ coefficient_of_variation ,
14
+ )
15
+ from saenopy .pyTFM .calculate_stress_imports .stress_functions import (
16
+ mean_stress_vector_norm ,
17
+ )
17
18
18
19
19
20
def calculate_stress (mask , pixel_size , shape , u , tx , ty ):
@@ -31,12 +32,12 @@ def calculate_stress(mask, pixel_size, shape, u, tx, ty):
31
32
mask == 1
32
33
) # the mask should be a single patch without holes
33
34
# changing the masks dimensions to fit to the deformation and traction field:
34
- mask_fem = interpolation (mask_fem , dims = tx .shape )
35
+ mask_fem = mask_interpolation (mask_fem , dims = tx .shape )
35
36
36
37
# second mask: The area of the cells. Average stresses and other values are calculated only
37
38
# on the actual area of the cell, represented by this mask.
38
39
mask_cells_full = binary_fill_holes (mask == 2 )
39
- mask_cells = interpolation (mask_cells_full , dims = tx .shape )
40
+ mask_cells = mask_interpolation (mask_cells_full , dims = tx .shape )
40
41
41
42
# converting traction forces (forces per surface area) to actual forces
42
43
# and correcting imbalanced forces and torques
@@ -58,7 +59,9 @@ def calculate_stress(mask, pixel_size, shape, u, tx, ty):
58
59
sigma_max , sigma_min , sigma_max_abs , tau_max , phi_n , phi_shear , sigma_mean = (
59
60
all_stress_measures (stress_tensor , px_size = ps2 * 10 ** - 6 )
60
61
)
61
- mask_int = interpolation (mask_cells_full , dims = sigma_mean .shape , min_cell_size = 100 )
62
+ mask_int = mask_interpolation (
63
+ mask_cells_full , dims = sigma_mean .shape , min_cell_size = 100
64
+ )
62
65
res_dict ["mean normal stress Cell Area" ] = np .mean (np .abs (sigma_mean [mask_int ]))
63
66
res_dict ["max normal stress Cell Area" ] = np .mean (np .abs (sigma_max_abs [mask_int ]))
64
67
res_dict ["max shear stress Cell Area" ] = np .mean (np .abs (tau_max [mask_int ]))
0 commit comments