-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
#6188 Allow user to define own FolderLayout
in SaveImage
and SaveImaged
transforms
#6213
Conversation
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
…d for custom implementations Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Add `savepath_in_metadict`, to include the location of the output image in the metadata Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
…d for custom implementations Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Add `savepath_in_metadict`, to include the location of the output image in the metadata Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
This reverts commit 145fca0.
This reverts commit 9e1dcd4.
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
…__` for easier identification (#6214) Discussed in #6213 ### Description Prepends `"meta"` to the `MetaTensor.__repr__` and `MetaTensor.__str__` output so printing a MetaTensor does not look the exact same as a regular `torch.Tensor`. I don't expect this change to cause any breaks, with me running the risk of invoking [xkcd 1172](https://xkcd.com/1172/). --- 1 failure in `./runtests.sh -f -u --net --coverage`: ```text ====================================================================== FAIL: test_values (tests.test_tciadataset.TestTciaDataset) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\PythonProjects\MONAI-SaveImageFormatting\tests\test_tciadataset.py", line 72, in test_values self.assertTrue( AssertionError: False is not true ``` ### 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). - [x] New tests added to cover the changes. - [x] 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. --------- Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
could you please update the test case in |
Will do! (Though I might have accidentally clicked a wrong button on this page) Edit: Nope, the button did what I expected it to do! |
…yout Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
I hope it's okay if I didn't rerun the full test suite, and only ran the edited tests. It takes about an hour to do on my work PC, which is considerably more powerful than my personal PC that I used for these last few commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contributions! Few comments in line.
You could also run ./runtests.sh --autofix
for auto style fixes.
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: Mathijs de Boer <8137653+MathijsdeBoer@users.noreply.github.com>
Formatting fix in test_save_imaged.py Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
# Conflicts: # monai/transforms/io/array.py # monai/transforms/io/dictionary.py
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
# Conflicts: # tests/test_save_imaged.py
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
/build |
Haha, now I'm starting to get slightly embarrased about the amount of small commits I have to make because I thought I had ran every test, but forgot that one, I'll get to work on fixing that mypy error. |
Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I think the current PR's implementation is ok for now, another idea is to set the path string as a property of SaveImage, then after saving we can get the path by saver.last_saved_filename cc @ericspod
/build |
…aTensor.__str__` for easier identification (Project-MONAI#6214) Discussed in Project-MONAI#6213 ### Description Prepends `"meta"` to the `MetaTensor.__repr__` and `MetaTensor.__str__` output so printing a MetaTensor does not look the exact same as a regular `torch.Tensor`. I don't expect this change to cause any breaks, with me running the risk of invoking [xkcd 1172](https://xkcd.com/1172/). --- 1 failure in `./runtests.sh -f -u --net --coverage`: ```text ====================================================================== FAIL: test_values (tests.test_tciadataset.TestTciaDataset) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\PythonProjects\MONAI-SaveImageFormatting\tests\test_tciadataset.py", line 72, in test_values self.assertTrue( AssertionError: False is not true ``` ### 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). - [x] New tests added to cover the changes. - [x] 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. --------- Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
…age` and `SaveImaged` transforms (Project-MONAI#6213) Improves issues discussed in Project-MONAI#6188 . ### Description As I found out in Project-MONAI#6188, `SaveImage` and `SaveImaged` provide a fairly rigid way to define the output path. I've made some changes that allow the user to more easily define their own `FolderLayout` derivative, and pass it to these transforms. Additionally, I've added a boolean that adds a key `"saved_to"` to the metadata, so the user can more easily assess where their output actually went. Finally, and most optionally, I've prepended `"meta"` to the `MetaTensor.__repr__` and `MetaTensor.__str__` outputs in an effort to more clearly show to the user that the printed tensor has special properties. This change was made in its own commit, which can be left out if undesired. Other small changes to documentation formatting, mainly changing: ```text """ ... some documentation `code` more docs ... """ ``` to ```text """ ... some documentation ``code`` more docs ... """ ``` To format these correctly in the docs. Seemed like some people assumed the single backticks would format as `code`, as opposed to _italics_. --- ### Test results `./runtests.sh -f -u --net --coverage` results: 1 failure, 2 errors The failure was related to me changing the `MetaTensor.__repr__`, fixed the test in a separate commit `./runtests.sh --quick --unittests --disttests` In progress ### 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). - [x] 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. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
…aTensor.__str__` for easier identification (Project-MONAI#6214) Discussed in Project-MONAI#6213 ### Description Prepends `"meta"` to the `MetaTensor.__repr__` and `MetaTensor.__str__` output so printing a MetaTensor does not look the exact same as a regular `torch.Tensor`. I don't expect this change to cause any breaks, with me running the risk of invoking [xkcd 1172](https://xkcd.com/1172/). --- 1 failure in `./runtests.sh -f -u --net --coverage`: ```text ====================================================================== FAIL: test_values (tests.test_tciadataset.TestTciaDataset) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\PythonProjects\MONAI-SaveImageFormatting\tests\test_tciadataset.py", line 72, in test_values self.assertTrue( AssertionError: False is not true ``` ### 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). - [x] New tests added to cover the changes. - [x] 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. --------- Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
…age` and `SaveImaged` transforms (Project-MONAI#6213) Improves issues discussed in Project-MONAI#6188 . ### Description As I found out in Project-MONAI#6188, `SaveImage` and `SaveImaged` provide a fairly rigid way to define the output path. I've made some changes that allow the user to more easily define their own `FolderLayout` derivative, and pass it to these transforms. Additionally, I've added a boolean that adds a key `"saved_to"` to the metadata, so the user can more easily assess where their output actually went. Finally, and most optionally, I've prepended `"meta"` to the `MetaTensor.__repr__` and `MetaTensor.__str__` outputs in an effort to more clearly show to the user that the printed tensor has special properties. This change was made in its own commit, which can be left out if undesired. Other small changes to documentation formatting, mainly changing: ```text """ ... some documentation `code` more docs ... """ ``` to ```text """ ... some documentation ``code`` more docs ... """ ``` To format these correctly in the docs. Seemed like some people assumed the single backticks would format as `code`, as opposed to _italics_. --- ### Test results `./runtests.sh -f -u --net --coverage` results: 1 failure, 2 errors The failure was related to me changing the `MetaTensor.__repr__`, fixed the test in a separate commit `./runtests.sh --quick --unittests --disttests` In progress ### 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). - [x] 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. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Mathijs de Boer <m.deboer-41@umcutrecht.nl>
Improves issues discussed in #6188 .
Description
As I found out in #6188,
SaveImage
andSaveImaged
provide a fairly rigid way to define the output path. I've made some changes that allow the user to more easily define their ownFolderLayout
derivative, and pass it to these transforms.Additionally, I've added a boolean that adds a key
"saved_to"
to the metadata, so the user can more easily assess where their output actually went.Finally, and most optionally, I've prepended
"meta"
to theMetaTensor.__repr__
andMetaTensor.__str__
outputs in an effort to more clearly show to the user that the printed tensor has special properties. This change was made in its own commit, which can be left out if undesired.Other small changes to documentation formatting, mainly changing:
to
To format these correctly in the docs. Seemed like some people assumed the single backticks would format as
code
, as opposed to italics.Test results
./runtests.sh -f -u --net --coverage
results: 1 failure, 2 errors
The failure was related to me changing the
MetaTensor.__repr__
, fixed the test in a separate commit./runtests.sh --quick --unittests --disttests
In progress
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.