Closed eduran90 closed 1 year ago
Hi Elvis,
Just to try something first, could you please try switching the terms of moving and fixed? resampled_moving = register_images_with_dicom_reg(fixed_image=moving_image, moving_image=fixed_image, dicom_registration=dicom_registration) And see if they overlap? If so, but you want the opposite, I can work on adding a parameter to return this.
Sorry the program is a little bit wonky, it was very much a labor of necessity
Thanks! Brian
Hi Brian,
Here's what happens after switching the terms:
Still no overlap. Thanks.
Is there anyway you could anonymize the DICOM and upload to a google drive for me to try and work on?
Thank you! Brian
Hi Brian,
I figured out that the issue was the DICOM image reader I was using.
Previously, I was using the following code to read the image series: image_path = 'path to image' reader = DicomReaderWriter() reader.down_folder(image_path) reader.get_images() image_sitk = sitk.GetImageFromArray(reader.ArrayDicom)
After replacing these lines with the following ones, the code worked well: reader = sitk.ImageSeriesReader() dicom_names = reader.GetGDCMSeriesFileNames(image_path) reader.SetFileNames(dicom_names) image_sitk = reader.Execute()
After executing the code, the images look aligned:
There might be an issue on how the DicomReaderWriter() reads the images in this case.
Thank you!
Hey Elvis,
Based on that information, the issue isn't with the ReaderWriter, but with how you used it. The main problem is that NumPy arrays inherently do not have any information on slice thickness, origin, or direction. When you created image_sitk from the reader.ArrayDicom, it's scrubbed all the info, as it would for any NumPy array turned into a sitk handle.
image_sitk = sitk.GetImageFromArray(reader.ArrayDicom)
You can get the correct result by using
image_sitk = reader.dicom_handle # This IS the sitk image that you're now getting the other way
Check this out, particularly the section titled 'Be wary of NumPy'
Glad you got everything working though! Although I hope the DICOM RT Tool can still be useful to you.
Best, Brian
Thanks much for the explanation Brian, and will definitely keep using the DicomRTTool, which has made my life much easier when working with these files.
Best. Elvis
On Sat, Mar 11, 2023, 7:28 PM Brian Mark Anderson, PhD < @.***> wrote:
Hey Elvis, Based on that information, the issue isn't with the ReaderWriter, but with how you used it. The main problem is that NumPy arrays inherently do not have any information on slice thickness, origin, or direction. When you created image_sitk ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hey Elvis,
Based on that information, the issue isn't with the ReaderWriter, but with how you used it. The main problem is that NumPy arrays inherently do not have any information on slice thickness, origin, or direction. When you created image_sitk from the reader.ArrayDicom, it's scrubbed all the info, as it would for any NumPy array turned into a sitk handle.
image_sitk = sitk.GetImageFromArray(reader.ArrayDicom)
You can get the correct result by using
image_sitk = reader.dicom_handle # This IS the sitk image that you're now getting the other way
Check this out, particularly the section titled 'Be wary of NumPy' @.**/part-1-python-and-dicom-two-easy-tools-to-save-time-and-energy-when-working-with-medical-images-b71a3e2e2800id_token=eyJhbGciOiJSUzI1NiIsImtpZCI6IjI1NWNjYTZlYzI4MTA2MDJkODBiZWM4OWU0NTZjNDQ5NWQ3NDE4YmIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJuYmYiOjE2Nzg1ODQwMTYsImF1ZCI6IjIxNjI5NjAzNTgzNC1rMWs2cWUwNjBzMnRwMmEyamFtNGxqZGNtczAwc3R0Zy5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsInN1YiI6IjEwMjY5OTgzMDg3OTAzNDkzODAwOSIsImVtYWlsIjoibWFya2JhMTIyQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhenAiOiIyMTYyOTYwMzU4MzQtazFrNnFlMDYwczJ0cDJhMmphbTRsamRjbXMwMHN0dGcuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJuYW1lIjoiQnJpYW4gQW5kZXJzb24iLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUdObXl4WWJyZjg3bjVQWkU2OUVGU05kemNyWDYyZmRMV1FuYmNFWE9xd2g9czk2LWMiLCJnaXZlbl9uYW1lIjoiQnJpYW4iLCJmYW1pbHlfbmFtZSI6IkFuZGVyc29uIiwiaWF0IjoxNjc4NTg0MzE2LCJleHAiOjE2Nzg1ODc5MTYsImp0aSI6ImNhYTg0NzY3NDY0YmFmODcxMDQyMGMxM2QzOTA0NTczMjRhMmUxM2IifQ.dkLkPshkR89yRe-IUHBiFKqg_OhrU056C7WkjKR69bpQOzzrqCmCQ5GSh-sa3maKi-mbD5Yv2BoCiMtqSSjOW-7oaiZg403x2qfOEjGFMNlYCkbO2WgarAWxvwIWXan_b8howy-BbhVxQpUP9gT8bESRNe5dzTmOa8rwruWFYhduRLgVFHd075YtsC7v2xbXtk4RSiMxvZ8jg3-1z3m3ST-fSLdf90Cn9eBYB2ysin4sFhNuA7fAGkN7fmvEwYorUHmQAyiKtVTRkwN-Nh2hiTSsnJdspg5xUWZrT0G1babgx6oqpvGm-r05lX_MSKlz02yGnxIeSSqTP-zU-eb8Ww__;Iw!!KwNVnqRv!EHixIiJabGURWdR3zBssFpCqEI2kk2zXVX0axHmgm0SO6jELjXXZavl4uBpicWOqZpuqjNazJEa04YJqfaKXlyM$>
Glad you got everything working though! Although I hope the DICOM RT Tool can still be useful to you.
Best, Brian
— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/brianmanderson/RegisteringImages/issues/1*issuecomment-1465065855__;Iw!!KwNVnqRv!EHixIiJabGURWdR3zBssFpCqEI2kk2zXVX0axHmgm0SO6jELjXXZavl4uBpicWOqZpuqjNazJEa04YJqitG3JkU$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/APAK7Y2YCPNKYT4XG2ZGOO3W3UREBANCNFSM6AAAAAAVVPAYII__;!!KwNVnqRv!EHixIiJabGURWdR3zBssFpCqEI2kk2zXVX0axHmgm0SO6jELjXXZavl4uBpicWOqZpuqjNazJEa04YJqaW2AT0A$ . You are receiving this because you authored the thread.Message ID: @.***>
Dear Brian,
I am Elvis Duran, a research scientist at MD Anderson Cancer Center currently using your "RegisterImages.WithDicomReg" Python module. This is the code I'm using to register two images: resampled_moving = register_images_with_dicom_reg(fixed_image=fixed_image, moving_image=moving_image, dicom_registration=dicom_registration)
Thank you!