@@ -75,7 +75,8 @@ def illumination_correction(
75
75
zarrurl ,
76
76
overwrite = False ,
77
77
newzarrurl = None ,
78
- channels = None ,
78
+ chl_list = None ,
79
+ path_dict_corr = None ,
79
80
coarsening_xy = 2 ,
80
81
background = 110 ,
81
82
):
@@ -90,19 +91,17 @@ def illumination_correction(
90
91
:type overwrite: bool
91
92
:param newzarrurl: output zarr, at the site level (e.g. x.zarr/B/03/0/)
92
93
:type newzarrurl: str
93
- :param chl_list: list of channels #FIXME
94
+ :param chl_list: list of channel names (e.g. A01_C01)
94
95
:type chl_list: list
96
+ :param path_dict_corr: FIXME
97
+ :type path_dict_corr: str
95
98
:param coarsening_xy: coarsening factor in XY (optional, default 2)
96
99
:type coarsening_z: xy
97
100
:param background: value for background subtraction (optional, default 110)
98
101
:type background: int
99
102
100
103
"""
101
104
102
- raise NotImplementedError (
103
- "illumination_correction not implemented " "with new channel scheme"
104
- )
105
-
106
105
# Check that only one output option is chosen
107
106
if overwrite and (newzarrurl is not None ):
108
107
raise Exception (
@@ -128,26 +127,16 @@ def illumination_correction(
128
127
img_size_y = 2160
129
128
img_size_x = 2560
130
129
131
- # FIXME: this block is too specific!
132
- # Hard-coded choice of illumination correction matrix
133
- path_correction_matrices = (
134
- "/data/active/fractal/Liberali/"
135
- "FractalTesting20220124/"
136
- "IlluminationCorrectionMatrices-Yokogawa/"
137
- )
138
- filenames = {
139
- 1 : "220120_60xW_BP445_CH01.tif" ,
140
- 2 : "220120_60xW_BP525_CH02.tif" ,
141
- 3 : "220120_60xW_BP600_CH03.tif" ,
142
- 4 : "220120_60xW_BP676_CH04.tif" ,
143
- }
130
+ # Load paths of correction matrices
131
+ with open (path_dict_corr , "r" ) as jsonfile :
132
+ dict_corr = json .load (jsonfile )
133
+ root_path_corr = dict_corr .pop ("root_path_corr" )
134
+
135
+ # Assemble dictionary of matrices and check their shapes
144
136
corrections = {}
145
- for channel in channels :
146
- ind_ch , ID_ch , label_ch = channel [:]
147
- corrections [ind_ch ] = imread (
148
- path_correction_matrices + filenames [ind_ch + 1 ]
149
- )
150
- if corrections [ind_ch ].shape != (img_size_y , img_size_x ):
137
+ for ind_ch , ch in enumerate (chl_list ):
138
+ corrections [ch ] = imread (root_path_corr + dict_corr [ch ])
139
+ if corrections [ch ].shape != (img_size_y , img_size_x ):
151
140
raise Exception (
152
141
"Error in illumination_correction, "
153
142
"correction matrix has wrong shape."
@@ -188,11 +177,10 @@ def illumination_correction(
188
177
189
178
# Loop over channels
190
179
data_czyx_new = []
191
- for channel in channels :
192
- ind_ch , ID_ch , label_ch = channel [:]
180
+ for ind_ch , ch in enumerate (chl_list ):
193
181
194
182
data_zyx = data_czyx [ind_ch ]
195
- illum_img = corrections [ind_ch ]
183
+ illum_img = corrections [ch ]
196
184
197
185
# Map "correct" function onto each block
198
186
data_zyx_new = data_zyx .map_blocks (
@@ -214,7 +202,7 @@ def illumination_correction(
214
202
num_levels = num_levels ,
215
203
chunk_size_x = img_size_x ,
216
204
chunk_size_y = img_size_y ,
217
- num_channels = len (channels ),
205
+ num_channels = len (chl_list ),
218
206
)
219
207
220
208
# Write data into output zarr
@@ -246,12 +234,11 @@ def illumination_correction(
246
234
help = "path of the new zarr file" ,
247
235
)
248
236
249
- # FIXME
250
237
parser .add_argument (
251
238
"-C" ,
252
239
"--chl_list" ,
253
240
nargs = "+" ,
254
- help = "list of channels " ,
241
+ help = "list of channel names (e.g. A01_C01) " ,
255
242
)
256
243
parser .add_argument (
257
244
"-cxy" ,
0 commit comments