function coordinateFormatGeometry2Scoord3d (coordinates, pyramid) {
  let transform = false
  if (!Array.isArray(coordinates[0])) {
    coordinates = [coordinates]
    transform = true
  }
  const metadata = pyramid[pyramid.length - 1]
  const origin = metadata.TotalPixelMatrixOriginSequence[0]
  const orientation = metadata.ImageOrientationSlide
  const spacing = getPixelSpacing(metadata)
  const offset = [
    Number(origin.XOffsetInSlideCoordinateSystem),
    Number(origin.YOffsetInSlideCoordinateSystem)
  ]

  const affine = buildTransform({
    offset,
    orientation,
    spacing
  })
  coordinates = coordinates.map((c) => {
    const pixelCoord = [c[0], -(c[1] + 1)]
    const slideCoord = applyTransform({ coordinate: pixelCoord, affine })
    return [slideCoord[0], slideCoord[1], 0]
  })
  if (transform) {
    return coordinates[0]
  }
  return coordinates
}
/**
 * Translates coordinates of Total Pixel Matrix in pixel unit into coordinates
 * in Frame of Reference (slide coordinate system) in millimeter unit.
 *
 * @param {number[]|number[][]} coordinates - Coordinates in Total Pixel Matrix
 * @param {Object[]} pyramid - Metadata for resolution levels of image pyramid
 * @returns {number[]|number[][]} Coordinates in Frame of Reference
 * @private
 */
Translates coordinates of Total Pixel Matrix in pixel unit into coordinates
in Frame of Reference (slide coordinate system) in millimeter unit.


Translates coordinates of Total Pixel Matrix in pixel unit into coordinates in Frame of Reference ( slide coordinate system ) in millimeter unit .
function coordinateFormatGeometry2Scoord3d (coordinates, pyramid) {
  let transform = false
  if (!Array.isArray(coordinates[0])) {
    coordinates = [coordinates]
    transform = true
  }
  const metadata = pyramid[pyramid.length - 1]
  const origin = metadata.TotalPixelMatrixOriginSequence[0]
  const orientation = metadata.ImageOrientationSlide
  const spacing = getPixelSpacing(metadata)
  const offset = [
    Number(origin.XOffsetInSlideCoordinateSystem),
    Number(origin.YOffsetInSlideCoordinateSystem)
  ]
  const affine = buildTransform({
    offset,
    orientation,
    spacing
  })
  coordinates = coordinates.map((c) => {
    const pixelCoord = [c[0], -(c[1] + 1)]
    const slideCoord = applyTransform({ coordinate: pixelCoord, affine })
    return [slideCoord[0], slideCoord[1], 0]
  })
  if (transform) {
    return coordinates[0]
  }
  return coordinates
}
function coordinateFormatGeometry2Scoord3d ( coordinates , pyramid ) { let transform = false if ( ! Array . isArray ( coordinates [ 0 ] ) ) { coordinates = [ coordinates ] transform = true } const metadata = pyramid [ pyramid . length - 1 ] const origin = metadata . TotalPixelMatrixOriginSequence [ 0 ] const orientation = metadata . ImageOrientationSlide const spacing = getPixelSpacing ( metadata ) const offset = [ Number ( origin . XOffsetInSlideCoordinateSystem ) , Number ( origin . YOffsetInSlideCoordinateSystem ) ] const affine = buildTransform ( { offset , orientation , spacing } ) coordinates = coordinates . map ( ( c ) => { const pixelCoord = [ c [ 0 ] , - ( c [ 1 ] + 1 ) ] const slideCoord = applyTransform ( { coordinate : pixelCoord , affine } ) return [ slideCoord [ 0 ] , slideCoord [ 1 ] , 0 ] } ) if ( transform ) { return coordinates [ 0 ] } return coordinates }
Translates coordinates of Total Pixel Matrix in pixel unit into coordinates
 in Frame of Reference (slide coordinate system) in millimeter unit.
Translates coordinates of Total Pixel Matrix in pixel unit into coordinates in Frame of Reference ( slide coordinate system ) in millimeter unit .