Beauchamp:CreateAFNIBRIKfromMR

About the UT Philips Scanner
Our scanner is a 3 T whole-body Philips scanner with 16 parallel RF channels. It is a hybrid Intera (older) and Achieva (newer). Slice acquisition is set to the default order, with the time maximized between adjacent slices. Slice acquisition order seems to be from bottom to top, based on the raw DICOM images (where the first image is the most inferior) and real-time view seen during scanning (where the most inferior images are display first, sometime most superior aren't displayed at all before the next TR starts).

Getting Data From the UT Philips Scanner if you are at UT
Depending on how the data is exported from the scanner, the data will be one of three formats:

NiFTI Format tms_10_10_1.nii This is the preferred format because it can be read by AFNI directly.

PAR/REC Format tms_10_10_1.PAR tms_10_10_1.REC This is the native Philips format. The PAR file contains the data PARameters. The REC file contains the raw REConstructed data for the entire run.

DICOM format IM_2048 Each file contains one image, so that one run has thousands of images in it.

MR data can be sent directly from the Philips scanner to an external hard drive attached to bidwell. (For some reason, the scanner PC cannot connect to Ike or the RAID). The data will end up on bidwell on (129.106.236.180) in  /Volumes/Users/mri/data (which is a link to the "My Passport" external hard disk). Vips will usually put it in a subdirectory on bidwell e.g.  ~mri/data/DR_BEAUCHAMP_2010/ZAE_042710

The data should be copied to /data1 for analysis using this command: scp -r mri@129.106.236.180:~mri/data/DR_BEAUCHAMP_2010/ZAJ_051210 /Volumes/data1/UT/ZAJ/

If you are not sure what directory to use, you can open a window to bidwell with the following command ssh mri@129.106.236.180 cd ~mri/data/DR_BEAUCHAMP_2010 ls exit

Getting Data From the UT Philips Scanner if you are at Rice or somewhere else outside UT
Vips will copy the data to the Beauchamp Lab server bidwell on (129.106.236.180) in  /Volumes/Users/mri/data (which is a link to the "My Passport" external hard disk). Vips will usually put it in a subdirectory on bidwell e.g.  ~mri/data/DR_BEAUCHAMP_2010/ZAE_042710

To log in to this machine from Rice, you must VPN onto the UT network, follow the instructions on http://its.uth.tmc.edu/vpn_home.htm Next, ssh to bidwell ssh mri@129.106.236.180 And navigate to the directory where the data is found.

Finally, use the scp command to copy the desired data to the machine outside UT. This will only work if the target machine has an appropriate IP address (in a public domain). This can be tested by ping-ing the target machine. scp -r ZAE_042710 fmri@168.7.67.9: Don't forget the trailing colon, it is critical. How long does this take for a typical experiment (this one is 7 fMRI runs and 2 T1s, about 1 GB), start at Fri Jun  3 11:38:03 CDT 2011 finish at Fri Jun  3 11:44:47 CDT 2011 About 6 minutes total for 1 GB, not too bad.

Getting Data from other Scanners
Data from other scanners will often be stored in DICOM or other formats. DICOM is the standard file format for storing medical data. Typically each scan is saved in a unique folder and each file represents a single slice. OsiriX is a free DICOM viewer for Macs and can be downloaded from the following URL:

http://homepage.mac.com/rossetantoine/osirix/

OsiriX can often extract images from DICOM or other formats and write them out to a directory in standard DICOM format. Then, to3d is used to convert the extracted DICOM files to AFNI BRIK/HEAD files.

Using to3d from the command line
If scanner data is obtained in NiFTI format, then no conversion is necessary (see above). For all other types of scanner data, the program to3d is used to convert the raw data to AFNI BRIK/HEAD files. The preferred way to run to3d is from the command line, so that all parameters are recorded and the process can be automated. To see the to3d options check the help file: to3d –help | more

To process an anatomical dataset, to3d is quite simple because there is only one timepoint. set session = /Volumes/data1/UT/CD/afni to3d -session $session -prefix CDanat IM_*

This creates an AFNI BRIK/HEAD named CD anat from the anatomical DICOM images in the current directory and places them in the "session" directory. AFNI reads information about the images from the DICOM header so that the voxel size and image origin is automatically correct in the BRIK/HEAD file.

To process a functional dataset, to3d if more complicated because we must tell it how many timepoints there were (this information is NOT in the DICOM header). Here is the to3d command to create a BRIK/HEAD from a functional run of DICOM images. to3d -session {$session} -skip_outliers -epan -prefix CDr1 -time:tz 110 33 2750 alt+z IM_*  00000001/IM_*  00000002/IM_*

Alternately, we can run to3d on the PAR/REC file.

to3d -skip_outliers -epan -time:tz 60 33 2750 alt+z 3D:0:0:80:80:1980:tms_10_10_1.REC

Where "1980" is the product of the number of time points and the number of slices (60*33). This requires you to manually enter all of the information about the dataset (voxel dimensions, etc.) in the GUI, as described in the next section. Alternately, a parent dataset can be specified that was collected with the same parameters.

to3d -overwrite -prefix test -skip_outliers -epan -geomparent ~/fMRI_1.nii -time:tz 120 33 2000 alt+z 3D:0:0:80:80:3960:C.B.study_2404_2404_F.REC

Using to3d from the GUI interface
If all of the necessary arguments to create a BRIK/HEAD file are given from the command line, then to3d will create the BRIK/HEAD file and finish. If some arguments are missing, then to3d will display a GUI. For instance, simply go to the directory containing the raw DICOM files and type to3d * from the correct folder. Below is a picture of the GUI interface with the most commonly edited options highlighted. Note that the bottom right of the window includes buttons to view the images, save the dataset, and quit. Normally to3d reads the variable information from the DICOM headers and nothing needs to be changed. Only the filename prefix needs to be set.



Averaging Anatomical Scans Using AFNI
To register all the anatomicals to the space of the anatomical closest in time to the functional data (generally anatr1), this is with just two anatomical's:

3dAllineate -base ${subj}anatr1+orig -source ${subj}anatr2+orig -prefix ${subj}anatr2_2RegTo1 -verb -warp shift_rotate -cost mi -automask -1Dfile ${subj}anatr2toanatr1

Average anatomicals into one dataset:

3dmerge -gnzmean -nscale -prefix ${subj}anatavg ${subj}anatr1+orig ${subj}anatr2_2RegTo1+orig