-
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
Expose ITK Image to MONAI MetaTensor conversion #5897
Conversation
c9ea563
to
8819fc2
Compare
7b1e62f
to
3de1ed9
Compare
ddad44d
to
574cd99
Compare
c27524f
to
f9b9aed
Compare
@ntatsisk Thank you for fixing the issues described in the discussion of your PR! I've added your latest three commits, so InsightSoftwareConsortium/itk-torch-transform-bridge@12f4d4b InsightSoftwareConsortium/itk-torch-transform-bridge@37cc4f9 and InsightSoftwareConsortium/itk-torch-transform-bridge@7a253b2. |
Thanks @Shadow-Devil! Yes, increasing the tolerance is one option. You could also copy-paste the output of a random array and keep it fixed, or another way is to set a value for the random seed. I am not aware what is the most common approach in the rest of the monai codebase. |
Since most of this test uses Another problem I saw within the pipeline is that a testcase is requesting too much memory. Should we skip this test in the quick run? How can I do that? |
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
…ernal functions private Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
…o_metatensor and partly fix dtype warning Signed-off-by: Felix Schnabel <[email protected]>
ebc4830
to
3513fd1
Compare
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
@ntatsisk Didn't you want both ITKImage -> Metatensor and Metatensor -> ITKImage conversions in this PR? |
I think we can create the function, the implementation could be just a thin wrapper of this logic :
|
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
Signed-off-by: Felix Schnabel <[email protected]>
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, it looks nice,
I'll fix a few style issues and merge it soon.
there is a warning message from this call np.dtype(itk.D)
:
in the future the `.dtype` attribute of a given datatype object must be a valid dtype instance. `data_type.dtype` may need to be coerced using `np.dtype(data_type.dtype)`. (Deprecated NumPy 1.20)
perhaps we should think about proper methods of getting equivalent dtypes like this
MONAI/monai/utils/type_conversion.py
Lines 29 to 39 in f5708ea
"get_numpy_dtype_from_string", | |
"get_torch_dtype_from_string", | |
"dtype_torch_to_numpy", | |
"dtype_numpy_to_torch", | |
"get_equivalent_dtype", | |
"convert_data_type", | |
"get_dtype", | |
"convert_to_cupy", | |
"convert_to_numpy", | |
"convert_to_tensor", | |
"convert_to_dst_type", |
Signed-off-by: Wenqi Li <[email protected]>
Hi @Shadow-Devil , @wyli. Thanks again for all this amazing work done here! I might visit again my two PRs to see if it is possible:
What do you think is preferable: wait for a couple of weeks before merging, or merge now and append any changes later in monai? |
thanks @ntatsisk, please feel free to create follow-up feature/pull requests... I think this PR is a fairly self-contained starting point. also, perhaps we should have a meeting to discuss an overall design and roadmap, for example a possible direction is towards an object-oriented approach like InsightSoftwareConsortium/itk-torch-transform-bridge#6 (comment) please let me know @Shadow-Devil @ntatsisk if you are interested in this topic. |
Signed-off-by: Wenqi Li <[email protected]>
/build |
If there is interest in this, I'm happy to participate and/or share updated code. |
Great to see this merged! It will be really valuable to us over (ITK)Elastix (InsightSoftwareConsortium/ITKElastix#126). Good job! 🎉 @wyli, Thanks for the reply, I might come back with more PRs then :). Related to your suggestion, I am always interested for further bridging opportunities, and a meeting would also be a nice opportunity to meet as well! |
I, too, am glad to see this merged. It will make my life easier with #5711. |
@ntatsisk Really looking forward to a solution with respect to different image sizes. That's the only bigger limitation I'm aware of right now. |
Sorry for the late response. I won't join this meeting, since this was my first encounter with ITK, so there isn't much I could contribute. I hope you will find a good design/roadmap for further development. |
Fixes #5708
Fixes #4117
Description
This is a migration of the PR InsightSoftwareConsortium/itk-torch-transform-bridge#6 into MONAI.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.