-
Notifications
You must be signed in to change notification settings - Fork 196
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
DeepEdit click based refinement seems to be adding segmentation on wrong side #1407
Comments
DICOM and most (if not all) medical imaging software uses right-handed coordinate system. How did you end up with a left-handed one (LAS)? You may need to resample your image to be in a left-handed coordinate system. |
Not sure, however it shouldn't matter because of the orientationD transform defined in the infer and training pre transforms re orientating all volumes to RAS anyway? |
It should not matter which right-handed coordinate system you use. If you use a left-handed coordinate system in the image then the image to physical coordinate system transformation matrix will have a negative determinant, which may cause problems in some algorithms. It is also possible that the matrix is orthogonalized somewhere along the way by computing the third axis from the cross product of two other axes, which works perfectly for any right-handed coordinate system but will flip an image axis for images that have left-handed coordinate system. I would recommend to try with images in LPS and RAS coordinate systems and if they all work well then most likely the issue is the left-handed coordinate system. If that's the case then MONAILabel should at least fail with an error instead of silently doing something wrong. |
I called nib.as_closest_canonical(img) on each pancreas volume and corresponding mask to re orientate my dataset into RAS prior to training however I am noticing the same issue. |
In addition, you could check the meta information, whether it's normal. MONAI Label takes the meta info and do reorientation/resample transform...etc. If the meta is not in correctly set, it may result in the wrong reorientation... |
sorry can you point to me which file / function this step is done? Still getting used to the framework. Though im beginning to suspect its more to do with the infer process rather than the training process. If the clicks were being incorrectly simulated the training loss should not decrease. I think this is to do with how the clicks im defining via slicers GUI are being assigned to a specific voxel. |
@diazandr3s can you fix the pre-transform to take care of click points if you are doing a flip (orientation) on the original image.. |
Why would the original image be getting flipped if its already been re orientated to RAS by the nibabel.as_closest_canonical() function? |
Sure! More than happy to help with this. I just wanted to ensure we are "collecting" and sending the clicks with the correct orientation. Unless the issue is what @lassoan mentioned. @VishalJ99 I think this is what you were asking: https://github.com/Project-MONAI/MONAILabel/blob/main/plugins/slicer/MONAILabel/MONAILabel.py#L936-L958 That's the function that processes the clicks. Specifically these two lines: https://github.com/Project-MONAI/MONAILabel/blob/main/plugins/slicer/MONAILabel/MONAILabel.py#L936-L958 @VishalJ99 is this happening with all CTs? |
No, for the spleen CT dataset downloaded with the example radiology app, there were no such issues. This issue arises when I tried to train a deepedit model with the same training and infer configs (except for modifying label names and choosing to not use a pre trained model) to do MRI pancreas segmentation. thanks for the links! Will compare how the points are being recorded for a click made on the spleen CT volumes vs the pancreas. |
2nd update: However, when loading this same volume with the modified header in via monai labels slicer plugin (clicking next sample), for some reason this change is reset such that the top left corner again has i = 0 (as shown in the picture attached in the previous post). Currently checking why loading in the volume via the monai label plug in does this... |
Meanwhile you can try deep grow 2d and 3d models.. if that helps |
Thanks for all the updates, @VishalJ99. I'm planning to work on this early next week. |
@diazandr3s sounds good, happy to help in any capacity. |
Hi @VishalJ99, I checked this issue and it seems it is more about the combination of the image header and the reader you use. Can you please try removing or changing the reader's argument in this line? https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/radiology/lib/infers/deepedit.py#L77 You could try something like this:
Or this
Hope this helps, |
Hi @VishalJ99, I've opened a PR to solve the click orientation issue: #1537 Looking forward to hearing from you, |
Sure will check tomorrow so just to make sure i understand what it is I am checking can you confirm the following? loading in a pancreas case with an orientation of RAS and Qform code of 0 and sform code of 2 I should expect the clicks to map onto the original volume correctly. My current solution is to modify the Q form and S form codes to 1 which has worked for me so far. |
Thanks, @VishalJ99. |
If you work with NIFTI file format then unfortunately you'll always run into image orientation issues, because this file format uses a complex and redundant way of representing image orientation. People who develop and use NIFTI has been unable to clean up the mess - they cannot agree how to resolve ambiguities and some of them don't even acknowledge that there is an problem. I would recommend to use DICOM if you want to preserve all metadata in a very structured and standard way; or use NRRD if you only need simple image storage (with some basic optional custom metadata). |
Ive taken the default radiology app and used it to train a deepEdit model to do volumetric MRI pancreas segmentation.
The auto segmentation works well however I am experiencing a strange issue when I try and make click based refinements.
Here is an example. This is the auto segmentation generated by the model:
You can see the right side could use further filling in so i add a foreground click in the desired region and the segmentation is updated to give the following:
The refinement seems to be based on a click that was defined on the left side when I placed it on the right...
Here is the output when I purposefully define the click on the wrong side:
i get the desired output.
I do not experience this issue when making click based refinements on a model trained on the CT spleen dataset downloaded from monai labels example datasets. I have not made any changes to any files other than renaming the labels.
The only explanation i can think of is that my input data is of orientation LAS whereas the CT spleen data is of orientation RAS.
However, i noticed that in the training and infer pre transforms, one of the transforms defined is the orientationD transform which re orientates the volumes to RAS, so this should not cause any issue...
The text was updated successfully, but these errors were encountered: