Skip to content
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

Provide ability to override map_items=True set by default for Dataset #7646

Closed
surajpaib opened this issue Apr 15, 2024 · 2 comments · Fixed by #7784
Closed

Provide ability to override map_items=True set by default for Dataset #7646

surajpaib opened this issue Apr 15, 2024 · 2 comments · Fixed by #7784

Comments

@surajpaib
Copy link
Contributor

Is your feature request related to a problem? Please describe.

return apply_transform(self.transform, data_i) if self.transform is not None else data_i

In the Dataset class, for any transform applied, map_items=True is the default behavior in the apply_transform helper function.

I'm trying to use some other datasets in MONAI which have an (input, target) tuple as the return from _getitem_. When I superclass this with the MONAI dataset, the tuple is unpacked, and the input and target are operated on as different items in the dataset.

Describe the solution you'd like
Ability to provide kwargs to Dataset that propagates to the apply_transform function, allowing disabling this mapping behavior.

Describe alternatives you've considered
Not using the Dataset class.

Additional context
A lot of datasets have the (input, target) behavior, and it would be useful to be able to wrap these in MONAI dataset classes.

@surajpaib
Copy link
Contributor Author

I'm happy to send a PR for this!

@surajpaib
Copy link
Contributor Author

Hi @KumoLiu

I've made a PR for this change. Let me know if all good. Thanks!

KumoLiu added a commit to surajpaib/MONAI that referenced this issue May 30, 2024
KumoLiu added a commit to surajpaib/MONAI that referenced this issue May 31, 2024
KumoLiu added a commit that referenced this issue May 31, 2024
Fixes #7646 

### Description

A few sentences describing the changes proposed in this pull request.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Suraj Pai <b.pai@maastrichtuniversity.nl>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Ben Murray <ben.murray@gmail.com>
slicepaste pushed a commit to slicepaste/MONAI that referenced this issue Jun 3, 2024
Fixes Project-MONAI#7646 

### Description

A few sentences describing the changes proposed in this pull request.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [x] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Suraj Pai <b.pai@maastrichtuniversity.nl>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Ben Murray <ben.murray@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants