Nic-Ma: /black
Nic-Ma: Hi @ericspod ,

Thanks very much for your review.
I updated the PR according to your comments.
And I got 2 small questions here:
1. Why you think "assert" is not good for parameters? not easy to "try-catch" outside?
2. Do you think it's OK to put post transforms at `/transforms/post/` or move to some other places like `/networks/`?

Thanks.
ericspod: Hi @Nic-Ma,
The thing with assert is that it is intended to be an internal sanity check rather than a mechanism to easily check some condition. Asserts can be turned off at runtime through a command line argument for efficiency, but we don't ever want input validation to be disabled. The assert statement is more convenient than having a `if ...: raise ...` kind of construct everywhere but it is better practice. Even better still would be some sort of design-by-contract facility so that we could define preconditions for inputs which are automatically turned into these checks for us. Something like [PyContracts](http://andreacensi.github.io/contracts/) or [icontract](https://github.com/Parquery/icontract) though I'm not recommending we start using these in MONAI without discussing it further. 

I think it's good to keep all the transforms we define in one place so yes under the `/transforms/post` directory. My feeling is that `/networks` should be strictly for the network definitions themselves, the layers they use, and a few utilities. Transforms are ancillary to the networks themselves even if defined in Pytorch. 
diff --git a/docs/source/transforms.rst b/docs/source/transforms.rst
index 5b552988..e505d962 100644
--- a/docs/source/transforms.rst
+++ b/docs/source/transforms.rst
@@ -315,6 +315,12 @@ Vanilla Transforms
     :members:
     :special-members: __call__
 
+`SplitChannel`
+~~~~~~~~~~~~~~
+.. autoclass:: SplitChannel
+    :members:
+    :special-members: __call__
+
 Dictionary-based Transforms
 ----------------------------
 
@@ -570,6 +576,12 @@ Dictionary-based Transforms
     :members:
     :special-members: __call__
 
+`SplitChanneld`
+~~~~~~~~~~~~~~~
+.. autoclass:: SplitChanneld
+    :members:
+    :special-members: __call__
+
 Transform Adaptors
 ------------------
 
diff --git a/monai/transforms/__init__.py b/monai/transforms/__init__.py
index b5671265..5cc032b6 100644
--- a/monai/transforms/__init__.py
+++ b/monai/transforms/__init__.py
@@ -20,3 +20,5 @@ from .spatial.array import *
 from .spatial.dictionary import *
 from .utility.array import *
 from .utility.dictionary import *
+from .post.array import *
+from .post.dictionary import *
diff --git a/monai/transforms/post/__init__.py b/monai/transforms/post/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/monai/transforms/post/array.py b/monai/transforms/post/array.py
new file mode 100644
index 00000000..92d171fd
--- /dev/null
+++ b/monai/transforms/post/array.py
@@ -0,0 +1,48 @@
+# Copyright 2020 MONAI Consortium
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""
+A collection of "vanilla" transforms for the model output tensors
+https://github.com/Project-MONAI/MONAI/wiki/MONAI_Design
+"""
+
+from monai.transforms.compose import Transform
+from monai.networks.utils import one_hot
+
+
+class SplitChannel(Transform):
+    """
+    Split PyTorch Tensor data according to the channel dim, if only 1 channel, convert to One-Hot
+    format first based on the class number. Users can use this transform to compute metrics on every
+    single class to get more details of validation/evaluation. Expected input shape:
+    (batch_size, num_channels, spatial_dim_1[, spatial_dim_2, ...])
+
+    Args:
+        to_onehot (bool): whether to convert the data to One-Hot format, default is False.
+        num_classes (int): the class number used to convert to One-Hot format if `to_onehot` is True.
+
+    """
+
+    def __init__(self, to_onehot=False, num_classes=None):
+        self.to_onehot = to_onehot
+        self.num_classes = num_classes
+
+    def __call__(self, img, to_onehot=None, num_classes=None):
+        if self.to_onehot if to_onehot is None else to_onehot:
+            if num_classes is None:
+                num_classes = self.num_classes
+            assert isinstance(num_classes, int), "must specify class number for One-Hot."
+            img = one_hot(img, num_classes)
+        n_classes = img.shape[1]
+        outputs = list()
+        for i in range(n_classes):
+            outputs.append(img[:, i : i + 1])
+
+        return outputs
diff --git a/monai/transforms/post/dictionary.py b/monai/transforms/post/dictionary.py
new file mode 100644
index 00000000..097e8b51
--- /dev/null
+++ b/monai/transforms/post/dictionary.py
@@ -0,0 +1,59 @@
+# Copyright 2020 MONAI Consortium
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""
+A collection of dictionary-based wrappers around the "vanilla" transforms for model output tensors
+defined in :py:class:`monai.transforms.utility.array`.
+
+Class names are ended with 'd' to denote dictionary-based transforms.
+"""
+
+from monai.utils.misc import ensure_tuple_rep
+from monai.transforms.compose import MapTransform
+from monai.transforms.post.array import SplitChannel
+
+
+class SplitChanneld(MapTransform):
+    """
+    Dictionary-based wrapper of :py:class:`monai.transforms.SplitChannel`.
+    All the input specified by `keys` should be splitted into same count of data.
+
+    """
+
+    def __init__(self, keys, output_postfixes, to_onehot=False, num_classes=None):
+        """
+        Args:
+            keys (hashable items): keys of the corresponding items to be transformed.
+                See also: :py:class:`monai.transforms.compose.MapTransform`
+            output_postfixes (list, tuple): the postfixes to construct keys to store splitted data.
+                for example: if the key of input data is `pred` and split 2 classes, the output
+                data keys will be: pred_(output_postfixes[0]), pred_(output_postfixes[1])
+            to_onehot (bool or list of bool): whether to convert the data to One-Hot format, default is False.
+        num_classes (int or list of int): the class number used to convert to One-Hot format if `to_onehot` is True.
+        """
+        super().__init__(keys)
+        if not isinstance(output_postfixes, (list, tuple)):
+            raise ValueError("must specify key postfixes to store splitted data.")
+        self.output_postfixes = output_postfixes
+        self.to_onehot = ensure_tuple_rep(to_onehot, len(self.keys))
+        self.num_classes = ensure_tuple_rep(num_classes, len(self.keys))
+        self.splitter = SplitChannel()
+
+    def __call__(self, data):
+        d = dict(data)
+        for idx, key in enumerate(self.keys):
+            rets = self.splitter(d[key], self.to_onehot[idx], self.num_classes[idx])
+            assert len(self.output_postfixes) == len(rets), "count of splitted results must match output_postfixes."
+            for i, r in enumerate(rets):
+                d[f"{key}_{self.output_postfixes[i]}"] = r
+        return d
+
+
+SplitChannelD = SplitChannelDict = SplitChanneld

add SplitChannel transform for model output
**Is your feature request related to a problem? Please describe.**
`SplitChannel` transform can be used to split a multiple class label or model outputs.
For example, split multiple classes and compute the `mean_dice` metric separately.

diff --git a/tests/test_split_channel.py b/tests/test_split_channel.py
new file mode 100644
index 00000000..76d1b3ea
--- /dev/null
+++ b/tests/test_split_channel.py
@@ -0,0 +1,31 @@
+# Copyright 2020 MONAI Consortium
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+import torch
+from parameterized import parameterized
+from monai.transforms import SplitChannel
+
+TEST_CASE_1 = [{"to_onehot": False}, torch.randint(0, 2, size=(4, 3, 3, 4)), (4, 1, 3, 4)]
+
+TEST_CASE_2 = [{"to_onehot": True, "num_classes": 3}, torch.randint(0, 3, size=(4, 1, 3, 4)), (4, 1, 3, 4)]
+
+
+class TestSplitChannel(unittest.TestCase):
+    @parameterized.expand([TEST_CASE_1, TEST_CASE_2])
+    def test_shape(self, input_param, test_data, expected_shape):
+        result = SplitChannel(**input_param)(test_data)
+        for data in result:
+            self.assertTupleEqual(data.shape, expected_shape)
+
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/tests/test_split_channeld.py b/tests/test_split_channeld.py
new file mode 100644
index 00000000..c2821c91
--- /dev/null
+++ b/tests/test_split_channeld.py
@@ -0,0 +1,46 @@
+# Copyright 2020 MONAI Consortium
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#     http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+import torch
+from parameterized import parameterized
+from monai.transforms import SplitChanneld
+
+TEST_CASE_1 = [
+    {"keys": ["pred"], "output_postfixes": ["cls1", "cls2", "cls3"], "to_onehot": False},
+    {"pred": torch.randint(0, 2, size=(4, 3, 3, 4))},
+    (4, 1, 3, 4),
+]
+
+TEST_CASE_2 = [
+    {"keys": ["pred"], "output_postfixes": ["cls1", "cls2", "cls3"], "to_onehot": True, "num_classes": 3},
+    {"pred": torch.randint(0, 3, size=(4, 1, 3, 4))},
+    (4, 1, 3, 4),
+]
+
+TEST_CASE_3 = [
+    {"keys": ["pred", "label"], "output_postfixes": ["cls1", "cls2", "cls3"], "to_onehot": True, "num_classes": 3},
+    {"pred": torch.randint(0, 3, size=(4, 1, 3, 4)), "label": torch.randint(0, 3, size=(4, 1, 3, 4))},
+    (4, 1, 3, 4),
+]
+
+
+class TestSplitChanneld(unittest.TestCase):
+    @parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_3])
+    def test_shape(self, input_param, test_data, expected_shape):
+        result = SplitChanneld(**input_param)(test_data)
+        for k, v in result.items():
+            if "cls" in k:
+                self.assertTupleEqual(v.shape, expected_shape)
+
+
+if __name__ == "__main__":
+    unittest.main()

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest black flake8 mypy pytype
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
absl-py==1.4.0
attrs==22.2.0
black==22.8.0
cachetools==4.2.4
certifi==2021.5.30
charset-normalizer==2.0.12
click==8.0.4
coverage==6.2
cycler==0.11.0
dataclasses==0.8
decorator==4.4.2
flake8==5.0.4
google-auth==2.22.0
google-auth-oauthlib==0.4.6
grpcio==1.48.2
idna==3.10
imageio==2.15.0
importlab==0.8.1
importlib-metadata==4.8.3
iniconfig==1.1.1
kiwisolver==1.3.1
libcst==0.4.1
Markdown==3.3.7
matplotlib==3.3.4
mccabe==0.7.0
-e git+https://github.com/Project-MONAI/MONAI.git@eb8f29cb18090385cc727780a6be4d0333e834ce#egg=monai
mypy==0.971
mypy-extensions==1.0.0
networkx==2.5.1
nibabel==3.2.2
ninja==1.11.1.1
numpy==1.19.5
oauthlib==3.2.2
packaging==21.3
parameterized==0.8.1
pathspec==0.9.0
Pillow==8.4.0
platformdirs==2.4.0
pluggy==1.0.0
protobuf==3.19.6
py==1.11.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
pytorch-ignite==0.3.0
pytype==2022.1.5
PyWavelets==1.1.1
PyYAML==6.0.1
requests==2.27.1
requests-oauthlib==2.0.0
rsa==4.9
scikit-image==0.17.2
scipy==1.5.4
six==1.17.0
tabulate==0.8.10
tensorboard==2.10.1
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tifffile==2020.9.3
toml==0.10.2
tomli==1.2.3
torch==1.10.2
typed-ast==1.5.5
typing-inspect==0.9.0
typing_extensions==4.1.1
urllib3==1.26.20
Werkzeug==2.0.3
zipp==3.6.0

name: MONAI
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - absl-py==1.4.0
      - attrs==22.2.0
      - black==22.8.0
      - cachetools==4.2.4
      - charset-normalizer==2.0.12
      - click==8.0.4
      - coverage==6.2
      - cycler==0.11.0
      - dataclasses==0.8
      - decorator==4.4.2
      - flake8==5.0.4
      - google-auth==2.22.0
      - google-auth-oauthlib==0.4.6
      - grpcio==1.48.2
      - idna==3.10
      - imageio==2.15.0
      - importlab==0.8.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - kiwisolver==1.3.1
      - libcst==0.4.1
      - markdown==3.3.7
      - matplotlib==3.3.4
      - mccabe==0.7.0
      - mypy==0.971
      - mypy-extensions==1.0.0
      - networkx==2.5.1
      - nibabel==3.2.2
      - ninja==1.11.1.1
      - numpy==1.19.5
      - oauthlib==3.2.2
      - packaging==21.3
      - parameterized==0.8.1
      - pathspec==0.9.0
      - pillow==8.4.0
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - protobuf==3.19.6
      - py==1.11.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytorch-ignite==0.3.0
      - pytype==2022.1.5
      - pywavelets==1.1.1
      - pyyaml==6.0.1
      - requests==2.27.1
      - requests-oauthlib==2.0.0
      - rsa==4.9
      - scikit-image==0.17.2
      - scipy==1.5.4
      - six==1.17.0
      - tabulate==0.8.10
      - tensorboard==2.10.1
      - tensorboard-data-server==0.6.1
      - tensorboard-plugin-wit==1.8.1
      - tifffile==2020.9.3
      - toml==0.10.2
      - tomli==1.2.3
      - torch==1.10.2
      - typed-ast==1.5.5
      - typing-extensions==4.1.1
      - typing-inspect==0.9.0
      - urllib3==1.26.20
      - werkzeug==2.0.3
      - zipp==3.6.0
prefix: /opt/conda/envs/MONAI

tests/test_split_channel.py::TestSplitChannel::test_shape_0 tests/test_split_channel.py::TestSplitChannel::test_shape_1 tests/test_split_channeld.py::TestSplitChanneld::test_shape_0 tests/test_split_channeld.py::TestSplitChanneld::test_shape_1 tests/test_split_channeld.py::TestSplitChanneld::test_shape_2
monai/transforms/post/array.py monai/transforms/__init__.py monai/transforms/post/dictionary.py docs/source/transforms.rst monai/transforms/post/__init__.py
monai/transforms/post/array.py monai/transforms/__init__.py monai/transforms/post/dictionary.py docs/source/transforms.rst monai/transforms/post/__init__.py