-
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
Applying Transform Chain to Geometric Objects #4027
Comments
We really need to make progress on this PR before adding in point transforms (which is definitely on our agenda). |
Just to add that MONAI Deploy App SDK has added the STL generation from volume segmentation image, closed issue and PR. For generating DICOM RTStruct instance, for use in radiotherapy planning, the contour(s) of segment(s) on each segmentation image slice need to be calculated, with and without smoothing applied. I had plans to implement this using cv2 (more like porting from a earlier impl), though a utility/transform in MONAI core is better and can be for more general use. |
Thanks for the feedback, I agree with the requirements for point transforms, we are working in this direction. Thanks. |
As we consider more and more non-image data the architecture we use to integrate those transforms has to be considered. I'm not sure having a separate section in the transforms for geometric transforms is the way to go, but instead these would be treated at the same level as image transforms. A transform such as |
HI @ericspod Yes what are the other nonimage data are you thinking of. The only thing other than the geometric object I can think of is Text and audio data which are a whole different ball game altogether. It is true that the RandAffine can handle point cloud data as it is just matrix multiplication. Maybe we should throw in some examples together like a proper workflow with image and geometric data together. I will think of some and push a notebook and see if we may need some wrappers over the core functions. |
So @ericspod, if I choose to apply a rotation matrix to a set of points say something like this
I do get the expected error about
However, the shape do not make much sense when you want to apply the transforms to a set of points. If i give a spatial size which might be the same as the image domain, I get the following error
Maybe if there is a hook to extract the transformation matrix we can do the matrix multiplications discussed during the meetings. I think if I dig deeper, i could hack some code that works but as of now the implementation is not particularly straight forward. I tried to find some solutions and @dongyang0122 also said that they are working on it #4024 (reply in thread) |
The error I get for
relates to spatial shape because points are understood: |
Is someone still working on this? |
Hi @jejon we do want to implement this but currently our priorities for the next release is on enhancing bundles and their usability for new and experienced MONAI users. We also want to focus on integrating the generative models project into the core repo. For the following release this is one feature that we all feel is important and likely will be a priority then. |
I'll mention again that we should be looking at how other libraries do transforms and to keep geometric neural networks in mind which is a major use cases for these sorts of transforms, eg.: https://pytorch-geometric.readthedocs.io |
Hi @ericspod , Thanks for sharing the pytorch geometric project, very inspiring. Thanks. |
In theory we should be able to adapt these transforms to MONAI quite simply. The base transform is just another callable so I suppose we could use these with |
All of our spatial transforms have the ability to produce matrices describing the transform already. They just have different code-paths for when they are operating lazily or not. When they aren't operating lazily, the transform is calculated but then just put in applied transforms as if it had been used to perform the transform. When they are operating lazily, it goes on the pending list to be applied subsequently. Strictly speaking, we could put in a code path to every transform that applies the matrix to geometric data structures like points and meshes, but I'd like to propose that we go a bit further. I'm going to try to sell the refactoring I did on the lazy resampling branch that refactored all the spatial transforms to use the same code path for lazy and non-lazy routes again. If all spatial transforms always work in terms of matrices (or deformation grids) then all we need is the ability to apply a matrix or grid to the appropriate data structure adapted from https://github.com/pyg-team/pytorch_geometric/blob/master/torch_geometric/data/data.py#L469 A pure spatial transform can be found here. It's a bit long so I'll just post the link: |
Hi all, I investigated more about https://pytorch-geometric.readthedocs.io/ and found that it's not easy to be compatible with the use cases in MONAI. For "pytorch-geometric", there is no concept of image, it refers to the cartesian coordinate system, but for detection, the transforms of the data refer to the center of the image. Here I give a simple example with image size (10, 10), box size(2, 4) and flip it with pytorch-geometric and MONAI.
The red line represents the original image, and the red dotted line represents the original bounding box. The green and blue colors represent the results after the MONAI and Geometric Flip, respectively. We can find that the blue box is outside of the image which may not meet our requirements. In summary, I propose we integrate the existing box transforms into the core. We can think of the operation on the box as an operator to integrate into the existing transform. If there are no other concerns, I'll try to create a draft PR first.
|
Is your feature request related to a problem? Please describe.
Sometimes we need to apply transforms to geometric objects (point clouds, lines, curves, and meshes), particularly in radiotherapy planning and object detection.
Describe the solution you'd like
A good solution would be a branch core library that can handle all the geometric transforms while accounting for the image metadata like image spacing and size. A geometric transform chain should be callable in a similar way as we call the regular image transforms. Something like
In an ideal case when we have an image annotation pair. We apply the same set of transformation to both objects. But for geometric objects there should be some way of passing messages to the annotations transform chain. For example you are rotating images and annotations. You can apply the rotation to the annotation, but after rotation the size of the image changes in different axes and sometimes it is important that the geometric transform should know about these changes for accurately applying the transforms. So there should be a message passing mechanism between two transform chains. More relevance in discussion #4024
Describe alternatives you've considered
I have written my own transforms to do all these things but it is a bit hacky and not standardized. I have my geometric labels from open-source tools like labelme. My code handles labelme annotations (in a json) but going in I think we will need to have support for STL, DICOM RT annotations.
Additional context
If there are some people working on it, please let me know as I have been working on it and will like to contribute to this branch.
The text was updated successfully, but these errors were encountered: