Converting Philips (UBC 3T) data to Analyze (SPM) format using MRIcro

GENERAL INFORMATION

The raw data consists of pairs of files, ending on .PAR and .REC. The scanner produces one pair of files for each scanning session (i.e., one uninterrupted period of scanning, typically 10-15 minutes long).

For a typical experiment you would have between 4 and 10 pairs of .PAR and .REC files, depending on how long your experiment was, and how many extra acquisitions you did (extra acquisitions would include structural image, phase maps, etc).

During scanning, you should have listed in the scanner log book the order of acquisitions, that will now help you determine which file containts the structural image, and which file contains the functional data. You can also double check the type of acquisition, by examining the information in each .PAR file.

In each pair, the .PAR file is a text file, containing the parameters for this session, including information on whether this was a structural or functional sequence. The corresponding .REC file contains the actual data, either BOLD or structural data, or numbers saved in bynary format. You can not directly view or read the .REC file, but you can open it and view it using MRIcro, a software program available on our computers. MRIcro is also necessary in order to convert the raw data into Analyze format data, so that preprocessing and analysis can be performed in SPM.

Each pair of .PAR and .REC files contains a 4D dataset, or a time-series of 3D brain images. The 4th time dimension corresponds to the duration of your scanning session, and the number of pairs of files will correspond to the number of dynamics you collected (or the total duration in seconds divided by the TR in seconds). For example, for a 4 minute scanning session, using 2 second TR, there will be 120 dynamics or brain images.

All these brain images are contained within a single pair of .PAR and .REC files. Analyaze format, however, separates this 4D data into discreet 3D brain images. Thus, in the above example, a single 4D PAR&REC pair will be converted into 120 3D Analyze format pairs of images. MRIcro can read both Philips format images (PAR & REC) and Analyze format images (.img & .hdr).

The .PAR & .REC endings are the convetion for images in Philips format. (The 3T scanner at UBC is a Philips). Analyze format uses different convention for endings: .img & .hdr, with the .img file roughly corresponding to the .REC files (both are binary images and contain voxel values) and the .hdr file roughly corresponding to the the .PAR file (both files contain parameter information, although only the .PAR file is an easily readable text format). The .img ending stands for “image”, and the .hdr ending stands for “header”. During the conversion the binary .REC files are being converted into binary .img files, using parameter information saved in the .PAR files that is then covnerted into parameter information saved in the .hdr files.

1. DETERMINING THE ORDER OF ACQUISITIONS (FUNCTIONAL, STRUCTURAL, ETC)

If you are not sure about which .REC files corresponds to your functional, structural, etc, sequence, you will need to determine it by examining the text in the corresopnding .PAR files. To do this, type more <name of each .PAR file> at the prompt, e.g.:

more OCT0505_CLUSTEREDAQUSITION_3_1.PAR

This would display some text information, amongst which the following would be relevant:

“. Technique : TIR”

“. Protocol name : T1W/IR AXIAL”

(indicating that a T1 IR axial structural scan was acquired

(of these two “Technique” is the more reliable indicator”)

“. Scan Duration [sec] : 234″

(the session lasted 234 seconds, always good to double check)

Note down somewhere that the file ending on “_3_1.REC” contains your structural for this subject.

The .PAR files are quite long, and the most relevant information is at the very top of the file. Once you’ve typed “more” to view them, however, the computer will by default want to display the remainder of the file, which you can view, if you want, by clicking repeatedly on the SPACE bar, or to save time, you could just press the “q” button to quit out of viewing that file and return to the prompt.

Then, view the next file by typing:

more <name of next .PAR file>, e.g.:

more OCT0505_CLUSTEREDAQUSITION_5_1.PAR

You may see the following lines that would be relevant:

“. Technique : FEEPI”
“. Protocol name : ANAGRAM 370 SENSE”

(Indicating that this was an EPI functional sequence, using the sense acuiqision, which is standard for functional sequences on the Philips scanner. EPI functional sequences are collected while the subject is performing the task.)]

Again, you should double check that the duration is what you collected:

“. Scan Duration [sec] : 246″
(the session lasted 246 seconds)

Again, note down that this is the first functional session for your experiment. To double check which was first, second, and so forth, the following line is useful:

“. Examination date/time : 2005.10.05 / 10:17:01″

containing information about the exame time when the session was started.

III. CREATE A DIRECTORY STRUCTURE FOR THE NEW FILES TO BE PRODUCED

Because in the next step, you will produce multiple new files (anything between 500 and 5000 new files), it is extremely important to create a number of subdirectories in which the new files will be stored, according to what they belong to.

Go to the Terminal prompt, and

1. Create a directory for the raw data:

mkdir raw_data

2. Now, move all the .PAR and .REC files in the raw_data directory:

mv *.PAR *.REC raw_data

3. Create one directory for each of your sessions of functional acquisition, one directory for your phase maps, etc:

mkdir sess1
mkdir sess2
mkdir sess3
….

mkdir phase_maps

If the different sessions came from different tasks or were collected for testing purposes, you might want to include some additional information in the names, e.g.:

mkdir sess1_TR2000_clustered
mkdir sess2_TR1000_regular
mkdir sess3_TR2000_regular

Create any other directories you might need, e.g., a “misc” directory for various files:

mkdir misc

Now you are ready to begin conversion to 3D analyze.

IV. CONVERTING PHILIPS IMAGES TO ANALYZE FORMAT IMAGES

1. Start MRIcro by typing:

startmricro

at the prompt. Then select “Import” from the menu, and then the “Convert Philips PAR to Analyze…” option.

2. Use the interface to go into the root directory on Jekyll by clicking the blue upward arrow as many times as it will take for the “Look in:” box to display only the “/” sign. Now select the directory where you placed your raw data, by clicking on the corresponding subdirectories, e.g.:

double-click “clabdata”
double-click “kamyar”
double-click “anagrams”
double-click “Oct05_05_anagramcluster_test”
double-click “raw_data”

You should eventually be able to see the names of the .PAR files you transfered. Select the first functional image of your acquisition. In our example, this was the file named “OCT0505_CLUSTEREDAQUSITION_5_1.PAR”. You select the file by clicking on it to highlight it, and then cliking on the “Open” button.

Although nothing will be displayed in MRIcro, a new pair of .img and .hdr files has been generated. These are a 4D Analyze format image pair, which needs to be converted into a time series of 3D analyze format image pairs.

3. To open the newly generated 4D analyze format image, select “File” from the menu in MRIcro, and the choose the “Open Analyze format hdr+img…” option. Select the newly generated .hdr file, in our example “OCT0505_CLUSTEREDAQUSITION_5_1.hdr” and click on the “Open” button.

4. If you are opening a functional acquisition session, a box will show titled “Processing data” saying that “Multi-volume file” has been selected. Click the “OK” button.

5. This is an image, which you can view by moving up and down the slices using the slider bar in the left middle section of the MRIcro interface. Other information is also displayed, and is good to double check, such as the number of slices, the acquisition diemsions, and others. You can also enlarge the image by clicking on the “x1″ box, to switch it to “x4″ or something similar.

6. To convert the 4D analyze format image into a 3D time series of files, select “File” from the menu, and then choose the “Save as… [rotate/clip/format/4D->3D]” option.

NB: BEFORE YOU SAVE EACH FILE AS 3D time series, it is EXTREMELY IMPORTANT to select the “Flip Left/Right” option on the little box that will appear at this point. Once you click on the button for this option, it will visually become darker, and that indicates that the images will be flipped before saving. Each fMRI scanner saves images in “radiological convention”, which means that the right side of the brain is saved on the left side of the image and vice versa. In neuroimaging, however, and in SPM, we use the “neurological convention”, which means that the right side of the brain is on the right side of the image. This step is crucially important, because if the orientation of images is inconsistent across subjects, group analysis and any scientific conclusions would be meaningless.

7. After selecting the “Flip Left/Right” option, click on “Save [Intel] button.

8. When asked about segmenting the file into multiple 3D volumes, click the “Segment Padded [File001,File002]” option. This will ensure that even multiple files (in the hundreds) are sorted appropriately.

9. Using the upwards arrow, locate the first of your session directories, e.g. “sess1″, and double-click to go in it from the interface. Finding the right directory is EXTREMELY important. If you save the file from session 2 in “sess1″, your task design will no longer be valid, and the results will be meaningless.

10. Change the name of the file in the “File Name:” so that it says “x.hdr” (simply delete all text prior to it). Double check that you are saving files in the right session directory and then click the “Save” button. The conversion might take a few seconds, depending on how long the scanning session was.

11. Go back to the Terminal prompt, and type “ls sess1″ to view the newly generated files. There should be as many pairs of .img + .hdr files as there were dynamics during the scanning session.

12. Now, go back to step 1 in this section and repeate the same for session 2, session 3, etc. Also, use the same steps for converting your structural scan, but name it “x_structural.hdr” when saving. (Some of the prompts might not occur while converting the structural image).

NB: The “x” in front of the file name indicates that the image was flipped right-to-left. Keep that “x” in the file names, including the structural image.