function groupMonochromeInstances (metadata) {
  const channels = []
  for (let i = 0; i < metadata.length; ++i) {
    const microscopyImage = new VLWholeSlideMicroscopyImage({
      metadata: metadata[i]
    })
    if (microscopyImage.ImageType[2] !== 'VOLUME') {
      continue
    }

    if (microscopyImage.SamplesPerPixel === 1 &&
        microscopyImage.PhotometricInterpretation === 'MONOCHROME2') {
      // this is a monochrome channel
      const pathIdentifier = microscopyImage.OpticalPathSequence[0].OpticalPathIdentifier
      const channel = channels.find(channel => {
        return channel[0].OpticalPathSequence[0].OpticalPathIdentifier === pathIdentifier
      })

      if (channel) {
        channel.push(microscopyImage)
      } else {
        channels.push([microscopyImage])
      }
    }
  }

  return channels
}
/** Group DICOM metadata of monochrome slides by Optical Path Identifier.
 *
 * @param {Object[]} metadata - DICOM JSON objects representing metadata of VL Whole Slide Microscopy Image instances.
 *
 * @returns {Object[]} Groups of formatted VLWholeSlideMicroscopyImage instances
 * @memberof metadata
 */
Group DICOM metadata of monochrome slides by Optical Path Identifier.
@param {Object[]} metadata - DICOM JSON objects representing metadata of VL Whole Slide Microscopy Image instances.

@returns {Object[]} Groups of formatted VLWholeSlideMicroscopyImage instances
@memberof metadata
Group DICOM metadata of monochrome slides by Optical Path Identifier . @param { Object [] } metadata - DICOM JSON objects representing metadata of VL Whole Slide Microscopy Image instances . @returns { Object [] } Groups of formatted VLWholeSlideMicroscopyImage instances @memberof metadata
function groupMonochromeInstances (metadata) {
  const channels = []
  for (let i = 0; i < metadata.length; ++i) {
    const microscopyImage = new VLWholeSlideMicroscopyImage({
      metadata: metadata[i]
    })
    if (microscopyImage.ImageType[2] !== 'VOLUME') {
      continue
    }
    if (microscopyImage.SamplesPerPixel === 1 &&
        microscopyImage.PhotometricInterpretation === 'MONOCHROME2') {
      const pathIdentifier = microscopyImage.OpticalPathSequence[0].OpticalPathIdentifier
      const channel = channels.find(channel => {
        return channel[0].OpticalPathSequence[0].OpticalPathIdentifier === pathIdentifier
      })
      if (channel) {
        channel.push(microscopyImage)
      } else {
        channels.push([microscopyImage])
      }
    }
  }
  return channels
}
function groupMonochromeInstances ( metadata ) { const channels = [ ] for ( let i = 0 ; i < metadata . length ; ++ i ) { const microscopyImage = new VLWholeSlideMicroscopyImage ( { metadata : metadata [ i ] } ) if ( microscopyImage . ImageType [ 2 ] !== 'VOLUME' ) { continue } if ( microscopyImage . SamplesPerPixel === 1 && microscopyImage . PhotometricInterpretation === 'MONOCHROME2' ) { const pathIdentifier = microscopyImage . OpticalPathSequence [ 0 ] . OpticalPathIdentifier const channel = channels . find ( channel => { return channel [ 0 ] . OpticalPathSequence [ 0 ] . OpticalPathIdentifier === pathIdentifier } ) if ( channel ) { channel . push ( microscopyImage ) } else { channels . push ( [ microscopyImage ] ) } } } return channels }
Group DICOM metadata of monochrome slides by Optical Path Identifier.
Group DICOM metadata of monochrome slides by Optical Path Identifier .
// this is a monochrome channel