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

Image space and World Space convert transforms #7942

Merged
merged 67 commits into from
Aug 29, 2024

Conversation

KumoLiu
Copy link
Contributor

@KumoLiu KumoLiu commented Jul 23, 2024

Fixes # .

Description

Add ImageToWorldSpace and WorldToImageSpace

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@KumoLiu KumoLiu changed the base branch from dev to geometric July 23, 2024 08:38
Signed-off-by: YunLiu <[email protected]>
@vikashg
Copy link

vikashg commented Jul 25, 2024

Hey @KumoLiu, I am going over the code. Can you please share the data spleen_60.nii.gz along with the .mrk.json file in a google drive?
Did you use Monai Label to annotate this?

Signed-off-by: YunLiu <[email protected]>
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Jul 26, 2024

Hey @KumoLiu, I am going over the code. Can you please share the data spleen_60.nii.gz along with the .mrk.json file in a google drive? Did you use Monai Label to annotate this?

Sure, I have uploaded the Google Drive link. I annotated it by using 3d slicer.

@atbenmurray
Copy link
Contributor

My apologies, I had to write slides for a presentation today and I've had no time to review this yet.

Signed-off-by: YunLiu <[email protected]>
@vikashg
Copy link

vikashg commented Jul 26, 2024

Thanks @KumoLiu I am going over it.

Signed-off-by: YunLiu <[email protected]>
Signed-off-by: YunLiu <[email protected]>
@vikashg
Copy link

vikashg commented Jul 31, 2024

Hello Yun,
Thanks for sharing the images. The code looks all right to me and it is quite clear to me what you are trying to do. I will suggest to test 2 things if you can (I would have but I do not have slicer installed)

  1. I looked at the image and it has the spacing as (0.792, 0.792, 5.0). In the test case you have marked all the points in the same plane. For the sake of completeness can you please mark few points in a different plane and check that they too are transformed correctly. I do not see a reason why it would not. But it is just a good idea to make sure.

  2. I see that you have marked the points on the axial plane (lets call it xy plane), where the pixel spacing is same in both x and y directions. Can you please mark few points in the coronal or sagittal planes and do the transformation. It will ensure that we are transforming the points correctly when the spacing is not same in both directions.

Again, I must say, I do not think that there will be a problem, but just to make sure it works in the aforementioned cases.
Thanks once again

vikashg
vikashg previously approved these changes Aug 1, 2024
Copy link

@vikashg vikashg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for testing the coronal and sagittal pieces @KumoLiu.

Signed-off-by: YunLiu <[email protected]>
Signed-off-by: YunLiu <[email protected]>
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Aug 27, 2024

/build

Signed-off-by: YunLiu <[email protected]>
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Aug 28, 2024

Hi @vikashg @atbenmurray @aylward @mingxin-zheng @Nic-Ma, do you have any further comments? Otherwise I will try to merge this one. Thanks.

@vikashg
Copy link

vikashg commented Aug 28, 2024

Hey Yun,
Give me couple of hours I am going over it right now. ok

Thanks

monai/transforms/utility/array.py Outdated Show resolved Hide resolved
monai/transforms/utility/array.py Outdated Show resolved Hide resolved
monai/transforms/utility/array.py Show resolved Hide resolved
monai/transforms/utility/dictionary.py Show resolved Hide resolved
monai/transforms/utility/dictionary.py Outdated Show resolved Hide resolved
monai/transforms/utility/array.py Show resolved Hide resolved
@vikashg
Copy link

vikashg commented Aug 28, 2024

Hey @KumoLiu,
I have created this gist to test the workings of the code. I wanted to test how an inplane rotation is working. Please have a look at the code to ensure that I am using all the options in ApplyTransformToPointsd correctly.
This was the original image
test
After rotation I get the following image
test_rot

Also, please add ApplyTransformToPointsd and ApplyTransformToPoints in the /monai/transforms/__init__.py file.
I think we are almost there, just a few things as @mingxin-zheng also mentioned about the documentation needs to be corrected/modified.
Thanks so much for working on this.

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Aug 28, 2024

Hi @mingxin-zheng @vikashg, add the use case description in the docstring. please help take a look whether it makes clearer to you, thanks!

@mingxin-zheng
Copy link
Contributor

Hi @mingxin-zheng @vikashg, add the use case description in the docstring. please help take a look whether it makes clearer to you, thanks!

Thanks and it looks good to me!

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Aug 28, 2024

Hi @vikashg, I take a look at your gist. The issue is that you need transform the point in the world space but you are transform the data already in the image space.
you can get world space point using:

coordinates_world_axial = np.array([i['position'] for i in data_axial['markups'][0]['controlPoints']])

Signed-off-by: YunLiu <[email protected]>
Signed-off-by: YunLiu <[email protected]>
Signed-off-by: YunLiu <[email protected]>
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Aug 28, 2024

/build

@vikashg
Copy link

vikashg commented Aug 28, 2024

Thanks @KumoLiu. That solves it.

Signed-off-by: YunLiu <[email protected]>
Signed-off-by: YunLiu <[email protected]>
Copy link

@vikashg vikashg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KumoLiu Really appreciate all the hard work you have put on this. Looks great to me.

@KumoLiu
Copy link
Contributor Author

KumoLiu commented Aug 28, 2024

/build

@KumoLiu KumoLiu merged commit 298a8d6 into Project-MONAI:geometric Aug 29, 2024
28 checks passed
@KumoLiu KumoLiu deleted the world2image branch August 29, 2024 02:09
KumoLiu added a commit to KumoLiu/MONAI that referenced this pull request Aug 29, 2024
Fixes # .

### Description
Add `ImageToWorldSpace` and `WorldToImageSpace`

### 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).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <[email protected]>
Co-authored-by: Mingxin Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants