I wrote a bit of bash shell script which uses the FSL package to convert the PAR-REC output from a Philips scanner to NIFTI format. All images are output in axial format.
As well as the output images XXXX.nii.gz, it generates two matrix files XXXX_to0.omat and XXXX_to0_inv.omat The first one reverses the rotation on the image, and shifts its origin to 0,0,0 (ie the angulation and translation relative to the scanner coordinate system) The second one is the inverse. Hence if you want to rotate image A to image B you'd use fsl's convert_xfm command: convert_xfm -omat A_to_B.omat -concat B_to0_inv.omat A_to0.omat and then use flirt to reslice flirt -in A -ref B -applyxfm -init A_to_b.omat -o A_to_B
Alternatively there a -q option which saves the nifti file with the matrix in it (as qform/sform) matrix, so when loaded into SPM, the images should all have the same orientation.
There's an '-f' option, which multiplies the REC pixel values by the scaling factor (and generates a floating point image). Without this option it completely ignores the scaling factors (though it does check to see if they're all the same for each slice). As yet it doesn't do what MRIcro does of storing the scaling info in the nifti file. Note the scaling is somewhat different to MRIcro. It calculates what Philips call in the PAR file the 'floating point value' whereas mricro does (I think) the 'displayed value'. If you have phase images that you want to turn into radians, or other quantitive analysis, you want the -f option. Not necessary for diffusion images, since they (seem) all to have the same scaling.
-Q option specifies a rotation matrix (with no angulation) saying that data is in radiological format. useful if you want to look at data in mricron, since otherwise it flips it LR
For diffusion images, if your first 3 diffusion vectors are orthogonal, the parrec file will contain an additional image which is the average of all the diffusion weighted images. The script ignores this additional image. For diffusion images, it outputs two text files with the diffusion gradients and bvalues.
If it encounters an image type it hasn't met before, it should complain and then exit.
This script seems to work for me. It is not guaranteed to work for you at all.
Click here to download.
Copyright 2009 Michael Firbank under Gnu General Public license
April 2009 v1.9.1 -Q option which saves a matrix in header with no angulation, but saying data in radiological
June 2009 v1.10 does PAR format 4.2 (not fully tested yet, as we only just got this format, but looks very similar to v4.1)
Oct 2010 v1.12 now copes when the slices have been output in a silly order to the REC file
This page has been viewed
times.