@@ -82,13 +82,25 @@ def validate_conditions(cls, values):
82
82
# Verify that custom parameters are only provided when type="custom"
83
83
if type != "custom" :
84
84
if lower_percentile is not None :
85
- raise ValueError (f"Type='{ type } ' but { lower_percentile = } . " "Hint: set type='custom'." )
85
+ raise ValueError (
86
+ f"Type='{ type } ' but { lower_percentile = } . "
87
+ "Hint: set type='custom'."
88
+ )
86
89
if upper_percentile is not None :
87
- raise ValueError (f"Type='{ type } ' but { upper_percentile = } . " "Hint: set type='custom'." )
90
+ raise ValueError (
91
+ f"Type='{ type } ' but { upper_percentile = } . "
92
+ "Hint: set type='custom'."
93
+ )
88
94
if lower_bound is not None :
89
- raise ValueError (f"Type='{ type } ' but { lower_bound = } . " "Hint: set type='custom'." )
95
+ raise ValueError (
96
+ f"Type='{ type } ' but { lower_bound = } . "
97
+ "Hint: set type='custom'."
98
+ )
90
99
if upper_bound is not None :
91
- raise ValueError (f"Type='{ type } ' but { upper_bound = } . " "Hint: set type='custom'." )
100
+ raise ValueError (
101
+ f"Type='{ type } ' but { upper_bound = } . "
102
+ "Hint: set type='custom'."
103
+ )
92
104
93
105
# The only valid options are:
94
106
# 1. Both percentiles are set and both bounds are unset
@@ -102,9 +114,14 @@ def validate_conditions(cls, values):
102
114
upper_bound is not None ,
103
115
)
104
116
if len (set (are_percentiles_set )) != 1 :
105
- raise ValueError ("Both lower_percentile and upper_percentile must be set " "together." )
117
+ raise ValueError (
118
+ "Both lower_percentile and upper_percentile must be set "
119
+ "together."
120
+ )
106
121
if len (set (are_bounds_set )) != 1 :
107
- raise ValueError ("Both lower_bound and upper_bound must be set together" )
122
+ raise ValueError (
123
+ "Both lower_bound and upper_bound must be set together"
124
+ )
108
125
if lower_percentile is not None and lower_bound is not None :
109
126
raise ValueError (
110
127
"You cannot set both explicit bounds and percentile bounds "
@@ -196,7 +213,9 @@ class CellposeChannel1InputModel(ChannelInputModel):
196
213
Cellpose models
197
214
"""
198
215
199
- normalize : CellposeCustomNormalizer = Field (default_factory = CellposeCustomNormalizer )
216
+ normalize : CellposeCustomNormalizer = Field (
217
+ default_factory = CellposeCustomNormalizer
218
+ )
200
219
201
220
def get_omero_channel (self , zarr_url ) -> OmeroChannel :
202
221
try :
@@ -233,7 +252,9 @@ class CellposeChannel2InputModel(BaseModel):
233
252
234
253
wavelength_id : Optional [str ] = None
235
254
label : Optional [str ] = None
236
- normalize : CellposeCustomNormalizer = Field (default_factory = CellposeCustomNormalizer )
255
+ normalize : CellposeCustomNormalizer = Field (
256
+ default_factory = CellposeCustomNormalizer
257
+ )
237
258
238
259
@validator ("label" , always = True )
239
260
def mutually_exclusive_channel_attributes (cls , v , values ):
@@ -244,7 +265,8 @@ def mutually_exclusive_channel_attributes(cls, v, values):
244
265
label = v
245
266
if wavelength_id and v :
246
267
raise ValueError (
247
- "`wavelength_id` and `label` cannot be both set " f"(given { wavelength_id = } and { label = } )."
268
+ "`wavelength_id` and `label` cannot be both set "
269
+ f"(given { wavelength_id = } and { label = } )."
248
270
)
249
271
return v
250
272
@@ -393,14 +415,18 @@ def normalized_img(
393
415
i99 = np .percentile (img [k ], upper_p )
394
416
i1 = np .percentile (img [k ], lower_p )
395
417
if i99 - i1 > + 1e-3 : # np.ptp(img[k]) > 1e-3:
396
- img [k ] = normalize_percentile (img [k ], lower = lower_p , upper = upper_p )
418
+ img [k ] = normalize_percentile (
419
+ img [k ], lower = lower_p , upper = upper_p
420
+ )
397
421
if invert :
398
422
img [k ] = - 1 * img [k ] + 1
399
423
else :
400
424
img [k ] = 0
401
425
elif lower_bound is not None :
402
426
if upper_bound - lower_bound > + 1e-3 :
403
- img [k ] = normalize_bounds (img [k ], lower = lower_bound , upper = upper_bound )
427
+ img [k ] = normalize_bounds (
428
+ img [k ], lower = lower_bound , upper = upper_bound
429
+ )
404
430
if invert :
405
431
img [k ] = - 1 * img [k ] + 1
406
432
else :
0 commit comments