@@ -112,20 +112,24 @@ In addition to the result tables, the label imdage (also known as an *index imag
112112 from net.imglib2.roi.labeling import LabelRegions
113113 from net.imglib2.type.logic import BitType
114114 from net.imglib2.type.numeric.real import FloatType
115-
115+
116116 from org.scijava.table import DefaultGenericTable
117117
118118 from jarray import array
119119
120- def extract_channel(image, ch):
120+ def extract_channel(image, axis, ch):
121121 """Extract a channel from the input image.
122122
123123 Extract the given channel from the input image.
124124
125125 :param image:
126-
127- Input Img.
128-
126+
127+ Input image.
128+
129+ :param axis:
130+
131+ Integer corresponding to the Channel axis.
132+
129133 :param ch:
130134
131135 Channel number to extract.
@@ -134,12 +138,10 @@ In addition to the result tables, the label imdage (also known as an *index imag
134138
135139 A view of the extracted channel.
136140 """
137- # find C and Z axis indicies
138- c_idx = find_axis_index(image, "Channel")
139-
140- return ops.op("transform.hyperSliceView").input(image, c_idx, ch - 1).apply()
141-
142-
141+
142+ return ops.op("transform.hyperSliceView").input(image, axis, ch - 1).apply()
143+
144+
143145 def extract_inside_mask(mask_a, mask_b):
144146 """Extract the mask "A" data from regions inside mask "B".
145147
@@ -193,43 +195,44 @@ In addition to the result tables, the label imdage (also known as an *index imag
193195 return i
194196 else:
195197 continue
196-
198+
197199 return None
198-
199-
200+
201+
200202 def gaussian_subtraction(image, sigma):
201203 """Perform a Gaussian subtraction on an image.
202-
204+
203205 Apply a Gaussian blur and subtract from input image.
204-
206+
205207 :param image:
206-
208+
207209 Input Img.
208-
210+
209211 :param sigma:
210-
212+
211213 Sigma value.
212-
214+
213215 :return:
214-
216+
215217 Gaussian blur subtracted image.
216218 """
217219 blur = ops.op("filter.gauss").input(image, sigma).apply()
218220 out = ops.op("create.img").input(image, FloatType()).apply()
219221 ops.op("math.sub").input(image, blur).output(out).compute()
220-
222+
221223 return out
222-
224+
223225 # crop the input data to a 450 x 450 patch
224226 min_arr = array([370, 136, 0, 0], "l")
225227 max_arr = array([819, 585, 2, 59], "l")
226228 img_crop = ops.op("transform.intervalView").input(img, min_arr, max_arr).apply()
227- img_crop = Views.dropSingletonDimensions( img_crop)
229+ img_crop = ops.op("transform.dropSingletonDimensionsView").input( img_crop).apply( )
228230 img_crop = ops.op("transform.offsetView").input(img_crop, array([370, 136, 0, 0], "l")).apply()
229231
230232 # extract channels
231- ch_a_img = extract_channel(img_crop, ch_a)
232- ch_b_img = extract_channel(img_crop, ch_b)
233+ c_idx = find_axis_index(img, "Channel")
234+ ch_a_img = extract_channel(img_crop, c_idx, ch_a)
235+ ch_b_img = extract_channel(img_crop, c_idx, ch_b)
233236
234237 # customize the following sections below for your own data
235238 # clean up channel "A" and create a mask
0 commit comments