Sunday, 20 March 2011

Create an averaged brain in Brainvoyager QX


Regional differences in sulcal and gyral topography can be used as disease indications such as in schizophrenia (Csernansky et al., 2008). In the previous video I showed how we can combine multiple aligned surfaces (.srf files) in one surface brain like the following image;

For combining multiple volumes (.vmr files), we use another function in BrainVoyager QX. This function can be accessed in two ways;
1- Through Volumes tab and mouse click on Combine 3D Data Sets... sub tab as shown in the following image.

2- By clicking on 3D Volume Tool then selecting Talairach tab then clicking Combine Data Sets... button as shown in the following image.


After selecting one of the previous options we will get window like the following one, we select wanted files and press on Average button.
The resulted average looks like the following image;

Related links
Run multiple BrainVoyager instances on Mac OSX

Thursday, 17 March 2011

Using bash script to convert freesurfer stats2table (asegstats2table & aparcstats2table)

At the previous entry, I presented how we can use applescript to control asegstats2table and aparcstats2table commands in order to generate text/ascii tables of freesurfer stats data for all subjects in the directory at once. At this entry I will show how we can write a bash script to control both asegstats2table and aparcstats2table commands. This bash script can be used in both Mac OS X and Linux.





freesurferstats2table_bash.zip



The following script uses aparcstats2table and asegstats2table to extract cortical thickness, surface area and volume of manually defined regions of interest using stats files that resulted from qdec.



http://surfer.nmr.mgh.harvard.edu/fswiki/freesurferstats2table

Please leave your feedback if you like this tool or a suggestion if you think it needs to be improved!



Related links

Tuesday, 8 March 2011

Using applescript to convert freesurfer stats2table (asegstats2table & aparcstats2table)



This applescript can be used to control asegstats2table and aparcstats2table commands in order to generate text/ascii tables of freesurfer stats data for all subjects in the directory at once using 4 mouse clicks!
Please click on the link below to download script;


This script is suitable for MAC only.


The following script uses aparcstats2table and asegstats2table to extract cortical thickness, surface area and volume of manually defined regions of interest using stats files that resulted from qdec.
stats2table_qdec.zip

The main purpose of this script is to simplify and automate conversion process because subjects’ IDs should be written with some options in the command line depending on freesurfer stats file. So users will not need to write any thing when they use this script instead of command line;

asegstats2table --subjects bert ernie fred margaret --meas volume --tablefile aseg_stats.txt

or

aparcstats2table --subjects bert ernie fred margaret --hemi rh --meas thickness --tablefile aparc_stats.txt

To visit script page in Freesurfer website please click on the following link 

Brainvoyager QX; rename DICOM files in multiple folders at once



This GUI script can be used to rename DICOM files in multiple folders at once. It depends on “rename DICOM files” tab in File tab menu of Brainvoyager QX.

Tuesday, 1 March 2011

Multiple DICOM to NIfTI converter using dcm2nii and AppleScript



dcm2nii is used to convert from DICOM format to various data format such as; 
Compressed 4D NIfTI nii.gz, 4D NIfTI nii, 3D NIfTI hdr/img and 3D Anlyze hdr/img. Or even it modify NIfTI format. There are two versions; the dcm2niigui and command line dcm2nii. This software was written by Dr. Chris Rorden. It can be downloaded with mricron package;
(http://www.cabiatl.com/mricro/mricron/install.html), 
where mac version link is;
For more information about dcm2nii please visit 
MAC gui version is user friendly but it can convert one data set at a time. Therefore, I wrote an applescript to convert multiple DICOM data sets to NIfTI/Analyze format at one instance using dcm2nii command.


Click below to download script
Multiple dcm2nii converter

For converting Nifti to Analyze and vice versa please visit the following entry;
http://www.easyneuroimaging.com/2012/01/batching-fsl-tools-and-utilities-using.html

And for splitting compressed or single images please visit the following entry;
http://www.easyneuroimaging.com/2011/12/batching-fsl-tools-and-utilities-using.html




Bash script works on both Linux and MAC.
user needs to copy this script to data directory and execute it from there using chmod +x to make it executable as following;
chmod +x dicom2nii.command or chmod +x dicom2nii.sh 
If you will use dicom2nii.command file copy it to your subjects' directory then execute it using dicom2nii.command. dicom2nii.sh you can do the same thing but you cant double click dicom2nii.sh.
Note: If mricron directory is not **** /Applications/mricronmac ****
Please do not forget to change it in **dicom2nii.command**  or  **dicom2nii.command** using any text editor



Please leave your feedback if you like this tool or a suggestion if you think it needs to be improved!

Multiple directories creator


I’ve written this simple applescript to create multiple directories. An example of its use in neuroimaging is creating multiple subjects’ directories for freesurfer. In addition, there is an option to add subdirectories in each folder automatically like “mri/orig” in freesurfer. Those subdirectories are created using Terminal application, so you will see terminal application flashing because it will start and quit every 2 to 3 second during script running. It would create 100 folder within less than 10 seconds and up to 5 minutes for creating 100 folders with subdirectories. 

Multiple directories creator.zip

Please leave your feedback if you like this tool or a suggestion if you think it needs to be improved!

Autoscale of vmr files (Brainvoyager QX) & automation of Advanced segmentation tools


AppleScript is a very powerful and versatile scripting language comes with Mac OS X. It can be used to automate repetitive tasks, which would save huge amount of time. In neuroimaging, most of processes are repetitive across subjects; I already have given an example in my previous blog entry. Repetation of processes is not the only problem, some processes consist of multiple stages where each stage need need long time to be finished. In addition, users should follow processes steps and add entries or click on buttons to move from stage to another. As an example I wrote two GUI applescripts to control advanced segmentation tools in Brainvoyager QX using a small tool called cliclick. Although Brainvoyager is not scriptable since there is no applescript dictionary for it yet, I have been told that, BrainVoyager will become a true scriptable application in a much easier way. Its applescript dictionary will be available soon with the next version.
Now, Brainvoyager QX 2.3 is supporting applescript scripting for Mac OS X users.Updated on Saturday 12 February 2011
 
The following GUI scripts can be used to automate advanced segmentation tools in Brainoyager QX  on multiple subjects data sets. First one; (Autoscale_BVQX) is used to scale vmr files to 0.5 x 0.5 x 0.5 mm3 while the other one (AdvancedST_BVQX) goes through all advanced segmentation tools stages starting from brain peeling step.
Please note that;
* Before starting these scripts, you should install Cliclick shell application in /usr/local/bin.

* Screen resolution should be set to 1440 X 900, otherwise you should change cliclick values along the whole script to fit with icons and buttons locations. 

* In addition, I tested this script on MacBook pro; Ram: 4Gb and CPU: 2.6GH  Core 2 duo and 6MB cache.Therefore, you could change "delay" timing depending on your mac speed by running all process manually for once,However I put 20 to 30 seconds extra time for longer processes.  

* Data sets should be already scaled to 0.5 x 0.5 x 0.5 mm3 before using AdvancedST_BVQX.

  1. *In order to scale multiple data sets to 0.5 x 0.5 x 0.5 mm3 at one instance you could use the other script;   Autoscale_BVQX.    


Please leave your feedback if you like this tool or a suggestion if you think it needs to be improved!


Related links
Run multiple BrainVoyager instances on Mac OSX