3D Brain Models: Difference between revisions
Line 15: | Line 15: | ||
The srf2obj script requires the installation of gawk if it's not already installed. The script can be found in the '''scripts/Shell''' folder on ubfs, and should be in your path (copy it to your ~/bin directory if you don't already have it). | The srf2obj script requires the installation of gawk if it's not already installed. The script can be found in the '''scripts/Shell''' folder on ubfs, and should be in your path (copy it to your ~/bin directory if you don't already have it). | ||
srf2obj lh.pial.srf > lh.pial.obj | srf2obj lh.pial.srf > lh.pial.obj | ||
If you are reading this wiki and aren't part of my lab, here is the srf2obj gawk script. I stole it from Anderson WInkler's blog. The only change I made is that gawk is installed in /usr/bin/ on my distribution of Ubuntu. You can copy/paste the script below to a text file to make a script (you'll still have to make it executable). | |||
#!/usr/bin/gawk -f | |||
BEGIN { if (ARGV[1] == "") { | |||
print "Convert Surface ASCII format to OBJ." | |||
print "" | |||
print "Usage:" | |||
print "srf2obj input.srf > output.obj" | |||
print "" | |||
print "The output goes to stdout. Use > to redirect to" | |||
print "a file, as shown above" | |||
print "" | |||
print "_____________________________________" | |||
print "Anderson M. Winkler" | |||
print "Yale University / Institute of Living" | |||
print "Jan/2010" | |||
print "http://brainder.org" | |||
exit } } | |||
# Count number of vertices and faces from the 2nd record | |||
NR == 2 { nV=$1 ; nF=$2 } | |||
# Convert vertex coordinates | |||
NR>=3 && NR<=nV+2 { print "v", $1, $2, $3} | |||
# Convert faces' vertex indices | |||
NR>=nV+3 && NR<=nV+nF+2 { print "f", $1+1, $2+1, $3+1 } | |||
=Blender= | =Blender= |
Revision as of 10:37, 29 May 2019
This page is all about turning FreeSurfer surface files into 3D printable models. Inspiration comes from here
Free Surfer
Create a WaveFront OBJ File
Use mris_convert to convert from FreeSurfer binary to ASCII:
mris_convert lh.pial lh.pial.asc
Repeat for both hemispheres
Rename Files
mv lh.pial.asc lh.pial.srf
Repeat for both hemispheres
Use srf2obj to create a Blender-Compatible File
The srf2obj script requires the installation of gawk if it's not already installed. The script can be found in the scripts/Shell folder on ubfs, and should be in your path (copy it to your ~/bin directory if you don't already have it).
srf2obj lh.pial.srf > lh.pial.obj
If you are reading this wiki and aren't part of my lab, here is the srf2obj gawk script. I stole it from Anderson WInkler's blog. The only change I made is that gawk is installed in /usr/bin/ on my distribution of Ubuntu. You can copy/paste the script below to a text file to make a script (you'll still have to make it executable).
#!/usr/bin/gawk -f BEGIN { if (ARGV[1] == "") { print "Convert Surface ASCII format to OBJ." print "" print "Usage:" print "srf2obj input.srf > output.obj" print "" print "The output goes to stdout. Use > to redirect to" print "a file, as shown above" print "" print "_____________________________________" print "Anderson M. Winkler" print "Yale University / Institute of Living" print "Jan/2010" print "http://brainder.org" exit } } # Count number of vertices and faces from the 2nd record NR == 2 { nV=$1 ; nF=$2 } # Convert vertex coordinates NR>=3 && NR<=nV+2 { print "v", $1, $2, $3} # Convert faces' vertex indices NR>=nV+3 && NR<=nV+nF+2 { print "f", $1+1, $2+1, $3+1 }
Blender
After creating the pial layer hemisphere's in FreeSurfer, you're next going to want to import one file at a time into Blender. Once the file has been imported there should be a gray brain mesh on the screen in Blender. To make working with the mesh easier you can change it's size by going to the bottom left-hand side of the page and change the X, Y, and Z coordinates to 1.0. Once they are all at 1.0 the brain will be much smaller and fit nicely within the provided grid. You can use the rotate and transform tools on the left-hand side of the screen to move and change the direction of the brain. To the best of your ability, try to get the brain level on all planes in a way similar to it's real life orientation. After the first hemisphere is in place do the exact same process with the other hemisphere. Once both halves are of the same size and orientation, try to align them next to each other as best as possible and join the halves into one object by right clicking on one half, then hold shift down and right click on the other. After both hemispheres are selected you just have to press CTRL + J, and the two halves should become one mesh.
3D Printing
The 3D printers at UB use a multitude of files, but all of the printers will accept .stl files (which Blender will let you directly export any file as that). Before printing you will need to fix your STL files using the Netfabb online service (requires a free autodesk account) https://service.netfabb.com/login.php