Published
Edited
Jul 9, 2020
Insert cell
md`# Hello ITK (unfinished)`
Insert cell
html` <div>
<label>Select image or mesh:</label>
<input name="inputFile" type="file">
</div>

<!-- File information -->
<textarea readonly name="fileInformation">File information...</textarea>

<!-- File visualization -->
<div id="viewer"></div>
`
Insert cell
{
var fileInput = document.querySelector("input");
fileInput.addEventListener("change", processFile);
return fileInput;
}
Insert cell
function processFile(event) {
const outputTextArea = document.querySelector("textarea");
outputTextArea.textContent = "Loading...";

const dataTransfer = event.dataTransfer;
const files = event.target.files || dataTransfer.files;

const viewerElement = document.getElementById('viewer')
//!!viewerElement && itkVtkViewer.createViewerFromFiles(viewerElement, files)

return itk.readFile(null, files[0]).then(function({ image, mesh, polyData, webWorker }) {
webWorker.terminate();
var imageOrMeshOrPolyData = image || mesh || polyData;

function replacer(key, value) {
if (!!value && value.byteLength !== undefined) {
return String(value.slice(0, 6)) + "...";
}
return value;
}
outputTextArea.textContent = JSON.stringify(imageOrMeshOrPolyData, replacer, 4);
});
}
Insert cell

image = itk.readImageLocalDICOMFileSeries(filePaths, false);
Insert cell
itk = require('https://unpkg.com/itk@12.4.0/umd/itk.js').then(() => window.itk);
Insert cell
itkViewer = require('https://unpkg.com/itk-vtk-viewer@9.23.2/dist/itkVtkViewerCDN.js');
Insert cell
vtk = require("vtk.js").then(() => window.vtk);
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more