Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read tensorboard logs #2

Merged
merged 3 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tensorboard_plugin_3d/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"itk-viewer-icons": "^11.11.2",
"itk-viewer-material-ui": "https://github.com/InsightSoftwareConsortium/itk-viewer-material-ui",
"material-ui": "^0.20.2",
"ndarray-pack": "^1.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
Expand Down
45 changes: 39 additions & 6 deletions tensorboard_plugin_3d/client/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import materialUIMachineOptions from 'itk-viewer-material-ui/src/materialUIMachineOptions'
import modifiedCreateInterface from './main'
import ndarraypack from 'ndarray-pack'

const uiMachineOptions = { ...materialUIMachineOptions }

Expand All @@ -9,10 +10,42 @@ uiMachineActions.createInterface = modifiedCreateInterface
uiMachineOptions.actions = uiMachineActions

const container = document.querySelector('.content')
const ipfsImage = new URL("https://data.kitware.com/api/v1/file/564a65d58d777f7522dbfb61/download/data.nrrd")
window.itkVtkViewer.createViewer(container,
{
image: ipfsImage,
rotate: false,
config: { uiMachineOptions },

async function fetchJSON(url) {
const response = await fetch(url);
if (!response.ok) {
return null;
}
const data = response.json();
return data;
}

function encodeScijsArray(array){
const encoded = {
_rtype: 'ndarray',
_rdtype: array.dtype,
_rshape: array.shape,
_rvalue: array.data,
}
return encoded
}

async function createViewer() {
const img_data = await fetchJSON('../images').then(response => {
let image_data = {image: encodeScijsArray(ndarraypack(response.images[0].array))}
if (response.images.length > 1) {
image_data.labelImage = encodeScijsArray(ndarraypack(response.images[1].array))
}
response.images.forEach((img) => {
encodeScijsArray(ndarraypack(img.array))
})
return image_data
})
window.itkVtkViewer.createViewer(container,
{
...img_data,
rotate: false,
config: { uiMachineOptions },
})
}
createViewer()
Loading