Skip to content

infer_subc/organelles/er

fixed_infer_ER(in_img)

Procedure to infer endoplasmic rediculum from linearly unmixed input with fixed parameters

Parameters

in_img

a 3d image containing all the channels

Returns

peroxi_object mask defined extent of peroxisome object

Source code in infer_subc/organelles/er.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def fixed_infer_ER(in_img: np.ndarray) -> np.ndarray:
    """
    Procedure to infer endoplasmic rediculum from linearly unmixed input with *fixed parameters*

    Parameters
    ------------
    in_img:
        a 3d image containing all the channels

    Returns
    -------------
    peroxi_object
        mask defined extent of peroxisome object
    """
    median_sz = 3
    gauss_sig = 2.0
    filament_scale = 1
    filament_cut = 0.015
    small_obj_w = 2
    return infer_ER(in_img, median_sz, gauss_sig, filament_scale, filament_cut, small_obj_w)

get_ER(in_img, meta_dict, out_data_path)

load endoplasmic_reticulum if it exists, otherwise calculate and write to ome.tif file

Parameters

in_img

a 3d np.ndarray image of the inferred organelle (labels or boolean)

meta_dict

dictionary of meta-data (ome)

out_data_path

Path object where tiffs are written to

Returns

exported file name

Source code in infer_subc/organelles/er.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def get_ER(in_img: np.ndarray, meta_dict: Dict, out_data_path: Path) -> np.ndarray:
    """
    load endoplasmic_reticulum if it exists, otherwise calculate and write to ome.tif file

    Parameters
    ------------
    in_img:
        a 3d  np.ndarray image of the inferred organelle (labels or boolean)
    meta_dict:
        dictionary of meta-data (ome)
    out_data_path:
        Path object where tiffs are written to

    Returns
    -------------
    exported file name

    """

    try:
        er = import_inferred_organelle("ER", meta_dict, out_data_path)
    except:
        start = time.time()
        print("starting segmentation...")
        er = infer_and_export_ER(in_img, meta_dict, out_data_path)
        end = time.time()
        print(f"inferred (and exported) ER in ({(end - start):0.2f}) sec")

    return er

infer_ER(in_img, median_sz, gauss_sig, filament_scale, filament_cut, small_obj_w)

Procedure to infer peroxisome from linearly unmixed input.

Parameters

in_img

a 3d image containing all the channels

median_sz

width of median filter for signal

gauss_sig

sigma for gaussian smoothing of signal

filament_scale

scale (log_sigma) for filament filter

filament_cut

threshold for filament fitered threshold

small_obj_w

minimu object size cutoff for nuclei post-processing

Returns

peroxi_object mask defined extent of peroxisome object

Source code in infer_subc/organelles/er.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def infer_ER(
    in_img: np.ndarray,
    median_sz: int,
    gauss_sig: float,
    filament_scale: float,
    filament_cut: float,
    small_obj_w: int,
) -> np.ndarray:
    """
    Procedure to infer peroxisome from linearly unmixed input.

    Parameters
    ------------
    in_img:
        a 3d image containing all the channels
    median_sz:
        width of median filter for signal
    gauss_sig:
        sigma for gaussian smoothing of  signal
    filament_scale:
        scale (log_sigma) for filament filter
    filament_cut:
        threshold for filament fitered threshold
    small_obj_w:
        minimu object size cutoff for nuclei post-processing
    Returns
    -------------
    peroxi_object
        mask defined extent of peroxisome object
    """
    er_ch = ER_CH
    ###################
    # EXTRACT
    ###################
    er = select_channel_from_raw(in_img, er_ch)

    ###################
    # PRE_PROCESSING
    ###################
    # er = normalized_edge_preserving_smoothing(er)
    struct_img = scale_and_smooth(er, median_sz=median_sz, gauss_sig=gauss_sig)

    ###################
    # CORE_PROCESSING
    ###################
    # f2_param = [[filament_scale, filament_cut]]
    # # f2_param = [[1, 0.15]]  # [scale_1, cutoff_1]
    # struct_obj = filament_2d_wrapper(er, f2_param)
    struct_obj = filament_filter(struct_img, filament_scale, filament_cut)

    ###################
    # POST_PROCESSING
    ###################
    struct_obj = size_filter_linear_size(struct_obj, min_size=small_obj_w)

    return label_bool_as_uint16(struct_obj)

infer_and_export_ER(in_img, meta_dict, out_data_path)

infer ER and write inferred ER to ome.tif file

Parameters

in_img

a 3d np.ndarray image of the inferred organelle (labels or boolean)

meta_dict

dictionary of meta-data (ome)

out_data_path

Path object where tiffs are written to

Returns

exported file name

Source code in infer_subc/organelles/er.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
def infer_and_export_ER(in_img: np.ndarray, meta_dict: Dict, out_data_path: Path) -> np.ndarray:
    """
    infer ER and write inferred ER to ome.tif file

    Parameters
    ------------
    in_img:
        a 3d  np.ndarray image of the inferred organelle (labels or boolean)
    meta_dict:
        dictionary of meta-data (ome)
    out_data_path:
        Path object where tiffs are written to

    Returns
    -------------
    exported file name

    """
    er = fixed_infer_ER(in_img)
    out_file_n = export_inferred_organelle(er, "ER", meta_dict, out_data_path)
    print(f"inferred ER. wrote {out_file_n}")
    return er