This guide shows how to convert NRRD segmentation files to Neuroglancer precomputed format with meshes.
Root cause: Mesh vertices were in physical coordinates (microns) instead of voxel coordinates.
Fix: Removed spacing parameter from marching_cubes() call. Neuroglancer applies resolution scaling separately.
Clarification: The NRRD files contain multiple anatomical structures as separate segments (this is correct).
If you see unexpected fragmentation, use merge_segments.py to consolidate connected components.
cd /home/ddelpiano/git/neuroglass/dataScripts/nrrd_to_precomputed
python inspect_nrrd.py files/VFB_00101567.nrrdOnly use this if you want to merge disconnected pieces into single segments:
python merge_segments.py \
files/VFB_00101567.nrrd \
files/VFB_00101567_merged.nrrd \
--min-size 100 \
--verbosepython converter.py \
--input-dir files \
--output-path output \
--verboseThis will:
- Find all
.nrrdfiles infiles/directory - Convert each to precomputed format in
output/directory - Create a mapping file:
output/sources_to_dataset.json
python meshes_generator.py \
--input-path output \
--dust-threshold 100 \
--verboseThis will:
- Find all precomputed datasets in
output/directory - Generate meshes for each segment (skipping segments < 100 voxels)
- Create segment properties (labels and metadata)
- Generate
output/neuroglancer_state.jsonfor easy loading
cd output
npx http-server . -p 8080 --cors- Go to https://neuroglancer-demo.appspot.com/
- Click the
{}(JSON) button in the top-right - Copy the contents of
output/neuroglancer_state.json - Paste into the JSON editor
- Click outside the editor to load
- Check the browser console for errors
- Verify mesh files exist:
ls -lh output/*/mesh/ - Check segment IDs match:
python inspect_nrrd.py files/VFB_00101567.nrrd | grep "Segment IDs"
- Try loading a single segment manually in Neuroglancer UI
- Use
inspect_nrrd.pyto see segment IDs and sizes - The NRRD files contain pre-labeled anatomical structures
- If you see unexpected fragmentation, verify with the original data source
- Reduce
--dust-thresholdto skip more small segments - Generate meshes for fewer segments initially
- Check your mesh file sizes