How to use the itk/runPipelineBrowser function in itk

To help you get started, we’ve selected a few itk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github InsightSoftwareConsortium / itkwidgets / js / lib / viewer.js View on Github external
}
  const numberOfBytes = pixelCount * image.imageType.components * componentSize
  const pipelinePath = 'ZstdDecompress'
  const args = ['input.bin', 'output.bin', String(numberOfBytes)]
  const desiredOutputs = [
    { path: 'output.bin', type: IOTypes.Binary }
  ]
  const inputs = [
    { path: 'input.bin', type: IOTypes.Binary, data: byteArray }
  ]
  console.log(`input MB: ${byteArray.length / 1000 / 1000}`)
  console.log(`output MB: ${numberOfBytes / 1000 / 1000 }`)
  const compressionAmount = byteArray.length / numberOfBytes
  console.log(`compression amount: ${compressionAmount}`)
  const t0 = performance.now()
  return runPipelineBrowser(null, pipelinePath, args, desiredOutputs, inputs)
    .then(function ({stdout, stderr, outputs, webWorker}) {
      webWorker.terminate()
      const t1 = performance.now();
      const duration = Number(t1 - t0).toFixed(1).toString()
      console.log("decompression took " + duration + " milliseconds.")

      switch (image.imageType.componentType) {
        case IntTypes.Int8:
          image.data = new Int8Array(outputs[0].data.buffer)
          break
        case IntTypes.UInt8:
          image.data = outputs[0].data
          break
        case IntTypes.Int16:
          image.data = new Int16Array(outputs[0].data.buffer)
          break
github InsightSoftwareConsortium / itkwidgets / js / lib / viewer.js View on Github external
const elementSize = DataTypeByteSize[polyData[prop].dataType]
  const numberOfBytes = polyData[prop].size * elementSize
  const pipelinePath = 'ZstdDecompress'
  const args = ['input.bin', 'output.bin', String(numberOfBytes)]
  const desiredOutputs = [
    { path: 'output.bin', type: IOTypes.Binary }
  ]
  const inputs = [
    { path: 'input.bin', type: IOTypes.Binary, data: byteArray }
  ]
  console.log(`${prop} input MB: ${byteArray.length / 1000 / 1000}`)
  console.log(`${prop} output MB: ${numberOfBytes / 1000 / 1000 }`)
  const compressionAmount = byteArray.length / numberOfBytes
  console.log(`${prop} compression amount: ${compressionAmount}`)
  const t0 = performance.now()
  return runPipelineBrowser(null, pipelinePath, args, desiredOutputs, inputs)
    .then(function ({stdout, stderr, outputs, webWorker}) {
      webWorker.terminate()
      const t1 = performance.now();
      const duration = Number(t1 - t0).toFixed(1).toString()
      console.log(`${prop} decompression took ${duration} milliseconds.`)
      polyData[prop]['values'] = new window[polyData[prop].dataType](outputs[0].data.buffer)

      return polyData
    })
}
github Kitware / itk-vtk-viewer / src / processFiles.js View on Github external
return readMeshFile(null, file).then(({ mesh: itkMesh, webWorker }) => {
            const read1 = performance.now();
            const duration = Number(read1 - read0).toFixed(1).toString()
            console.log("Mesh reading took " + duration + " milliseconds.")
            webWorker.terminate()
            const pipelinePath = 'MeshToPolyData'
            const args = ['mesh.json', 'polyData.json']
            const desiredOutputs = [
              { path: args[1], type: IOTypes.vtkPolyData }
            ]
            const inputs = [
              { path: args[0], type: IOTypes.Mesh, data: itkMesh }
            ]
            is3D = itkMesh.meshType.dimension === 3
            convert0 = performance.now()
            return runPipelineBrowser(null, pipelinePath, args, desiredOutputs, inputs)
          }).then(function ({ outputs, webWorker }) {
            const convert1 = performance.now();