Skip to content

Commit 27f4165

Browse files
author
Laurent Guerard
committed
Enhance docstrings for filter and threshold options functions
Update parameter names for clarity
1 parent 9fe0a64 commit 27f4165

1 file changed

Lines changed: 64 additions & 14 deletions

File tree

src/imcflibs/imagej/processing.py

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,53 @@
1010

1111

1212
def filter_options(filter_method, filter_radius, do_3d=False):
13-
"""Build the ImageJ filter command and options strings."""
13+
"""Build the ImageJ filter command and options strings.
14+
15+
Parameters
16+
----------
17+
filter_method : str
18+
Name of the filter method to use
19+
filter_radius : int
20+
Radius of the filter to use
21+
do_3d : bool, optional
22+
If set to True, will do a 3D filtering, by default False
23+
24+
Returns
25+
-------
26+
tuple[str, str]
27+
The filter name and options strings
28+
"""
1429

1530
if do_3d:
1631
filter_name = filter_method + " 3D..."
1732
else:
1833
filter_name = filter_method + "..."
1934

20-
options = (
21-
"sigma="
22-
if filter_method == "Gaussian Blur"
23-
else "radius=" + str(filter_radius) + " stack"
24-
)
35+
if filter_method == "Gaussian Blur":
36+
options = "sigma=" + str(filter_radius) + " stack"
37+
else:
38+
options = "radius=" + str(filter_radius) + " stack"
2539

2640
return filter_name, options
2741

2842

2943
def threshold_options(threshold_method, do_3d=True):
30-
"""Build the ImageJ threshold option strings."""
44+
"""Build the ImageJ threshold option strings.
45+
46+
Parameters
47+
----------
48+
threshold_method : str
49+
Name of the threshold method to use
50+
do_3d : bool, optional
51+
If set to True, the automatic threshold will be done on a 3D stack,
52+
by default True
53+
54+
Returns
55+
-------
56+
tuple[str, str]
57+
The auto threshold options and the convert to binary options strings
58+
59+
"""
3160

3261
auto_threshold_options = (
3362
threshold_method + " " + "dark" + " " + "stack" if do_3d else ""
@@ -93,7 +122,7 @@ def apply_rollingball_bg_subtraction(
93122
rolling_ball_radius,
94123
light_background=False,
95124
sliding=False,
96-
disable=False,
125+
disable_smooth=False,
97126
do_3d=False,
98127
):
99128
"""Perform background subtraction using a rolling ball method.
@@ -108,7 +137,7 @@ def apply_rollingball_bg_subtraction(
108137
If set to True, will treat the background as light, by default False
109138
sliding : bool, optional
110139
If set to True, will do a sliding window approach, by default False
111-
disable : bool, optional
140+
disable_smooth : bool, optional
112141
If set to True, will disable the smoothing, by default False
113142
do_3d : bool, optional
114143
If set to True, will do a 3D filtering, by default False
@@ -124,7 +153,7 @@ def apply_rollingball_bg_subtraction(
124153
rolling_ball_radius,
125154
light_background=light_background,
126155
sliding=sliding,
127-
disable=disable,
156+
disable_smooth=disable_smooth,
128157
do_3d=do_3d,
129158
)
130159

@@ -140,16 +169,36 @@ def rolling_ball_options(
140169
rolling_ball_radius,
141170
light_background=False,
142171
sliding=False,
143-
disable=False,
172+
disable_smooth=False,
144173
do_3d=False,
145174
):
146-
"""Generate the options for the "Subtract Background..." macro command."""
175+
"""Generate the options for the "Subtract Background..." macro command.
176+
177+
Parameters
178+
----------
179+
rolling_ball_radius : int
180+
Radius of the rolling ball filter to use
181+
light_background : bool, optional
182+
If set to True, will treat the background as light, by default False
183+
sliding : bool, optional
184+
If set to True, will do a sliding window approach, by default False
185+
disable_smooth : bool, optional
186+
If set to True, will disable the smoothing, by default False
187+
do_3d : bool, optional
188+
If set to True, will do a 3D filtering, by default False
189+
190+
Returns
191+
-------
192+
str
193+
The options string for the "Subtract Background..." macro command
194+
195+
"""
147196
parts = ["rolling=" + str(rolling_ball_radius)]
148197
if light_background:
149198
parts.append("light")
150199
if sliding:
151200
parts.append("sliding")
152-
if disable:
201+
if disable_smooth:
153202
parts.append("disable")
154203
if do_3d:
155204
parts.append("stack")
@@ -166,7 +215,8 @@ def apply_threshold(imp, threshold_method, do_3d=True):
166215
threshold_method : str
167216
Name of the threshold method to use
168217
do_3d : bool, optional
169-
If set to True, the automatic threshold will be done on a 3D stack, by default True
218+
If set to True, the automatic threshold will be done on a 3D stack,
219+
by default True
170220
171221
Returns
172222
-------

0 commit comments

Comments
 (0)