Skip to content

Commit 5516535

Browse files
committed
fix mypy
Signed-off-by: KumoLiu <[email protected]>
1 parent d40416c commit 5516535

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

monai/transforms/intensity/array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def randomize(self, data: Any | None = None) -> None:
666666
if not self._do_transform:
667667
return None
668668
if self.channel_wise:
669-
self.factor = [self.R.uniform(low=self.factors[0], high=self.factors[1]) for _ in range(data.shape[0])]
669+
self.factor = [self.R.uniform(low=self.factors[0], high=self.factors[1]) for _ in range(data.shape[0])] # type: ignore
670670
else:
671671
self.factor = self.R.uniform(low=self.factors[0], high=self.factors[1])
672672

@@ -681,12 +681,13 @@ def __call__(self, img: NdarrayOrTensor, randomize: bool = True) -> NdarrayOrTen
681681
if not self._do_transform:
682682
return convert_data_type(img, dtype=self.dtype)[0]
683683

684+
ret: NdarrayOrTensor
684685
if self.channel_wise:
685686
out = []
686687
for i, d in enumerate(img):
687-
out_channel = ScaleIntensity(minv=None, maxv=None, factor=self.factor[i], dtype=self.dtype)(d)
688+
out_channel = ScaleIntensity(minv=None, maxv=None, factor=self.factor[i], dtype=self.dtype)(d) # type: ignore
688689
out.append(out_channel)
689-
ret = torch.stack(out)
690+
ret = torch.stack(out) # type: ignore
690691
else:
691692
ret = ScaleIntensity(minv=None, maxv=None, factor=self.factor, dtype=self.dtype)(img)
692693
return ret

monai/transforms/intensity/dictionary.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ def __init__(
369369
keys: KeysCollection,
370370
offsets: tuple[float, float] | float,
371371
safe: bool = False,
372-
channel_wise: bool = False,
373372
factor_key: str | None = None,
374373
meta_keys: KeysCollection | None = None,
375374
meta_key_postfix: str = DEFAULT_POST_FIX,
@@ -384,8 +383,6 @@ def __init__(
384383
if single number, offset value is picked from (-offsets, offsets).
385384
safe: if `True`, then do safe dtype convert when intensity overflow. default to `False`.
386385
E.g., `[256, -12]` -> `[array(0), array(244)]`. If `True`, then `[256, -12]` -> `[array(255), array(0)]`.
387-
channel_wise: if True, calculate on each channel separately. Please ensure
388-
that the first dimension represents the channel of the image if True.
389386
factor_key: if not None, use it as the key to extract a value from the corresponding
390387
metadata dictionary of `key` at runtime, and multiply the random `offset` to shift intensity.
391388
Usually, `IntensityStatsd` transform can pre-compute statistics of intensity values
@@ -412,7 +409,7 @@ def __init__(
412409
if len(self.keys) != len(self.meta_keys):
413410
raise ValueError("meta_keys should have the same length as keys.")
414411
self.meta_key_postfix = ensure_tuple_rep(meta_key_postfix, len(self.keys))
415-
self.shifter = RandShiftIntensity(offsets=offsets, safe=safe, channel_wise=channel_wise, prob=1.0)
412+
self.shifter = RandShiftIntensity(offsets=offsets, safe=safe, prob=1.0)
416413

417414
def set_random_state(
418415
self, seed: int | None = None, state: np.random.RandomState | None = None

0 commit comments

Comments
 (0)