-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update ['pixdim'] after Spacing transform in meta dict. #8269
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
base: dev
Are you sure you want to change the base?
Conversation
According to the issue, this PR addresses on the meta dictionary `data['pixdim']` of NIfTI images does not update after applying the `spacing` or `spacingd`. To align with `affine`, we update `data['pixdim']` and keep the original metainfo in `data['original_pixdim']`. Additionally, this PR also update the metainfo `key_{meta_key_postfix}['pixdim']` in NIfTI images, consistent with `spaced_data_dict['image_meta_dict']['pixdim']` in issue Project-MONAI#6832. Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
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 contribution! Leave several comments inline.
Hi folks. I had a look through the code and the PR, but I need to do a deeper evaluation of how this intersects with lazy resampling and the consistency of behaviour between MetaTensor and _meta_dict modes |
In the middle of extending test scenarios. Please bear with me. |
@einsyang723 @IamTingTing The current PR is not our final version, and it has remained unchanged for a while. |
Previously, a method was defined in `meta_tensor`, and using `data_array.clone()` introduced additional costs. After reevaluating the code, modifying the `TraceableTransform.track_transform_meta()` method executed by `SpatialResample` makes it much cleaner and more maintainable. Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Previously, a method was defined in `meta_tensor`, and using `data_array.clone()` introduced additional costs. After reevaluating the code, modifying the `TraceableTransform.track_transform_meta()` method executed by `SpatialResample` makes it much cleaner and more maintainable. Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Picking this up again. Will have a review for you all today. |
According to the issue, this PR addresses on the meta dictionary `data['pixdim']` of NIfTI images does not update after applying the `spacing` or `spacingd`. To align with `affine`, we update `data['pixdim']` and keep the original metainfo in `data['original_pixdim']`. Additionally, this PR also update the metainfo `key_{meta_key_postfix}['pixdim']` in NIfTI images, consistent with `spaced_data_dict['image_meta_dict']['pixdim']` in issue Project-MONAI#6832. Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com>
Previously, a method was defined in `meta_tensor`, and using `data_array.clone()` introduced additional costs. After reevaluating the code, modifying the `TraceableTransform.track_transform_meta()` method executed by `SpatialResample` makes it much cleaner and more maintainable. Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Checking all dictionary keys that start with `{key}_` to support custom settings of `meta_keys` and `meta_key_postfix`. This ensures that no matter how users configure the naming conventions in `LoadImaged`, we can correctly synchronize metadata from the MetaTensor to the corresponding meta dictionary. Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
Signed-off-by: Wei_Chuan, Chiang <jamesis1356@gmail.com> Co-authored-by: einsyang723 <tina910723@gmail.com> Co-authored-by: IamTingTing <6121smile@gmail.com>
@einsyang723 @slicepaste @ericspod @KumoLiu @IamTingTing |
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.
The change made in monai/transforms/spatial/dictionary.py means the issue that I raised is much less relevant now
@atbenmurray Thank you for the approval. Just to confirm our understanding — this PR can be merged first, and the remaining concerns regarding |
Exactly. Yes. This PR is decoupled from PR #8411 now. |
Thanks for the confirmation. Looking forward to the merge! |
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.
I think everything has been addressed here, @KumoLiu please trigger blossom and we'll integrate this soon. Thanks!
Fixes #6840
Description
According to the issue, this PR addresses on the meta dictionary
data['pixdim']
of NIfTI images does not update after applying thespacing
orspacingd
. To align withaffine
, we updatedata['pixdim']
and keep the original metainfo indata['original_pixdim']
. Additionally, this PR also update the metainfokey_{meta_key_postfix}['pixdim']
in NIfTI images, consistent withspaced_data_dict['image_meta_dict']['pixdim']
in issue #6832.Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.