0

I am looking into the https://scikit-image.org/docs/dev/api/skimage.draw.html#skimage.draw.ellipse and skimage.draw.ellipsoid_stats(a, b, c) which claims, I quote

Calculates analytical surface area and volume for ellipsoid with semimajor axes aligned with grid dimensions of specified spacing.

But looking into their code there is no information regarding spacing introduced. Perhaps I am missing something.

My questions are: - how can I calculate the volume of an ellipsoid knowing the radii a, b, c and the grid spacing? I am working with DICOM CT volumes which have different spacings.

def ellipsoid_stats(a, b, c):
    """
    Calculates analytical surface area and volume for ellipsoid with
    semimajor axes aligned with grid dimensions of specified `spacing`.
    Parameters
    ----------
    a : float
        Length of semimajor axis aligned with x-axis.
    b : float
        Length of semimajor axis aligned with y-axis.
    c : float
        Length of semimajor axis aligned with z-axis.
    Returns
    -------
    vol : float
        Calculated volume of ellipsoid.
    surf : float
        Calculated surface area of ellipsoid.
    """
    if (a <= 0) or (b <= 0) or (c <= 0):
        raise ValueError('Parameters a, b, and c must all be > 0')

    # Calculate volume & surface area
    # Surface calculation requires a >= b >= c and a != c.
    abc = [a, b, c]
    abc.sort(reverse=True)
    a = abc[0]
    b = abc[1]
    c = abc[2]

    # Volume
    vol = 4 / 3. * np.pi * a * b * c

    # Analytical ellipsoid surface area
    phi = np.arcsin((1. - (c ** 2 / (a ** 2.))) ** 0.5)
    d = float((a ** 2 - c ** 2) ** 0.5)
    m = (a ** 2 * (b ** 2 - c ** 2) /
         float(b ** 2 * (a ** 2 - c ** 2)))
    F = ellip_F(phi, m)
    E = ellip_E(phi, m)

    surf = 2 * np.pi * (c ** 2 +
                        b * c ** 2 / d * F +
                        b * d * E)

    return vol, surf
RMS
  • 1,350
  • 5
  • 18
  • 35

1 Answers1

0

The scikit functions give you results in terms of pixels - so surface area in terms of pixels (if you've got a 2D image), and volume in terms of pixels^2.

Ones you have that for the images, to get it into mm and mm^2 for your CT images, you'll then need to look up the PixelSpacing tag to get the size of each pixel in mm, and use that to convert the units.

If you're using pydicom then you can use .PixelSpacing[0]. PixelSpacing is a 2-element list, but all CT's I know have the same row/column pixel spacing, so it's sufficient just to use the first element in the list PixelSpacing[0].

Richard
  • 3,024
  • 2
  • 17
  • 40