3D-printing nii data

In this blog post, I want to write about pipelines on how to prepare Nifti-brain data and make them printable by a 3D-printer.

Two pipelines are shown. One pipeline describes the 3D-printing the cortical folding structure that is estimated with Freesurfer and subsequently corrected with Meshlab. And another pipeline describes how you can 3D-print any binary nii-volume by using the AFNI-program IsoSurface and correct the output with netfabb. 

Pipeline 1: Cortex preparation with Freesurfer and Meshlab

Freesurfer analysis to get cortical sheet

In you don’t have it already, get FREESURFER.
1. Place NIFTI file to process it in /Applications/freesurfer/subjects
2. Open a shell, enter the following commands:
/bin/bash
FREESURFER_HOME=/Applications/freesurfer
source $FREESURFER_HOME/SetUpFreeSurfer.sh
recon-all –all –i [path of NIFTI file here] -s mybrain

3. Once FreeSurfer has completed processing the scan (after about 24 hours) enter the following commands to convert the surfaces to STL files:
mris_convert /usr/local/freesurfer/subjects/mybrain/surf/rh.pial rh.stl
mris_convert /usr/local/freesurfer/subjects/mybrain/surf/lh.pial lh.stl

Processing in Meshlab

If you don’t have it already, get Mashlab.

1. Open Meshlab
2. File>Import Mesh> /Applications/freesurfer/subjects/mybrain/surf/rh.stl
3. File>Import Mesh> /Applications/freesurfer/subjects/mybrain/surf/lh.stl
4. Filters>Mesh Layer>Flatten Visible Layers
5. Click Apply
6. Filters>Remeshing Simplification and Reconstruction>Quadric Edge Collapse Decimation (this cuts out wholes and merges overlapping objects)
7. Enter desired Target Number of Faces (suggested: 200,000) and Apply
8. Optional: Filters>Smoothing, Fairing and Deformation>HC Laplacian Smooth (for esthetic reasons)
9. Export Mesh to convenient location, export as a .STL file 3D Printing

Pipeline 2: Printing arbitrary 3D-structures in nii with IsoSurface and netfabb

Converting binary nii volume to STL surface in IsoSurface

In case you want to 3D-print any other shape of the brain. E.g. entire brain including the cerebellum and brain stem (aseg volume file in FreesSurfer). You can also generate your own surfaces independent of Freesurfer.

This can be done in the AFNI program IsoSurface e.g. with the following command (this command takes less than 60 sec to run).

IsoSurface -isoval 1 -input binary.nii -Tsmooth 0.1 100  -remesh 0.5 -overwrite -autocrop -o Output.stl

The output of this command is not necessarily a 2-manifold. Thus, the 3D-printer cannot print it. It can be corrected, however, with netfabb.

Correcting for non-manifolds in netfabb

If its not already installed on the 3D-printer control computer, install netfabb basic.

1. Open netfabb-basic and load in the STL file that needs to be fixed for non-manifolds.
2. Click on the repair symbol (red cross).
3. Click on Automatic repair and Apply repair.

20180725_123228-01.jpeg
example view of the repairing for non-manifolds in netfabb

3D-printing in CatalystEX

1. Start the 3D-printer program CatalystEX and load in the STL file that you generated with either one of the steps described above.
2. Enter Properties as desired (suggested: “Sparse- low density” for model interior 0.40.5and “SMART” support fill).

20180723_153853-01.jpeg
example settings for 3D-printing in CatalystEX

3. Go to Orientation Tab, Click Auto Orient
4. Click Process STL. Note that processing may take some time.
5. Click Add to Pack Only Once (if you are printing a live size brain, this step can take up to 4 hours).
6. Click Print to Add File to Print Queue
-Note: Printing a large and detailed model will take about 3 days once printing starts.

20180727_105359-01.jpeg

Acknowledgments

I want to thank John Schwartz for teaching me on how to use a 3D-printer. I want to thank Pete Molfese for tips regarding IsoSurface.