-
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
2620 3595 Writer backend selector, deprecating nifti_saver/writer, png_saver/writer #3773
Conversation
c122c0e
to
a934a49
Compare
88b00c0
to
c4e23df
Compare
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.
Looks good to me!
Hi @wyli , Thanks for the quick update. Thanks. |
/black |
a4df129
to
d55e922
Compare
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
6b2e6d8
to
f86ce2b
Compare
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
fmt = f"{ext_name}".lower() | ||
existing = look_up_option(fmt, SUPPORTED_WRITERS, default=()) | ||
all_writers = im_writer + existing | ||
SUPPORTED_WRITERS[fmt] = all_writers |
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.
Hi @wyli ,
Here you use a global dictionary to store the supported format
-> writers
mapping, while in the image readers we store readers
in LoadImage
transform with its own supported formats
, for example:
https://github.com/Project-MONAI/MONAI/blob/dev/monai/data/image_reader.py#L386
I am not very sure which way is better, the readers
way is similar to the Chain of Responsibility
design pattern, This global SUPPORTED_WRITERS
may be not easy to maintain, especially in multi-threads cases, etc.
Maybe because I was Java / C++ developer before, I usually never use global variables even in python. I prefer to use class
to implement complicated logic, because it can maintain self-contained
local states. For example you implemented FolderLayout
as a class instead of a function.
Glad to see your opinions.
@ericspod @rijobro What do you guys think?
Thanks in advance.
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.
it's a global dict accessed without global keyword.. I believe it's aSUPPORTED_WRITERS
is a module-level variable, it's not a global one.
very common design, for example, scikit-image and PIL used it in a similar way
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.
OK, I am not sure whether it can work fine if calling SaveImage
in multi-thread? I think all our non-random
transforms are thread-safe
now.
Thanks.
Hi @wyli , Thanks for the quick implementation, put some comments inline, I will review the Thanks. |
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
67826e8
to
01853a6
Compare
/integration-test |
/build |
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
/build |
Signed-off-by: Wenqi Li <wenqil@nvidia.com>
696c77e
to
0152543
Compare
/build |
closes #3595
closes #2620
Description
this is to add a
resolve_writer
andregister_writer
,update
monai.transform.SaveImage
to use the latest API.Status
Ready
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.