# How to open a centerline 3d image in 3dslicer?

**URL:** <https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921>\
**Category:** Support\
**Created:** [July 25, 2021, 8:41pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921 "2021-07-25T20:41:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![parvaneh.a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parvaneh.a/32/14462_2.png) [@parvaneh.a](https://discourse.slicer.org/u/parvaneh.a)\
**Post date:** [July 25, 2021, 8:41pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/1 "2021-07-25T20:41:26Z")

</div>

Operating system: ubuntu 20  
Slicer version:4.11.20210226  
Expected behavior: open a centerline image as expected  
Actual behavior: opens the centerline image abnormally

Hi,  
I have extracted the center line of my label map images using bwskel function in matlab. I would like to open them in slicer. When I open them in matlab with volumeViewer it show that correctly as image below but when I open in slicer it shows a weird image. Why this happen and a how can I see the center line binary image in slicer as I see in matlab?

In matlab centerline image appeared as yellow lines:

 ![Screenshot from 2021-07-25 16-34-15](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/3/230aa558b8867ad22fbc9c1aaba56217f61754aa.png)

In slicer centerline image appeared as :

 ![Screenshot from 2021-07-25 16-38-07](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/7/77a0215ad7ea62bb56a5f1a19b36eb7f270ba46c.png)

Best,

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 25, 2021, 10:01pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/2 "2021-07-25T22:01:08Z")

</div>

Probably the matlab code is saving with options Slicer doesn’t expect. What format do you use for saving?

---

<div class="post-metadata">

**Author:** ![parvaneh.a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parvaneh.a/32/14462_2.png) [@parvaneh.a](https://discourse.slicer.org/u/parvaneh.a)\
**Post date:** [July 25, 2021, 11:12pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/3 "2021-07-25T23:12:44Z")

</div>

I am using nii.gz format for saving. Might be related to data type (uint, o so?)?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 26, 2021, 2:43pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/4 "2021-07-26T14:43:34Z")

</div>

Most .nii.gz file load fine in Slicer but it’s not a great format for general purpose work for a lot of reasons. You could try nrrd or another format.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 26, 2021, 9:18pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/5 "2021-07-26T21:18:01Z")

</div>

You may try to turn off smoothing (in [“Advanced create…”](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentations.html#create-new-representation-in-segmentation-conversion) in Segmentations module), because smoothing may remove isolated voxels and very thin structures.

However, your rendering in Matlab looks like a quite low quality centerline extraction (looks like a very basic skeletonization). I would not bother even trying to read this data because it is unlikely that you could use it for anything. Instead, you can extract high-quality centerline, metrics, statistics, connectivity information, etc. using [SlicerVMTK extension](https://github.com/vmtk/SlicerExtension-VMTK#the-vmtk-extension-for-3d-slicer).

---

<div class="post-metadata">

**Author:** ![parvaneh.a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parvaneh.a/32/14462_2.png) [@parvaneh.a](https://discourse.slicer.org/u/parvaneh.a)\
**Post date:** [July 26, 2021, 10:57pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/6 "2021-07-26T22:57:57Z")

</div>

Thanks for helping . Unfortunately I could not find the option of "Advanced create’ in segmentation module. I have attached the picture which I see in the segmentation module and would be thankful if you could elaborate on the steps to find the advanced create for turning off the smoothing.

 ![Screenshot from 2021-07-26 18-50-32](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/b/aba2599b592bde589a3392212b80db1f7b986544.png)

I have seen the skeletonization filter in 3d slicer and that does not have skeletonization in 3D. Also about the slicervmtk , it requires that I define the beginning and end of the path of center line manually which is not possible for many data that I have. Furthermore, as seen , my image has 4 main branches of pulmonary veins and providing the seed point of each of four takes so much time and is impossible. Even with trying the seed points the results with slicer was not acceptable. Please let me know if I have missed anything.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 27, 2021, 4:11am UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/7 "2021-07-27T04:11:30Z")

</div>

> [@parvaneh.a](#):
>
> Unfortunately I could not find the option of "Advanced create’ in segmentation module.

Long-click (hold down the left mouse button until the menu appears):

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/b/1bfecd8bd000dfbea3d38729b6d38bd340c07ac3.png)

> [@parvaneh.a](#):
>
> I have seen the skeletonization filter in 3d slicer and that does not have skeletonization in 3D

The module performs skeletonization in 3D. Why do you think it is not doing that?

> [@parvaneh.a](#):
>
> about the slicervmtk , it requires that I define the beginning and end of the path of center line manually which is not possible for many data that I have.

You have the option of specifying endpoints manually, which is a very useful feature, but normally you just click “Auto-detect” to get all the endpoints automatically in a few seconds.

> [@parvaneh.a](#):
>
> Furthermore, as seen , my image has 4 main branches of pulmonary veins and providing the seed point of each of four takes so much time and is impossible

No problem at all, automatic endpoint detection should work well. If the segmented surface is noise then you may have more endpoints than you want, in that case you may either slightly smooth the segmentation, cut of small branches, or remove some of the detected endpoints.

> [@parvaneh.a](#):
>
> Even with trying the seed points the results with slicer was not acceptable.

It should be good. Something like this (blue network, green is centerline extraction result):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/0/a0ce7ef2b996c20e827fda09b92fe2d71cc54f3e.jpeg)

Could you attach a screenshot that illustrates the problem you ran into?

---

<div class="post-metadata">

**Author:** ![parvaneh.a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parvaneh.a/32/14462_2.png) [@parvaneh.a](https://discourse.slicer.org/u/parvaneh.a)\
**Post date:** [July 28, 2021, 9:52pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/8 "2021-07-28T21:52:44Z")

</div>

Thanks a lot the issue was resolved with turn off the smoothing and I can see the binary centerline correctly.  
I had not tried the automatic end point detection and just tried it and it works very well with a bit error as some end points are joined together as seen. How to correct them and how to write a code in python to be able to automatically extract centerline for all images without loading them one by one in slicer and save them?

 ![Screen Shot 2021-07-28 at 5.45.57 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/1/619d9bcaca1e4730b778abf8829532eac8c186e4.jpeg)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 28, 2021, 10:46pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/9 "2021-07-28T22:46:32Z")

</div>

If you search the forum archives for vmtk and centerlines I’m pretty sure this has already been answered. Maybe someone who uses vmtk can jump in here.

---

<div class="post-metadata">

**Author:** ![parvaneh.a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parvaneh.a/32/14462_2.png) [@parvaneh.a](https://discourse.slicer.org/u/parvaneh.a)\
**Post date:** [July 29, 2021, 2:49am UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/10 "2021-07-29T02:49:34Z")

</div>

Thanks.  
In some cases it does not provide the centerline on some branches. here I first used automatic endpoint and then added manually some on the parts that did not get the endpoint . However, still the centerline cannot be obtained on some branches. Hoe can I get those in?

 ![Screen Shot 2021-07-28 at 10.44.23 PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/3/63bc2dc94969804bd210ee8e3fc9fb415cdd7025.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 3, 2021, 4:28pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/11 "2021-08-03T16:28:26Z")

</div>

Which Slicer version did you encounter this problem with?

---

<div class="post-metadata">

**Author:** ![parvaneh.a](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/parvaneh.a/32/14462_2.png) [@parvaneh.a](https://discourse.slicer.org/u/parvaneh.a)\
**Post date:** [August 19, 2021, 12:55am UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/12 "2021-08-19T00:55:44Z")

</div>

the version was 4.11

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 20, 2021, 6:47pm UTC](https://discourse.slicer.org/t/how-to-open-a-centerline-3d-image-in-3dslicer/18921/13 "2021-08-20T18:47:36Z")

</div>

That should work. Then most likely the issue is that inside the left atrium, the concept of a centerline does not exist. You may want to specify a vessel endpoint at the origin of each vessel branch.
