Neuroimaging
This post is a bit different. As much as I love baking, I also have a love for neuroscience and anatomy. Neuroscience is a big space with many different forms of research. My main focus has always been in fMRI and structural MRI. To be able to visualize structural and functional aspects of the brain the first step is to prep the data.
In the neuroimaging space there are many analysis packages. The one that I have used extensively and find to be the most straightforward is a free software pack named Freesurfer. You can find more info here: https://surfer.nmr.mgh.harvard.edu/ and even download it to use it yourself!
You will see .nii for image extensions, this is the Neuroimaging Informatics Technology Initiative format and often used in imaging. You can use dicom files with freesurfer but I would suggest looking into MRI convert for conversions of dicom files.
RUNNING FREESURFER RECONSTRUCTION:
contents of <>bracket should be replaced with string of your choice (variable name, filename, folder name etc., path) - don't include bracket
recon-all command for two files (PRE and POST):
recon-all -i <path to file1> -i <path to file2> -subject <name of the output folder that will be created for file1> -subject <name of the output folder that will be created for file1> - all
example:
recon-all -i 3D_T1.nii -all -sd $SUBJECTS_DIR -s 1 -no-isrunning
last -no -isrunning part is telling the software to overwrite previously existing files
last '- all' flag tells freesurfer to run all 3 major stages of freesurfer reconstruction at once. To run them separately use flags: '-autorecon1', '-autorecon2', or '-autorecon3' instead of '-all' flag.
You should read the pages below to understand what free surfer is doing in the recon all process
https://surfer.nmr.mgh.harvard.edu/fswiki/ReconAllBlockDiagram
https://surfer.nmr.mgh.harvard.edu/fswiki/ReconAllDevTable
recon-all
1.recon-all -autorecon1 (stages 1-5)
Talairach transformations, skull-stripping, normalization, intensity normalization
2.recon-all -autorecon2 (stages 6-23)
WM/GM segmentation, parcellation, structure segmentation, surface reconstruction etc.
3.recon-all -autorecon3 (stages 23-30)
Spherical mapping and registration, Statistics, Cortical Parcellation
’recon-all -all’ runs -autorecon1,-autorecon2 and -autorecon3
If you already setup Freesurfer in your terminal window run the command below
freeview -v \
$SUBJECTS_DIR/<yoursubject>/mri/T1.mgz \
$SUBJECTS_DIR/<yoursubject>/mri/wm.mgz \
$SUBJECTS_DIR/<yoursubject>/mri/brainmask.mgz \
$SUBJECTS_DIR/<yoursubject>/mri/aseg.mgz:colormap=lut:opacity=0.2 \
-f $SUBJECTS_DIR/<yoursubject>/surf/lh.white:edgecolor=blue \
$SUBJECTS_DIR/<yoursubject>/surf/lh.pial:edgecolor=red \
$SUBJECTS_DIR/<yoursubject>/surf/rh.white:edgecolor=blue \
$SUBJECTS_DIR/<yoursubject>/surf/rh.pial:edgecolor=red
1. The first line opens freeview with the flag '-v'. The files following the flag are the volumes that Freeview will be loaded with.
2. 'T1.mgz'. The file is the input T1 anatomical MRI file having had motion correction, spatial normalization, intensity normalization, etc. performed upon it.
3. 'wm.mgz' -- the white matter mask.
4. 'brainmask.mgz'-- the brain mask after skull-stripping. This file is inspected to check for issues that may have arised during skull-stripping.
5. 'aseg.mgz' to specify color and opacity.
6. '-f' flag; this flag tells freeview that the following files will now be surfaces rather than volumes. The line goes on to open 'lh.white' -- the left hemisphere white matter surface. The edgecolor of ‘lh.white’ is then set to blue.
7. ‘lh.pial’ - the grey matter surface of the left hemisphere. The edge color is then set to red.
Create your 3D stl file for printing
● mris_convert --combinesurfs
/Applications/freesurfer/subjects/"yoursubject"/surf/lh.pial
/Applications/freesurfer/subjects/"yoursubject"/surf/rh.pial
/Users/yashar/Desktop/"yoursubject".stl
For a single hemi.
● OR mris_convert /usr/local/freesurfer/subjects/"yoursubject"/surf/lh.pial /home/yashar/Documents/"yoursubject".stl