src/store/modules/segmentationModule/getLabelmapStats.js
/**
 * Estimates the slice thickness given the image position patient of adjacent frames.
 * For the edges the slice thickness is assumed to be the perpendicular distance to the closest frame.
 * For all other frames the slice thickness is taken to be the sum of half of the distance to the frame above and below.
 *
 * Voxels on the first or last frame are assumed to be full occupied.
 *
 * @param {Object[]} images An array of cornerstone images.
 * @param {Object[]} imagePlanes An array of the per-frame imagePlane metadata.
 * @param {number} frameIndex The index of the frame to get the slice thickness for.
 *
 * @returns {number}
 */
Estimates the slice thickness given the image position patient of adjacent frames.
For the edges the slice thickness is assumed to be the perpendicular distance to the closest frame.
For all other frames the slice thickness is taken to be the sum of half of the distance to the frame above and below.

Voxels on the first or last frame are assumed to be full occupied.

@param {Object[]} images An array of cornerstone images.
@param {Object[]} imagePlanes An array of the per-frame imagePlane metadata.
@param {number} frameIndex The index of the frame to get the slice thickness for.

@returns {number}
Estimates the slice thickness given the image position patient of adjacent frames . For the edges the slice thickness is assumed to be the perpendicular distance to the closest frame . For all other frames the slice thickness is taken to be the sum of half of the distance to the frame above and below . Voxels on the first or last frame are assumed to be full occupied . @param { Object [] } images An array of cornerstone images . @param { Object [] } imagePlanes An array of the per - frame imagePlane metadata . @param { number } frameIndex The index of the frame to get the slice thickness for . @returns { number }
function _getSliceThickness(images, imagePlanes, frameIndex) {
  const numberOfSlices = images.length;
  const ipp = imagePlanes[frameIndex].imagePositionPatient;
  if (frameIndex === 0) {
    const ippAbove = imagePlanes[frameIndex + 1].imagePositionPatient;
    return distanceBetweenSlices(ipp, ippAbove);
  } else if (frameIndex === numberOfSlices - 1) {
    const ippBelow = imagePlanes[frameIndex - 1].imagePositionPatient;
    return distanceBetweenSlices(ipp, ippBelow);
  }
  const ippBelow = imagePlanes[frameIndex - 1].imagePositionPatient;
  const ippAbove = imagePlanes[frameIndex + 1].imagePositionPatient;
  return (
    (distanceBetweenSlices(ipp, ippBelow) +
      distanceBetweenSlices(ipp, ippAbove)) /
    2
  );
}
function _getSliceThickness ( images , imagePlanes , frameIndex ) { const numberOfSlices = images . length ; const ipp = imagePlanes [ frameIndex ] . imagePositionPatient ; if ( frameIndex === 0 ) { const ippAbove = imagePlanes [ frameIndex + 1 ] . imagePositionPatient ; return distanceBetweenSlices ( ipp , ippAbove ) ; } else if ( frameIndex === numberOfSlices - 1 ) { const ippBelow = imagePlanes [ frameIndex - 1 ] . imagePositionPatient ; return distanceBetweenSlices ( ipp , ippBelow ) ; } const ippBelow = imagePlanes [ frameIndex - 1 ] . imagePositionPatient ; const ippAbove = imagePlanes [ frameIndex + 1 ] . imagePositionPatient ; return ( ( distanceBetweenSlices ( ipp , ippBelow ) + distanceBetweenSlices ( ipp , ippAbove ) ) / 2 ) ; }
Estimates the slice thickness given the image position patient of adjacent frames.
Estimates the slice thickness given the image position patient of adjacent frames .
// Special cases: Edge of volume - Assume thickness is the distance // between the current slice and the closest slice as this is all the information we have. // Estimate slice thickness from the two adjacent slices.