Tunnelvision is an experimental tensor viewer for IPython environments based on Voxel.
Tunnelvision requires Python 3.7+. Binary wheels are available for MacOS (x86_64/arm64) and Linux.
To install Tunnelvision, run:
pip install tunnelvisionThe API of tunnelvision is very similar to that of matplotlib. Tunnelvision is a 5D tensor viewer that requires tensors to have the following format: Batch x Depth x Height x Width x Channels, where channels can be 1 (grayscale/monochrome) or 3 (RGB). You can quickly plot (medical) images using:
import numpy as np
import tunnelvision as tv
arr = np.random.randint(0, 2048, (2, 3, 224, 224, 1), dtype=np.uint16)
tv.show(arr)More advanced plots with segmentation overlays (or colormaps in general) can be created as follows:
ax = tv.Axes(figsize=(512, 512))
ax.imshow(arr1)
ax.imshow(arr2, cmap="seg")
ax.show()Pyvoxel has support for tunnelvision as well, which allows you to plot images with their correct orientation and spacing, without having to manually set those in the configuration:
import voxel as vx
mv = vx.load("../data/ct/")
tv.show(mv)To use tunnelvision through VS Code remote, we need forward an arbitrary available port to the tunnelvision-server. Once you have forwarded a port from the ports pane within VS Code, make sure to add it to your configuration file for tunnelvision:
# ~/.cache/tunnelvision/default_config.yaml
port: 1337Typically, problems will revolve around the WebSockets connection. Make sure your port is forwarded when working remote. Make sure the handshake between the client and server was successful by inspecting the state.websocket object. One can use ps aux | grep tunnelvision to inspect whether the server is running. Logs for the server are stored in ~/.cache/tunnelvision.