Skip to content

Update bundle examples to adapt to MetaTensor and fixed a bug #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/bundle/custom_component/configs/custom_train.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"train#preprocessing#transforms#6":
"train#deterministic_transforms#0":
{
"_target_": "scripts.custom_transforms.PrintEnsureTyped",
"_target_": "scripts.custom_transforms.LoadImagePrintd",
"keys": ["image", "label"]
}
}
10 changes: 5 additions & 5 deletions modules/bundle/custom_component/scripts/custom_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
# limitations under the License.

from monai.config import KeysCollection
from monai.transforms import EnsureTyped
from monai.transforms import LoadImaged


class PrintEnsureTyped(EnsureTyped):
class LoadImagePrintd(LoadImaged):
"""
Extend the `EnsureTyped` transform to print the image shape.
Transform to load image and print the image shape.

Args:
keys: keys of the corresponding items to be transformed.

"""

def __init__(self, keys: KeysCollection, data_type: str = "tensor") -> None:
super().__init__(keys, data_type=data_type)
def __init__(self, keys: KeysCollection) -> None:
super().__init__(keys)

def __call__(self, data):
d = dict(super().__call__(data=data))
Expand Down
4 changes: 0 additions & 4 deletions modules/bundle/hybrid_programming/configs/data_loading.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"b_min": 0,
"b_max": 1,
"clip": true
},
{
"_target_": "EnsureTyped",
"keys": "@image_key"
}
]
},
Expand Down
4 changes: 0 additions & 4 deletions modules/bundle/spleen_segmentation/configs/train.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
"b_min": 0,
"b_max": 1,
"clip": true
},
{
"_target_": "EnsureTyped",
"keys": ["image", "label"]
}
],
"random_transforms": [
Expand Down