How to generate new segmentations from an existing segmentation

90 views
Skip to first unread message

Daniel

unread,
Nov 3, 2020, 12:40:46 PM11/3/20
to itksnap-users
I am doing a research on brain hematoma, and now I have a question to ask.

Suppose I have segmented a brain hematoma already with ITK-SNAP, and now I want to obtain a second segmentation, which lies 2 mm inside the original segmentation; I also want to obtain a third segmentation, which lies 2 mm outside the original segmentation.

Is it possible to generate the 2nd and 3rd segmentations automaticaaly in ITK-SNAP? Or could anyone provide any suggestions on how to achieve this?

Thank you in advance.

Cook, Philip

unread,
Nov 3, 2020, 1:06:16 PM11/3/20
to itksna...@googlegroups.com

I'm not sure how the second and third segmentations differ. You can dilate a segmentation with c3d. Assuming you have a binary ROI with label 1 for hematoma, 0 for background

 

c3d hematoma.nii.gz -as original -dilate 1 2x2x2mm -push original -scale -1 -add -o newROI.nii.gz

 

This will give you a 2mm border around the original label.

--
You received this message because you are subscribed to the Google Groups "itksnap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to itksnap-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/itksnap-users/815de1c9-f355-46a2-bbea-8362c8493046n%40googlegroups.com.

Daniel

unread,
Nov 3, 2020, 7:10:10 PM11/3/20
to itksnap-users
Thank you for the prompt reply, it helps a lot!

I have another question, how can I “shrink” the original segmentation? I just searched the tutorial of c3d, but haven’t found any similar commands.

Thank you!

Cook, Philip

unread,
Nov 3, 2020, 7:11:36 PM11/3/20
to itksna...@googlegroups.com
That would be -erode, which is the opposite of dilate

Sent from my iPhone

On Nov 3, 2020, at 7:10 PM, Daniel <yan...@gmail.com> wrote:

Thank you for the prompt reply, it helps a lot!

Daniel

unread,
Nov 3, 2020, 7:14:51 PM11/3/20
to itksnap-users

Thank you. I will try both commands!

Daniel

unread,
Nov 4, 2020, 11:39:10 PM11/4/20
to itksnap-users
I have tried both commands, and it seems they are not working as intended.

For example, when using the "dilate"command, the generated segmentation extends from the original segmentation more far than the value I set.
(If I set the value to be 5 mm, for example, the distance between the border of the generate segmentation and the border of the original segmentation is visually much greater than 5 mm.)




What I want is drawing the border of a lesion (the original segmentation, which i already have), and then extends the border inward for 5 mm, and outward for 5 mm.
And finally I can get an area on the border of the lesion, the center-line of which is the actual border, and the width of the area is 10 mm.

Following is an illustration of what I want. 
I have the black circle already (the original segmentation), and I want to get the red circular area (the actual shape of the area depends on the original segmentation) that centers on the black circle, the width of which is 10 mm. 

无标题.png



Could you please provide further advice on this?
Really appreciate your help!

Cook, Philip

unread,
Nov 4, 2020, 11:42:27 PM11/4/20
to itksna...@googlegroups.com
Can you share an example image?

Sent from my iPhone

On Nov 4, 2020, at 11:39 PM, Daniel <yan...@gmail.com> wrote:

I have tried both commands, and it seems they are not working as intended.

For example, when using the "dilate"command, the generated segmentation extends from the original segmentation more far than the value I set.
(If I set the value to be 5 mm, for example, the distance between the border of the generate segmentation and the border of the original segmentation is visually much greater than 5 mm.)




What I want is drawing the border of a lesion (the original segmentation, which i already have), and then extends the border inward for 5 mm, and outward for 5 mm.
And finally I can get an area on the border of the lesion, the center-line of which is the actual border, and the width of the area is 10 mm.

Following is an illustration of what I want. 
I have the black circle already (the original segmentation), and I want to get the red circular area (the actual shape of the area depends on the original segmentation) that centers on the black circle, the width of which is 10 mm. 

Dorian P.

unread,
Nov 5, 2020, 12:18:36 AM11/5/20
to itksnap-users
What you are trying to get may be obvious on a circle, but on real lesions is not that straightforward. When you dilate around a crevice, you may smooth out the crevice so you don't get the same shape of the crevice moving outwards. So, when you think it is much more than 5mm, it may actually be more from the crevice but it is 5mm from the nearest border voxel. For the same reason, going 5mm out and 5mm in does not mean that you will be able to maintain a constant 10mm distance between the two new borders. This is because, if my understanding is correct, dilation is not like a zoom or magnification that preserves the morphology of the shape. It is more like a stucco of voxels added on the outer layer.
Dorian

Daniel

unread,
Nov 5, 2020, 3:50:30 AM11/5/20
to itksnap-users
Thank you for the detailed explanation, I agree that this is a tricky problem.
This step is a prerequisite for the research, so I need to find an effective way to do it. If haven't found any, then maybe I have to do it manually, I think it would be rather painful and time-consuming ;-(

Daniel

unread,
Nov 5, 2020, 3:54:49 AM11/5/20
to itksnap-users
No problem.
As the dicom image contains some private information, can I send it to you via email?

I haven't found your email address, I don't know if you can tell me the address, or could you send me an email at yan...@gmail.com?
Thank you!

Cook, Philip

unread,
Nov 6, 2020, 1:53:25 PM11/6/20
to itksna...@googlegroups.com

I don't need the DICOM, just the NIFTI segmentation, which should be quite small if compressed as .nii.gz. I can send you a link where you can upload it.

Daniel

unread,
Nov 7, 2020, 9:54:23 AM11/7/20
to itksnap-users
OK, I have uploaded the data to the shared folder, please check.

Daniel

unread,
Nov 7, 2020, 9:55:25 AM11/7/20
to itksnap-users
The .rar file I uploaded includes three different cases.

Daniel

unread,
Nov 19, 2020, 2:57:52 AM11/19/20
to itksnap-users
Hi Philip,

Sorry to ask again, I am wondering if you have checked the images I sent you? 

Looking forward to your reply.
You are appreciated!

Daniel 
On Thursday, November 5, 2020 at 12:42:27 PM UTC+8 Philip Cook wrote:

Olena Tankyevych

unread,
Nov 19, 2020, 4:21:32 AM11/19/20
to itksna...@googlegroups.com
When you use such binary morphological operations, the structuring element (or the mask, if you wish) you use to dilate or to erode is very important. If you want a smaller dilation, try less than 5mm, if your image does not have the same pixel size in three dimensions, you can use a smaller mask size in the dimension that has a worse resolution.

Also, if you want not only the border, but the whole dilated image : c3d original.nii -dilate 1 3x3x3mm -o dilated.nii

Cook, Philip

unread,
Nov 19, 2020, 9:38:21 AM11/19/20
to itksna...@googlegroups.com
Hi,

Can you please upload a segmentation image as .nii.gz to my box?

Sent from my iPhone

On Nov 19, 2020, at 2:58 AM, Daniel <yan...@gmail.com> wrote:

Hi Philip,
Reply all
Reply to author
Forward
0 new messages