# Freesurfer Script Writing

An Introduction to Freesurfer

Freesurfer is a processing software commonly used for the purposes of neuroimaging processing and data analysis. It allows for the visualization of structural and functional areas of the brain, making it especially useful in my field of research, which explores the role of Gamma Amino Butyric Acid (GABA) as a biomarker in the prognosis and treatment trajectories in stroke patients. Processing through the Freesurfer pipeline is conducted through C shell, a Terminal shell which is used as an executive command interpreter.

This blog post is meant to document some of the procedural aspects of data analysis in my subset of neuroscience research, which mainly includes neuroimaging and topographical mapping of the brains of patients who have suffered from stroke. As an undergraduate, I have relatively little experience writing scripts and computer programming; this post is meant to be a guide to beginners on how to I utilized the Freesurfer pipeline as I peruse and attempt to solve the methodological complications that may arise while creating and editing scripts within the pipeline myself.

Methods and Directives I have Completed thus Far:

$Autoreconall-1,$Autoreconall-2, and $Autocreconall-3, are all a series of commands used in the reconstruction of cortical images based on post-stroke T1 MRI scans of patients. These co mmands scan for topographical errors and are known as clustered directives. Clustered directives allowed me to perform a series of commands all at once, thus more efficient processing and correcting brain scans. Additionally commands such as$foreach allow one to process the scans for each subject all at once, thus minimizing the amount of script I had to input into Terminal, the MAC operating system that hosts C shell.

The processing of these images took about three days to complete, and one subject had to be thrown out due to an excess of topographical images found on the original T1 MRI. After these were complete, I was able to utilize Freeview, a visualization tool within the Freesurfer pipeline, to look at the final, reprocessed brain volumes and check for any abnormalities, such as whether regions of the brain were cutoff. An example of a sample scan visualized in Freeview can be seen below:

Finally after this has been completed, a stats script was used in order to extract statistical data. However, after attempting to input the script an error (shown in the image below) came up. Although, according to others working within C shell or BASH, this seems to be a fairly common error, none of the suggested corrections to the script (most of which came from this thread: https://askubuntu.com/questions/304999/not-able-to-execute-a-sh-file-bin-bashm-bad-interpreter) seemed to help resolve the issue.  Hopefully these will be resolved within the week.

/bin/bash^M: bad interpreter: No such file or directory

## 4 Replies to “Freesurfer Script Writing”

1. Zach Shuster says:

Fascinating post!
Is there any information you could give us on what the image posted means? What do the various colors indicate? etc.

2. Michael Francis Thees says:

I like your post, it is exactly what we talked about and what I was looking for. There are a few formatting things I want to make you aware of in paragraphs 2-5

$Autoreconall-1,$Autoreconall-2, and $Autocreconall-3, are all a series of commands used in the reconstruction of cortical images based on post-stroke T1 MRI scans of patients. These co mmands scan for topographical errors and are known as clustered directives. To start with you can have the text appear as code in the actual post by doing ‘ ‘ so for example (I don’t actually know if this will work in comments…):$Autoreconall-1

Second be careful you ended up with a weird line break in there.

I will also point out that, while ask ubuntu is a great resource it is generally geared towards people using ubuntu and the ubunutu build for any linux application. Naturally the build varies from kernel to kernel (ie year to year) and that post is from 2013, so it may be worth while to make a new post there (referencing the old one) if you are using ubuntu as your OS.

3. Elliot Ji says:

I really like the post! It’s well-organized and very clear on the steps you took to do the research. I can’t comment on anything else since it’s completely above my ability to comprehend. What have the past works done? It’s quite awesome that you use software to visualize human brain!

4. Danial Arslan says:

This post was really well written. I like the flow and direction you give your blog post by first starting off with an introduction of the program you have been using to then talking about the various scripts you have been utilizing, such as clustered derivatives, and finally focusing on a specific problem you are dealing with now. You could even create a short section within your blog where you talk about how the MRI scans are visually interpreted by explaining how to analyze the picture you have included in your post.
As regards to the error you discuss, you mention how it is common within C shell or BASH. Why is that so and what causes the error to occur?