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

gap appears when I generate the nii.gz file from .tre when using TubeTK #141

Open
jinshuozhang opened this issue Mar 30, 2023 · 8 comments

Comments

@jinshuozhang
Copy link

Thank you for sharing your excellent project professor!

I meet the same problems as [Subhashis-Banerjee] https://github.com/InsightSoftwareConsortium/ITKTubeTK/issues/81 when I try to generate the label image from .tre

my .mha and .tre data come from the public dataset https://public.kitware.com/Wiki/TubeTK/Data, the size of the image is 448×448×128 and the spacing is 0.513×0.513×0.8.

I use the 'Normal002-MRA.mha' and the corresponding VascularNetwork.tre for testing. the following is my code:

`
import itk
from itk import TubeTK as ttk

PixelType = itk.F
Dimension = 3
ImageType = itk.Image[PixelType, Dimension]

Read tre file

TubeFileReaderType = itk.SpatialObjectReader[Dimension]

tubeFileReader = TubeFileReaderType.New()
tubeFileReader.SetFileName("F:/MIDAS_data/002/Vessel_annotation_file/VascularNetwork.tre")
tubeFileReader.Update()
tubes = tubeFileReader.GetGroup()

''''###
SurfWriter = ttk.WriteTubesAsPolyData.New()
SurfWriter.SetFileName("F:/MIDAS_data/002/vesselsurface.vtp")
SurfWriter.SetInput(tubes)
SurfWriter.Update()
'''

Read template image

TemplateImageType = itk.Image[PixelType, Dimension]
TemplateImageReaderType = itk.ImageFileReader[TemplateImageType]

templateImageReader = TemplateImageReaderType.New()
templateImageReader.SetFileName("F:/MIDAS_data/002/MRA/Normal002-MRA.mha")
templateImageReader.Update()
templateImage = templateImageReader.GetOutput()
###########################
#Resample = ttk.ResampleImage.New(templateImage,ResampleFactor=(2,2,2))
#Resample = ttk.ResampleImage.New(templateImage)
#Resample.SetMakeHighResIso(True)
#Resample.Update()
#image_iso = Resample.GetOutput()
##########################

TubesToImageFilterType = ttk.ConvertTubesToImage[TemplateImageType]
tubesToImageFilter = TubesToImageFilterType.New()
tubesToImageFilter.SetUseRadius(True)
tubesToImageFilter.SetTemplateImage(templateImageReader.GetOutput())
#tubesToImageFilter.SetTemplateImage(image_iso)
tubesToImageFilter.SetInput(tubes)
tubesToImageFilter.Update()
outputImage = tubesToImageFilter.GetOutput()

itk.imwrite(outputImage, 'F:/MIDAS_data/002/double_label.nii.gz')
`

I get the image( size: 448×448×128 spacing: 0.513,0.513,0.8 ) shows the label discontinuous:

111

the vtp image shows these gaps should not exist:
222

when I up-resampling the mha image to 896×896×255 ,spacing 0.257,0.257,0.4, I got the right label:

333

however, this size is too large for us to use for study.
So, Is there any way to get continuous vessel labels without upsampling? I need the continuous vessel labels with the size of 448×448×128 and spacing of 0.513,0.513,0.8.
Thank you !

@aylward
Copy link
Member

aylward commented Apr 12, 2023 via email

@jinshuozhang
Copy link
Author

jinshuozhang commented Apr 17, 2023

Hi, How are you generating the renderings? The _label.nii.gz images produced are volumes, but it looks like you're showing the results as red surfaces. So, this could be a problem of the surface extraction/renderer you're using to convert from a binary volume to surfaces, or it could definitely be my code that is at fault. I'll check my code again, but it would be good if you also checked the volume (_label.nii.gz) file directly instead of as a 3D rendering. Thanks! s

Thank you for your reply. We are using the code you provided to get the _label.nii.gz file. Then we opened the file using itk-snap, a popular software, and got the 3D rendered result. As far as we know, the reason for the broken blood vessels in the label file is not caused by itk-snap, but the label file itself is faulty. Could you check if there is a problem with the code itself that we are using, thank you !

@jinshuozhang
Copy link
Author

7777
This is the python version of the code we use, and the data we use is the .tre annotated file provided in MIDAS.

@aylward
Copy link
Member

aylward commented Apr 17, 2023 via email

@jinshuozhang
Copy link
Author

Hi, Please email me your _label.nii.gz file. Thanks, Stephen @.***

On Mon, Apr 17, 2023 at 2:56 AM jinshuozhang @.> wrote: [image: 7777] https://user-images.githubusercontent.com/101242990/232407523-0b2be5d1-eb7b-4dbc-87d3-78f302224fdc.png This is the python version of the code we use, and the data we use is the .tre annotated file provided in MIDAS. — Reply to this email directly, view it on GitHub <#141 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEJL5K7BZHTRF2HZR45WTXBTSQRANCNFSM6AAAAAAWMTQUGQ . You are receiving this because you commented.Message ID: @.>
-- Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives Chair of MONAI Advisory Board --- Kitware: Delivering innovation.

professor, we have emailed the label.nii.gz, have you got it?

@aylward
Copy link
Member

aylward commented Apr 23, 2023 via email

@jinshuozhang
Copy link
Author

I have not received it, and it is not in my spam folder. Sorry for the troubles. Please try sharing via gdrive or dropbox or box or such. Some mail systems blog .gz and .zip file attachments. Otherwise, I can try duplicating your code later this week, but it is already a busy week for me. Thanks, s On Sun, Apr 23, 2023 at 4:01 AM jinshuozhang @.> wrote:

Hi, Please email me your _label.nii.gz file. Thanks, Stephen @.
… <#m_-4720112394795503434_> On Mon, Apr 17, 2023 at 2:56 AM jinshuozhang @.> wrote: [image: 7777] https://user-images.githubusercontent.com/101242990/232407523-0b2be5d1-eb7b-4dbc-87d3-78f302224fdc.png https://user-images.githubusercontent.com/101242990/232407523-0b2be5d1-eb7b-4dbc-87d3-78f302224fdc.png This is the python version of the code we use, and the data we use is the .tre annotated file provided in MIDAS. — Reply to this email directly, view it on GitHub <#141 (comment) <#141 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEJL5K7BZHTRF2HZR45WTXBTSQRANCNFSM6AAAAAAWMTQUGQ https://github.com/notifications/unsubscribe-auth/AACEJL5K7BZHTRF2HZR45WTXBTSQRANCNFSM6AAAAAAWMTQUGQ . You are receiving this because you commented.Message ID: @.> -- Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives Chair of MONAI Advisory Board --- Kitware: Delivering innovation. professor, we have emailed the label.nii.gz, have you got it? — Reply to this email directly, view it on GitHub <#141 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACEJL644X4PZELPXZIYIMLXCTOWHANCNFSM6AAAAAAWMTQUGQ . You are receiving this because you commented.Message ID: @.***>
-- Stephen R. Aylward, Ph.D. Senior Director of Strategic Initiatives Chair of MONAI Advisory Board --- Kitware: Delivering innovation.

professor,this is my code and the lable.nii.gz. https://drive.google.com/file/d/1-HrBRIsKxKITljZcSCtNZ7OBkBnu-hri/view?usp=share_link. We are very grateful for your help and we wish you all the best in your work.

@aylward
Copy link
Member

aylward commented May 4, 2023

Hi,

Sorry for the delay. Looking at the label.nii.gz file, there are no gaps. The issue is how you are displaying the label.nii.gz file. Below is a comparison: on the left is your visualization and on the right is a maximum intensity projection (MIP) of your file. The MIP shows that the vessels get very narrow at the regions you see as gaps, but there are still connections. The challenge is the discretization of the image, i.e., the size of the vessels relative to the size of a voxel. When a segment of a vessel has a diameter that is approximately one voxel, that vessel segment is rendered as one-voxel-wide curves. Your display seems to be doing a surface extraction or volume rendering from the label.nii.gz file - and many surface extraction (and other rendering methods) will not handle one-voxel-wide objects very well - making them appear to "disappear."

Right now things are (arguably) as accurate as the resolution of the image allows. That is why when you reconstruction using a higher resolution image you get a more accurate looking representation regardless of the rendering method. The one-voxel-wide segments become two or more voxel wide segments, and volume rendering / surface extraction works.

NoGaps

Hope all of this makes sense. One possible hack...you could apply a morphological dilate filter to make every vessel appear wider. Then your rendering method should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants