Beauchamp:CreateAFNIBRIKfromMR: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
(New page: == Converting DICOM Files to AFNI Files == 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 sl...)
 
(72 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Converting DICOM Files to AFNI Files ==
{{Beauchamp Navigation Bar}}


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:
{| cellspacing="2px" cellpadding="0" border="0" style="padding: 0px; width: 750px; color: #000000; background-color: #ffffff;"
|-valign="top"
|width=400px style="padding: 5px; background-color: #ffffff; border: 2px solid #CC6600;" |
 
Previous step is
[[Beauchamp:HowToScan|How to Collect MRI Data and Use the Scanner]]
Next step is
[[Beauchamp:CreateAFNIBRIK|Turning the raw data into AFNI BRIKs]]
 
== Getting Data from the BCM Siemens Scanners ==
To save the data after you scan, follow these steps:
#View all experiments in the Patient Browser (accessed with button in bottom right of numeric keypad that has folders on it)
#Click on the experiment to export
#Click Transfer, Export Offline
#Select the appropriate destination (\camri\mrisrv) in the pull-down menu next to the "Path" label
#Add the end of the path, type in a new directory (e.g. \Beauchamp\ExperimentCode )
# Click "Yes" when it asks whether to create a new folder
# this should copy into a folder called ExperimentCode
Then, to transfer the data to our server using your own Mac or PC. First, connect to the scanner server using the BeauchampLab login.
on a Mac:
  Apple-K or Go-Connect To Server                      cifs://mrisrv.bcms.bcm.edu/Beauchamp
on a PC
  Tools-Mount Network Drive            \\mrisrv.bcms.bcm.edu\beauchamp
Then, navigate to the correct directory and copy to an analysis directory on the Beauchamp Lab server. This is usually in the format
/Volumes/data/BCM/XXX
Where "XX" is a unique two or three-letter code that corresponds to the experiment.
 
Other alternatives:
To save to a flash drive: Export to Off-Line, Select flash drive, export
 
To save to TABS (the Mac next to the console on 3T-5) where it can then be put on DropBox or elsewhere: Send to tabsSCP
  cd /Users/tabs/tabs/dicom
The DCM files will be placed in a directory named with the date and time, e.g.
 
 
 
Here is the old way:
After you scan, the technologist will send you an e-mail with the link to the data.
If necessary, make a new directory
  mkdir /Volumes/data1/UT/JL
  cd /Volumes/data1/UT/JL
  mkdir raw
  cd raw
And then click on the link and download the data to this directory (called "raw" for ease of reference). The data is stored as an .iso file. Double click on the .iso file to open a window that lists the component data files (with .ima suffix). Click and drag these into the raw directory.
 
== 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/
http://homepage.mac.com/rossetantoine/osirix/


Use to3d to convert the DICOM files to AFNI readable files. to3d can be used either from the command line or from a GUI interface.
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.
 
== Getting Data From the UT Philips Scanner if you are at UT ==
 
The MRI data can be transferred from the scanner in a number of ways; the only fail-safe method is to take a removable USB drive to the scanner room and copy the data directly to it. Alternately, the data can be placed somewhere "in the cloud" by the scanner tech and then moved to the correct place on the server.
One place is the UT NAS. Connect to the NAS by hitting Apple-K and then
 
Login with your UT ID and password. Navigate to the correct directory and copy to the experiment directory.
On the scanner, it may be necessary to use the IP address in windows format (Windows Explorer or My Computer, Tools, Map Network Drive):
 
Another place the data could be placed is in a folder on our server. You must find it and move it to the correct location (experiment directory, "raw" subdirectory).
The folder will be named by Vips (ask him for the name if you cannot find it) and is located on the server internal hard disk, as opposed to the RAID connected to the server.
<b>GUI Version</b>. Make sure that both the "data" drive (RAID) AND "beauchamplab" (server internal hard disk) are mounted on your Mac. Apple-K to XXXXXXX and select both if they are not.
Open one finder window and navigate to ms-nbafmri/beauchamplab and find the folder with your data in it. Move or copy it to the correct experiment directory.
<b>Command line version</b>.
 
Navigate to the correct directory. Then, copy to the correct location on the server as follows. Replace the sample directory name with the desired one; this is the name given by Vips. Be sure you have created the experiment directory, including the raw subdirectory, already.
cp -r ZAP_081612/* /Volumes/Pegasus/data/UT/ZAP/raw/
 
<b>More Notes</b>
 
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.
 
Method 1:
Vips doesn't like this because it is too slow.
Using a package called ExpanDrive
  https://secure.expandrive.com/
Vips can connect directly to a Mac server with scp (ssh must be enabled on the server).
He will copy it to the "BeauchampServer" dirve mounted on the Philips console. This is a link to the ms-nbafmri server located at 139.52.4.123
(For Tim's data, it is copied to data on ike).
The next step is to copy it from the ms-nbafmri server to the correct experiment directory. Here are the steps to do that:
 
For ms-nbafmri ii is copied to the admin home directory (on the server hard disk) and needs to be copied to the correct location (on the Promise RAID).
 
Use the Amazon/Gmail lab password. Find where the data is located.
  cd DATA
  ls
Then, copy to the correct location on the server as follows. (Replace the sample directory name with the desired one; this is the name given by Vips).
cp -r ZAP_081612 /Volumes/Pegasus/data/UT/
 
Method 2:
Faster for Vips, but involves an extra step for us.
Data can be copied to the NAS and then transferred from there to the server. On Windows, mount the NAS with
 
On Macs, Apple-K and then
 
For either case, log in with your UT user ID and password.


===Using to3d from the GUI interface ===
OLDER:
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  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.


To load the GUI component of to3d just specify all the files from a single scan. Since each scan typically has its own folder this can be as simple as running
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.


[[Image:To3d.jpg| 600px]]
The data should be copied to /data1 for analysis using this command:


=== Using to3d from the command line (Faster) ===


to3d can also write files from the command line, which is particularly helpful when writing scripts to automate the task for several subjects. There are also more options from the command line. To see them all check the help file:
If you are not sure what directory to use, you can open a window to bidwell with the following command
to3d –help | more
After the files have been created you should use 3dcopy to save a copy in the subject’s surfaces directory.


mkdir /surfaces/subject_name
  cd ~mri/data/DR_BEAUCHAMP_2010
mkdir /surfaces/subject_name/afni
  ls
3dcopy subjIDanatr /surfaces/subject_name/afni/subjIDanatr
  exit


Note that 3dcopy automatically moves the BRIK and HEAD files that share the prefix subjIDanatr, and the program also appends the header file’s history.
== Getting Data From the UT Philips Scanner if you are at Rice or somewhere else outside UT ==


=== Averaging Anatomical Scans Using AFNI ===
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 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:
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


  3dAllineate -base ${subj}anatr1+orig -source ${subj}anatr2+orig -prefix ${subj}anatr2_2RegTo1 -verb -warp shift_rotate -cost mi -automask -1Dfile ${subj}anatr2toanatr1
And navigate to the directory where the data is found.


Average anatomicals into one dataset:
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.


   3dmerge -gnzmean -nscale -prefix ${subj}anatavg ${subj}anatr1+orig ${subj}anatr2_2RegTo1+orig
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.

Revision as of 14:40, 30 July 2015

Brain picture
Beauchamp Lab



Previous step is How to Collect MRI Data and Use the Scanner Next step is Turning the raw data into AFNI BRIKs

Getting Data from the BCM Siemens Scanners

To save the data after you scan, follow these steps:

  1. View all experiments in the Patient Browser (accessed with button in bottom right of numeric keypad that has folders on it)
  2. Click on the experiment to export
  3. Click Transfer, Export Offline
  4. Select the appropriate destination (\camri\mrisrv) in the pull-down menu next to the "Path" label
  5. Add the end of the path, type in a new directory (e.g. \Beauchamp\ExperimentCode )
  6. Click "Yes" when it asks whether to create a new folder
  7. this should copy into a folder called ExperimentCode

Then, to transfer the data to our server using your own Mac or PC. First, connect to the scanner server using the BeauchampLab login. on a Mac:

 Apple-K or Go-Connect To Server                       cifs://mrisrv.bcms.bcm.edu/Beauchamp

on a PC

 Tools-Mount Network Drive            \\mrisrv.bcms.bcm.edu\beauchamp

Then, navigate to the correct directory and copy to an analysis directory on the Beauchamp Lab server. This is usually in the format

/Volumes/data/BCM/XXX

Where "XX" is a unique two or three-letter code that corresponds to the experiment.

Other alternatives: To save to a flash drive: Export to Off-Line, Select flash drive, export

To save to TABS (the Mac next to the console on 3T-5) where it can then be put on DropBox or elsewhere: Send to tabsSCP

 cd /Users/tabs/tabs/dicom

The DCM files will be placed in a directory named with the date and time, e.g.


Here is the old way: After you scan, the technologist will send you an e-mail with the link to the data. If necessary, make a new directory

 mkdir /Volumes/data1/UT/JL
 cd /Volumes/data1/UT/JL
 mkdir raw
 cd raw

And then click on the link and download the data to this directory (called "raw" for ease of reference). The data is stored as an .iso file. Double click on the .iso file to open a window that lists the component data files (with .ima suffix). Click and drag these into the raw directory.

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.

Getting Data From the UT Philips Scanner if you are at UT

The MRI data can be transferred from the scanner in a number of ways; the only fail-safe method is to take a removable USB drive to the scanner room and copy the data directly to it. Alternately, the data can be placed somewhere "in the cloud" by the scanner tech and then moved to the correct place on the server. One place is the UT NAS. Connect to the NAS by hitting Apple-K and then

Login with your UT ID and password. Navigate to the correct directory and copy to the experiment directory. On the scanner, it may be necessary to use the IP address in windows format (Windows Explorer or My Computer, Tools, Map Network Drive):

Another place the data could be placed is in a folder on our server. You must find it and move it to the correct location (experiment directory, "raw" subdirectory). The folder will be named by Vips (ask him for the name if you cannot find it) and is located on the server internal hard disk, as opposed to the RAID connected to the server. GUI Version. Make sure that both the "data" drive (RAID) AND "beauchamplab" (server internal hard disk) are mounted on your Mac. Apple-K to XXXXXXX and select both if they are not. Open one finder window and navigate to ms-nbafmri/beauchamplab and find the folder with your data in it. Move or copy it to the correct experiment directory. Command line version.

Navigate to the correct directory. Then, copy to the correct location on the server as follows. Replace the sample directory name with the desired one; this is the name given by Vips. Be sure you have created the experiment directory, including the raw subdirectory, already.

cp -r ZAP_081612/* /Volumes/Pegasus/data/UT/ZAP/raw/

More Notes

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.

Method 1: Vips doesn't like this because it is too slow. Using a package called ExpanDrive

 https://secure.expandrive.com/

Vips can connect directly to a Mac server with scp (ssh must be enabled on the server). He will copy it to the "BeauchampServer" dirve mounted on the Philips console. This is a link to the ms-nbafmri server located at 139.52.4.123 (For Tim's data, it is copied to data on ike). The next step is to copy it from the ms-nbafmri server to the correct experiment directory. Here are the steps to do that:

For ms-nbafmri ii is copied to the admin home directory (on the server hard disk) and needs to be copied to the correct location (on the Promise RAID).

Use the Amazon/Gmail lab password. Find where the data is located.

 cd DATA
 ls

Then, copy to the correct location on the server as follows. (Replace the sample directory name with the desired one; this is the name given by Vips).

cp -r ZAP_081612 /Volumes/Pegasus/data/UT/

Method 2: Faster for Vips, but involves an extra step for us. Data can be copied to the NAS and then transferred from there to the server. On Windows, mount the NAS with

On Macs, Apple-K and then

For either case, log in with your UT user ID and password.

OLDER: 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 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.


The data should be copied to /data1 for analysis using this command:


If you are not sure what directory to use, you can open a window to bidwell with the following command

 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

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.

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.