Last active
September 17, 2020 09:14
-
-
Save dfsp-spirit/15a32fd0da85bff153a0c4206e3ae60c to your computer and use it in GitHub Desktop.
Reading FreeSurfer morphometry data in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
# | |
# This script illustrates how to load FreeSurfer morphometry data in R. | |
# | |
# If you do not have 'freesurferformats' yet, you need to install it: | |
# install.packages('freesurferformats'); | |
library('freesurferformats'); | |
subjects_dir = "~/data/study1"; # Replace with your data (or with example data from the 'fsbrain' package). | |
subject = 'subject1'; | |
# Example for native space data: read the file $HOME/data/study1/subject1/surf/lh.thickness | |
thickness_native_lh = freesurferformats::read.fs.morph(file.path(subjects_dir, subject, 'surf', 'lh.thickness')); | |
# Example for standard space data | |
thickness_std_fwhm10_lh = freesurferformats::read.fs.morph(file.path(subjects_dir, subject, 'surf', 'lh.thickness.fwhm10.fsaverage.mgh')); | |
# Optional: you should now have a look at your data. E.g., you could try: | |
hist(thickness_native_lh); | |
hist(thickness_std_fwhm10_lh); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment