Web Browser Processing Pipelines

These processing pipeline execution functions can be used from within a web
browser.

Most of these functions return a Promise.

These functions return the WebWorker used for computation. They also optionally accept a web worker from a previous execution as their first argument – pass the worker generated from execution or null if one is not available.


runPipelineBrowser(webWorker, pipelinePath, args, outputs, inputs) -> result

Run an itk.js Emscripten module with Node.js.

webWorker: Re-use a WebWorker generated by a previous call to runPipelineBrowser. Usually, null is passed here instead, which will result in generation of a new WebWorker.

pipelinePath: Path to the pre-built pipeline module, without .js or Wasm.js extensions.

args: A JavaScript Array of strings to pass to the execution of the main function, i.e. arguments that would be passed on the command line to a native executable.

outputs: A JavaScript Array containing JavaScript objects with two properties: path and type.

path is the file path on the virtual filesystem to read after execution has completed.

type is one of the itk/IOTypes:


IOTypes.Text
A UTF8-encoded string. To write this data type in C++, write a plain text file with, e.g. std::ofstream.

IOTypes.Binary
A binary Uint8Array. To write this data type in C++, read the binary file with, e.g. std::ofstream with the std::ofstream::binary flag to std::ofstream::open.

IOTypes.Image
An itk/Image. To write this data type in C++, use the itk::ImageFileWriter, add BridgeJavaScript module to the ITK find_package COMPONENTS in your CMakeLists.txt, and use .json for the image file name extension.

IOTypes.Mesh
An itk/Mesh. To write this data type in C++, use the itk::MeshFileWriter, add BridgeJavaScript module to the ITK find_package COMPONENTS in your CMakeLists.txt, and use .json for the image file name extension.

IOTypes.vtkPolyData
A vtk.js PolyData. To write this data type in C++, use the vtkJSONDataSetWriter, and add vtkIOExport module to the VTK find_package COMPONENTS in your CMakeLists.txt

inputs: A JavaScript Array containing JavaScript objects with three properties: path, type, and data.

data contains the corresponding data to write to the virtual filesystem before executing the module.

path is the file path on the virtual filesystem to read after execution has completed.

type is one of the itk/IOTypes:


IOTypes.Text
A UTF8-encoded string. To read this data type in C++, read the plain text file with, e.g. std::ifstream.

IOTypes.Binary
A binary Uint8Array. To read this data type in C++, read the binary file with, e.g. std::ifstream with the std::ifstream::binary flag to std::ifstream::open.

IOTypes.Image
An itk/Image. To read this data type in C++, use the itk::ImageFileReader, add BridgeJavaScript module to the ITK find_package COMPONENTS in your CMakeLists.txt, and use .json for the image file name extension.

IOTypes.Mesh
An itk/Mesh. To read this data type in C++, use the itk::MeshFileReader, add BridgeJavaScript module to the ITK find_package COMPONENTS in your CMakeLists.txt, and use .json for the image file name extension.

result: A JavaScript object with four properties: stdout, stderr, outputs, and webWorker.
stdout and stderr are strings. outputs is an array with { path, type, data } content that corresponds to the values specified in the function call. webWorker is the WebWorker used for pipeline execution.