Page 1 of 1

Measuring the centerline

Posted: Wed Mar 06, 2019 2:54 pm
by nafis2016
Hello everyone,
I have created a centerline based on a ".stl" model in Simvascular. Now, I am interested in measuring the spline length between two specific control points, like the distance between two branches of the aorta on the centerline. would you please direct me how to do it? I tried the measurement button in the software but apparently, it cannot measure the distance I am interested in.

Regards,

Re: Measuring the centerline

Posted: Thu Mar 07, 2019 3:06 pm
by davep
Hi Nafiseh,

There is currently no functionality in SimVascular GUI to measure the distance between control points along a center line.

It might be possible to do this using the SimVascular Python interface, I will look into that.

Cheers,
Dave

Re: Measuring the centerline

Posted: Thu Mar 07, 2019 10:18 pm
by nafis2016
Thank you so much David. I really appreciate if you could direct me how to do that in Python interface.
Regards,

Re: Measuring the centerline

Posted: Wed Mar 13, 2019 11:13 pm
by davep
Hi Nafiseh,

I have created a Python script called contour_distance.py that is used to calculate the distance between the centers of contours created in the SimVascular SV 2D Segmentations module. It is not exactly what you want but it is close. I will be adding other scripts soon, need to create a new version of SimVascular to support some additional functionality.

You can download the script from https://github.com/ktbolt/cardiovascula ... on-scripts. There is a README there that explains how to use the script.

Let me know if you have any questions or have any problems. I am just learning how to use the Python interface so the script may need to be refined a bit.

Cheers,
Dave

Re: Measuring the centerline

Posted: Tue Aug 23, 2022 10:30 am
by rudolf.hellmuth
Hi,

I used to make many measures with the centreline with version 2018.08.09 and older ones. I have scripts that measure arc-length, curvature and separation angles between two branches. Separation angle as the angle a branch has compared to other branch if one branch's centreline would travel along the main vessel's centreline to meet the other branch's centreline. I also used to use the centreline to extract tangent vector and use them to slice the cross-section of blood vessels. I cannot do this with the newest version of SimVascular. The current version is giving me the a rough centreline, because it generates points that are too close from one another (please, see attached pictures). The tangent vector is very sensitive to the proximity of the points of the centreline.

Moreover, the centrelines used to be stored as PTH files rather than CSV. However, this isn't any problem.

Why is the centreline so rough now, when it used to be smooth before? Could this be fixed?

Best regards,
Rudolf

Re: Measuring the centerline

Posted: Tue Aug 23, 2022 11:02 am
by rudolf.hellmuth
The other message was no allowing me to upload more pictures. I will do it here.

We have also found out that the algorithm that makes the centreline fails when the curvature of the vessel is high. We have scanned the superficial saphenous vein with the knee bent at 120 deg. The lofted vessel is smooth, but SimVascular crashes when we try to get the centreline.

My colleague has done many segmentations with the newest version of SimVascular. We will now see if we can open a project made in a new version using an old version, just to get a proper centreline out of it. Hopefully that will work. We have a lot of data to be processed...

Best regards,
Rudolf

Re: Measuring the centerline

Posted: Wed Aug 24, 2022 6:01 am
by rudolf.hellmuth
Hi,

I have made a merge by distance filter to handle the new centrelines. It has fixed the issue for me. I am including the filter here in case anyone needs this workaround. FYI, my vessel has an average diameter of about 5 mm, and I have merged all points in the sequence whose distance is < 0.6 mm.

Code: Select all

def mergeByDistance(pathPoints, minDistance, verbose=False):
    '''
    Merge path points with the neighbours in a sequence if they  are at a 
    distance less less than 'minDistance' from each other.

    Parameters
    ----------
    pathPoints : numpy.array(n, 3)
        x-, y-, and z-coordinates of the n points defining pathline.
    minDistance : float
        minimum Carthesian distance allowed of neighboring points to be 
        separated in a path.
    verbose : bool
        Swith to print points that are being merged.

    Returns
    -------
        numpy.array(n, 1)

    '''

    points = list()
    count = 0
    for i, point in enumerate(pathPoints):
        if i == 0:
            points.append(point)
        else:
            delta = point - points[-1]
            d = np.linalg.norm(delta)
            if d < minDistance:
                if verbose:
                    print('mergeByDistance: points {0:d} and {1:d} by distance'+
                          ' {2:f} < {3:f}.'.format(i-1, i, d, minDistance))
                points[-1] += 0.5*delta  # last point moves to halfway
                count += 1
            else:
                if verbose:
                    print('mergeByDistance: points {0:d} no change.'.format(i))
                points.append(point)
    print('mergeByDistance: {0:d} of {1:d} merged.'.format(count, i))

    return np.array(points)

Re: Measuring the centerline

Posted: Mon Aug 29, 2022 11:12 am
by davep
Hi Rudolf,

There has been a lot of work done on generating better centerline geometry (e.g. https://github.com/SimVascular/SimVascular/issues/655). The centerline format is thus different from what it used to be.

We are using centerline geometry for lots of different kinds of applications and have not seen any problems. But of course there may be a problem with the particular type of vessel geometry you are dealing with. If you think the data is not correct then please open an Issue here https://github.com/SimVascular/SimVascular/issues.

Cheers,
Dave

Re: Measuring the centerline

Posted: Tue Aug 30, 2022 2:44 pm
by pfaller
Hi Rudolf,

That's an interesting centerline. I see how the change in discretization length can cause these problems. This could be fixed by either using multiple points in the finite difference method or regularizing the tangent.

What's curious is that in our example the points are usually somewhat equally spaced. In general, the centerline mesh resolution depends on the surface mesh resolution. I'm wondering if the surface mesh in your case is also irregular and if the centerline could be fixed by remeshing the surface?

Best,
Martin