From 7998863128232d7661773524f6ff47899226f2ed Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Wed, 20 Jul 2022 18:34:54 +0800 Subject: [PATCH 1/5] add user warnings in AsChannelFirst and AddChannel Signed-off-by: KumoLiu --- monai/transforms/utility/array.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index a28f468cf4..0a1ade7e92 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -113,6 +113,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: class AsChannelFirst(Transform): + warnings.warn('recommend to use `EnsureChannelFirst` to ensure that the channel is in the first dimension') """ Change the channel dimension of the image to the first dimension. @@ -174,6 +175,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: class AddChannel(Transform): + warnings.warn('recommend to use `EnsureChannelFirst` to ensure that the channel is in the first dimension') """ Adds a 1-length channel dimension to the input image. From 5fcea274e73c7a676b6aaa4a2be533c39d525c52 Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Thu, 21 Jul 2022 09:27:27 +0800 Subject: [PATCH 2/5] change warning to deprecated Signed-off-by: KumoLiu --- monai/transforms/utility/array.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index 0a1ade7e92..f2a4097993 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -112,8 +112,8 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return img +@deprecated(since="0.9", msg_suffix="use monai.transforms.EnsureChannelFirst instead.") class AsChannelFirst(Transform): - warnings.warn('recommend to use `EnsureChannelFirst` to ensure that the channel is in the first dimension') """ Change the channel dimension of the image to the first dimension. @@ -174,8 +174,8 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return out +@deprecated(since="0.9", msg_suffix="use monai.transforms.EnsureChannelFirst instead.") class AddChannel(Transform): - warnings.warn('recommend to use `EnsureChannelFirst` to ensure that the channel is in the first dimension') """ Adds a 1-length channel dimension to the input image. From 3d76af3311264bcc634d8ca5036192c592b32070 Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Thu, 21 Jul 2022 11:42:28 +0800 Subject: [PATCH 3/5] change since0.9 to 0.8 Signed-off-by: KumoLiu --- monai/transforms/utility/array.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index f2a4097993..e76a0e0fb1 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -112,7 +112,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return img -@deprecated(since="0.9", msg_suffix="use monai.transforms.EnsureChannelFirst instead.") +@deprecated(since="0.8", msg_suffix="please use monai.transforms.EnsureChannelFirst instead.") class AsChannelFirst(Transform): """ Change the channel dimension of the image to the first dimension. @@ -174,7 +174,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return out -@deprecated(since="0.9", msg_suffix="use monai.transforms.EnsureChannelFirst instead.") +@deprecated(since="0.8", msg_suffix="please use monai.transforms.EnsureChannelFirst instead.") class AddChannel(Transform): """ Adds a 1-length channel dimension to the input image. From 990677a58b50ad4ead18e70b74e32405b7dec148 Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Thu, 21 Jul 2022 11:46:10 +0800 Subject: [PATCH 4/5] add use MetaTensor data type Signed-off-by: KumoLiu --- monai/transforms/utility/array.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index e76a0e0fb1..0bc8917593 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -112,7 +112,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return img -@deprecated(since="0.8", msg_suffix="please use monai.transforms.EnsureChannelFirst instead.") +@deprecated(since="0.8", msg_suffix="please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead.") class AsChannelFirst(Transform): """ Change the channel dimension of the image to the first dimension. @@ -174,7 +174,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return out -@deprecated(since="0.8", msg_suffix="please use monai.transforms.EnsureChannelFirst instead.") +@deprecated(since="0.8", msg_suffix="please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead.") class AddChannel(Transform): """ Adds a 1-length channel dimension to the input image. From ce2e844c1ea3260c2dfc16d62e7daacf36a0bf3d Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Thu, 21 Jul 2022 11:52:26 +0800 Subject: [PATCH 5/5] fix pep8 Signed-off-by: KumoLiu --- monai/transforms/utility/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index 0bc8917593..999636d0b9 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -112,7 +112,7 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: return img -@deprecated(since="0.8", msg_suffix="please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead.") +@deprecated(since="0.8", msg_suffix="please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead.") class AsChannelFirst(Transform): """ Change the channel dimension of the image to the first dimension.