1
1
2
2
3
- def edgetrim_mask (edge_trim_array , debug_flag = 0 , start_trim = 0 , end_trim = 0 ):
3
+ def edgetrim_mask (edge_trim_array , debug_flag = 0 , start_trim = 0 , end_trim = 0 , additional_narrowing = 0 ):
4
4
"""
5
5
% (C) Nick Holschuh - Amherst College -- 2022 ([email protected] )
6
6
%
@@ -23,20 +23,31 @@ def edgetrim_mask(edge_trim_array, debug_flag=0, start_trim=0, end_trim=0):
23
23
from scipy .interpolate import interp1d
24
24
mask = np .zeros (edge_trim_array .shape )
25
25
26
+
27
+ ###################################################################
28
+ ### Here we identify the non-NAN values in the edge_trim matrix ###
29
+ ###################################################################
26
30
et_row ,et_col = np .where (~ np .isnan (edge_trim_array ))
27
31
center_split = np .mean (et_row )
28
32
left_ind = np .where (et_row < center_split )
29
33
right_ind = np .where (et_row >= center_split )
30
34
31
35
36
+ ###################################################################
37
+ ### We interpolate the edge_trim values across all slices ####
38
+ ###################################################################
32
39
col_opts = np .arange (0 ,edge_trim_array .shape [1 ])
33
40
34
- left_row_interpolator = interp1d (et_col [left_ind ],et_row [left_ind ],fill_value = np .NaN ,bounds_error = 0 )
35
- right_row_interpolator = interp1d (et_col [right_ind ],et_row [right_ind ],fill_value = np .NaN ,bounds_error = 0 )
41
+ left_row_interpolator = interp1d (et_col [left_ind ],et_row [left_ind ]+ additional_narrowing ,fill_value = np .NaN ,bounds_error = 0 )
42
+ right_row_interpolator = interp1d (et_col [right_ind ],et_row [right_ind ]- additional_narrowing ,fill_value = np .NaN ,bounds_error = 0 )
36
43
37
44
left_row = left_row_interpolator (col_opts ).astype (int )
38
45
right_row = right_row_interpolator (col_opts ).astype (int )
39
46
47
+
48
+ ###################################################################
49
+ ### Then we build the mask from the interpolated values ####
50
+ ###################################################################
40
51
for i in col_opts :
41
52
mask [left_row [i ]:right_row [i ]+ 1 ,i ] = 1
42
53
for i in range (start_trim ):
0 commit comments