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

Modify pixdim to original_pixdim in meta dict #6840

Open
KumoLiu opened this issue Aug 8, 2023 · 4 comments · May be fixed by #8269
Open

Modify pixdim to original_pixdim in meta dict #6840

KumoLiu opened this issue Aug 8, 2023 · 4 comments · May be fixed by #8269

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 8, 2023

Is your feature request related to a problem? Please describe.
Follow up of #6832, after Spacing, the original pixdim is not modified in meta dict, which may cause some confusion.

Describe the solution you'd like
Would be better to update it to original_pixdim.
Similar to affine.

header[MetaKeys.ORIGINAL_AFFINE] = self._get_affine(i, self.affine_lps_to_ras)
header[MetaKeys.SPACE] = SpaceKeys.RAS if self.affine_lps_to_ras else SpaceKeys.LPS
header[MetaKeys.AFFINE] = header[MetaKeys.ORIGINAL_AFFINE].copy()

@IamTingTing
Copy link

IamTingTing commented Dec 13, 2024

Hi @KumoLiu , I'm working on this issue with @slicepaste and @einsyang723. We would like to clarify the meaning of original_pixdim mentioned in the request. Does it refer to the pixel dimension of the original image or the previous image? Like, we have an image that becomes a second image after spacing, and then a third image after spacing again. In this case, does original_pixdim refer to the dimension of the very first image or the second image?

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Dec 13, 2024

Hi @KumoLiu , we're working on this issue. We would like to clarify the meaning of original_pixdim mentioned in the request. Does it refer to the pixel dimension of the original image or the previous image? Like, we have an image that becomes a second image after spacing, and then a third image after spacing again. In this case, does original_pixdim refer to the dimension of the very first image or the second image?

Hi @IamTingTing, this refers to the "original image" before any operations are performed.

From your example: "We have an image that becomes a second image after spacing, and then a third image after spacing again," it specifically means the pixdim of the first image, before any spacing adjustments.

And BTW to be simple, we can only update the pixdim in the meta dict to the original_pixdim since data.pixdim is logging the correct(current) pixdim.

@slicepaste
Copy link
Contributor

slicepaste commented Dec 13, 2024

Hi @IamTingTing, this refers to the "original image" before any operations are performed.

From your example: "We have an image that becomes a second image after spacing, and then a third image after spacing again," it specifically means the pixdim of the first image, before any spacing adjustments.

And BTW to be simple, we can only update the pixdim in the meta dict to the original_pixdim since data.pixdim is logging the correct(current) pixdim.

Hi @KumoLiu ,
I appreciate the feedback regarding the change of pixdim to original_pixdim. However, I think maybe it would be better to ensure consistency between pixdim and affine in the code.

Currently, affine is handled as follows:

data.affine
data['affine']
data['original_affine']

Perhaps pixdim should follow the same structure, like:

data.pixdim
data['pixdim']
data['original_pixdim']

It may be more intuitive as both parameters follow the same pattern, instead of updating pixdim to original_pixdim.
What do you think about this suggestion?

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Dec 13, 2024

Hi @slicepaste, yes we can follow the same structure.

slicepaste added a commit to slicepaste/MONAI that referenced this issue Dec 23, 2024
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 <[email protected]>
Co-authored-by: einsyang723 <[email protected]>
Co-authored-by: IamTingTing <[email protected]>
@slicepaste slicepaste linked a pull request Dec 23, 2024 that will close this issue
7 tasks
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.

3 participants