
Tractography Viewer
by Liron Shani
Visualization of diffusion MRI tractography, with a widget to explore slices of a human brain by scrolling.
About this notebook
This notebook shows white matter fiber bundles from diffusion MRI tractography. The bundles come from a single TRX file for subject sub- NDARAA948VFH, from the HBN site RU 64-direction acquisition. The notebook overlays the fibers on a T1-weighted anatomical volume in NIfTI format. It uses ipyniivue for the NiiVue viewer, numpy for the array data, and the standard zipfile, json, and io modules to read the TRX archive.
The notebook reads the streamline positions, offsets, and group files from the TRX zip archive. Each group names one anatomical region. The notebook creates one marimo button per region. When the reader clicks a button, the code extracts the streamlines for that region and loads them as a mesh in the viewer. The viewer shows the T1 image in three planes and a 3D render. The reader can rotate the 3D view and see the selected bundle with a fiber radius of 0.5.
The extract step rebuilds a small TRX archive in memory for the clicked region. It copies the DIMENSIONS and VOXEL_TO_RASMM fields from the source header. The viewer uses a white background, a 3D crosshair, and a clip plane. The 3D zoom is yoked to the 2D zoom.











