Contouring with having initial curve using filters in Simple ITK module?

Hello Dear Developers and Users

I want to segment or contour the pelvis.
Consider the following figure. This screenshot contains a 2D image of EPID, named EPID.

Consider the following figure. This screenshot contains the contour of the pelvic bone extracted from the DRR image named contourDRR, using filters such as ClosingByReconstructionImageFilter, OpeningByReconstructionImageFilter and ZeroCrossingBasedEdgeDetectionImageFilter in Simple ITK module.

I would like to consider this contour (contourDRR) as a starting point (initial contour) and using, for example, the filter of geodesicActiveContourLevelSetImageFilter in Simple ITK module, it is deformable to match the edge of the pelvis in the EPID image (EPID).
In other words, I want to use active contour with matching this initial contour (contourDRR) on the edges of pelvis in EPID.
Unfortunately, after using this filter, I took an output image that had all the pixels equal to one.

How can I do this contouring with initial contour?
Please guide me to do it.
Best regards.

Shahrokh

Details:

EPID information:
Image Dimension: 611 576 1
Image Spacing: 0.25mm 0.25mm 1.00mm

contourDRR Information:
Image Dimension: 270 256 1
Image Spacing: 0.5859mm 0.5859mm 1.0000mm

With these specifactions, at firstly I made the same type these volumes (EPID and contourDRR) to Double. Then I applied geodesicActiveContourLevelSetImageFilter. I get the following error message:

Exception thrown in SimpleITK GeodesicActiveContourLevelSetImageFilter_Execute: /work/Preview/Slicer-0-build/SimpleITK/Code/BasicFilters/src/sitkImageFilter.cxx:63:

sitk::ERROR: Input “featureImage” for “GeodesicActiveContourLevelSetImageFilter” has size of [ 270, 256, 1 ] which does not match the primary input’s size of [ 611, 576, 1 ]!

So I use the module of General Registration (ANTs) to unify the specifications of these volumes (EPID and contourDRR).

Inputs:
Fixed Image: EPID
Moving Image: contourDRR
Stages (Presets): Rigid
Setting:
Computation Precision: double
Outputs:
Transformed Volume: ContourDRRTRansformed

I get the following result:
EPID information:
Image Dimension: 611 576 1
Image Spacing: 0.25mm 0.25mm 1.00mm
ContourDRRTRansformed Information:
Image Dimension: 611 576 1
Image Spacing: 0.25mm 0.25mm 1.0000mm

At now, I run geodesicActiveContourLevelSetImageFilter on these volumes: EPID and ContourDRRTRansformed nodes.I get the following error message:

Exception thrown in SimpleITK GeodesicActiveContourLevelSetImageFilter_Execute: /work/Preview/Slicer-0-build/ITK/Modules/Filtering/ImageFilterBase/include/itkRecursiveSeparableImageFilter.hxx:227:

ITK ERROR: RecursiveGaussianImageFilter(0x7f8d78567a40): The number of pixels along direction 2 is less than 4. This filter requires a minimum of four pixels along the dimension to be processed.

I do not know to add three slices (exactly one or copy) in the direction of IS in 3DSlicer. For doing it, I save these volumes ( EPID and ContourDRRTRansformed ) in nifti format and use medcon for example with following commands:

$ cp ContourDRRTRansformed.nii ContourDRRTRansformed1.nii
$ cp ContourDRRTRansformed.nii ContourDRRTRansformed2.nii
$ cp ContourDRRTRansformed.nii ContourDRRTRansformed3.nii
$ cp ContourDRRTRansformed.nii ContourDRRTRansformed3.nii
$ medcon -f ContourDRRTRansformed1.nii ContourDRRTRansformed2.nii ContourDRRTRansformed3.nii ContourDRRTRansformed4.nii -stack3d -c nii
...
$ cp EPID.nii EPID1.nii
$ cp EPID.nii EPID2.nii
$ cp EPID.nii EPID3.nii
$ cp EPID.nii EPID3.nii
$ medcon -f EPID1.nii EPID2.nii EPID3.nii EPID4.nii -stack3d -c nifti

Result:
EPID information:
Image Dimension: 611 576 4
Image Spacing: 0.25mm 0.25mm 1.00mm
contourDRR Information:
Image Dimension: 611 576 4
Image Spacing: 0.25mm 0.25mm 1.00mm

After doing it, I again I run geodesicActiveContourLevelSetImageFilter on these volumes: EPID and ContourDRRTRansformed. As mentioned in my previous message, unfortunately, after using this filter, I took an output image that had all the pixels equal to one.

Please guide me to solving this problem.
Thanks.
Shahrokh

You can use “Resample Scalar/Vector/DWI Volume” to resample the contourDRR image to match the geometry of the EPID image, but setting the contourDRR as input image and the EPID as reference image.

Thanks a lot for your guidance.

I used the module of Resample Scalar/Vector/DWI Volume to match the geometry of contourDRR image with EPID image (as you mentioned, I set contourDRR and EPID as Input Volume and Reference Volume respectively). After running it, I have new volume node with the name of contourDRR2 which is geometrically matched with the EPID image.

But I’m sorry, I still have two major and minor problems:

Major problem:
How can I use a binary image containing the contour of an organ (such as contourDRR2) as the initial curve using Simple ITK filter, based on the active contour technique, to extract the contour in a gray scale image (EPID)? As mentioned above, I have two images contourDRR2 (binary images) and EPID (graycale image) which are geometrically matched with ‌each other. I used the filter of geodesicActiveContourLevelSetImageFilter to deform this initial contour so that the result of this deformation (for example using this filter) is a contour that matches the edge of the pelvis in the EPID image.

Minor problem:
How do I generate four axial slices that are exactly the same as a original slice and are in a row in the IS direction?
For example, I have ContourDRR2 with the following specifications:
Image Dimension: 611 576 1

How can I convert this image with the following specifications:
Image Dimension: 611 576 4

Best regards.
Shahrokh

Probably the best would be to ask this from the developers of these algorithms on the ITK forum.

You can use a resampling module for this, setting the spacing along IS direction to 1/4 of the original and the IS extent of the image to 4.

Thank a lot for your guidance and refer to ITK forum. I raise my problem there.
Best regards.
Shahrokh