Say you have a number of meshes in FreeSurfer ascii format (with extension *.asc or *.srf), one brain structure per file. However, for later processing or to import in some computer graphics software, you would like to have these multiple meshes all in a single file. This post provides a small script to accomplish this: mergesrf.
To use it, right click and save the file above, make it executable and, ideally, put it in a place where it can be found (or add its location to the environmental variable ${PATH}
. Then run something as:
mergesrf file1.srf file2.srf fileN.srf mergedfile.srf
In this example, the output file is saved as mergedfile.srf
. Another example is to convert all subcortical structures into just one large object, after aseg2srf
as described here. To convert all, just change the current directory to ${SUBJECTS_DIR}//ascii
, then run:
mergesrf * aseg_all.srf
A list with the input files and the output at the end is shown below:
The script uses Octave, which can be downloaded freely. The same script, with a small modification, can also run from inside matlab. This other version can be downloaded here: mergesrf.m
Requirements
In addition to Octave (or matlab), the script also requires functions to read and write surface files, which are available from the areal package (described here and downloadable here).
Pingback: Braindering with ASCII files | Brainder.