ptoa - Philips PAR/XML/REC to Analyze

blue bar

Command line program to convert Philips PAR/REC format (versions 3 or 4) or Philips XML/REC to Analyze v7 of NIFTI-1 format.

ptoa [-q] [-d] [-dv] [-f] [-v] [-ana | -nif | -nii ] [-gz] [-i] [-diff [-fdt]] [-spos] [-mp2] Philips_PAR_XML_REC_filename1 [Philips_PAR_XML_REC_filename2 ...]
-q
Supresses text output of conversion progress.
-d
Displays additional diagnostic output.
-dv
By default, the scale and offset factors stored in the converted Analyze header file is the 'floating point' value which relates best to the actual signal intensity. The PAR file also describes a display value. If the scale and offset factors to obtain the display value are required instead of those to obtain the floating point value, then the -dv flag should be used.
-s1
Ignores the scale and offset values in the PAR file and sets a scale value of 1 with 0 offset.
-cal
By default, the cal_min and cal_max fields of the Analyze or NIFTI header are both set to zero. However, some software requires that these be set. This flag populates the cal_min and cal_max fields of the header with suitable values (Analyze format: The unscaled minimum and maximum pixel intensities. NIFTI format: The scaled minimum and maximum pixel intensity values).
-f
By default the scale and offset factors are stored in the Analyze header and the pixel intensities saved in the converted Analyze image files are those from the Philips REC file. If the -f flag is specified then the scale and offset factors are applied to the pixel intensities during conversion and a float Analyze file is written which requires no further intensity scaling.
-v
Displays the date and time that ptoa was compiled, and exits.
-ana
Converts to Analyze format, which is the default (although see the -gz option, below).
-nif
Converts to NIFTI-1 format, with separate .hdr and .img files. Slice orientation information is included in the qform, thanks to Julien Besle & Denis Schluppeck, although this has not been extensively tested for subject orientations other than head-first, supine.
-nii
Converts to NIFTI-1 format, with a single .nii file. Slice orientation information is included in the qform, thanks to Julien Besle & Denis Schluppeck, although this has not been extensively tested for subject orientations other than head-first, supine.
-gz
Writes compressed NIFTI-1 format. If none of the above three flags defining the output image format are specified, then defaults to writing NIFTI-1 format with separate .hdr and .img files.
-i
Not all the information required in the NIFTI-1 header is containing in the PAR file, for example the slice timing information within a volume required to determine sparse acquisitions or interleaved slice ordering. By default, ptoa does not populate these fields in the NIFTI header. However, this appears to cause issues with certain other software packages. By specifying this flag, values for the slice_end, slice_code, and slice_duration fields are inferred, but may not be correct.
-diff
If the PAR file describes a diffusion acquisition and the diffusion gradient directions are present (PAR version 4.1 or above, or XML) then write additional files containing the diffusion b values and directions in the slice coordinate frame, suitable for FSL.
-fdt
If a diffusion acquisition is detected then after all file conversion has finished, perform basic post-processing using FSL's diffusion toolbox to perform eddy current correction, calculate the diffusion tensor, produce maps of Mean Diffusivity, Fractional Anisotropy, and an isotropic diffusion weighted image. This options requires that FSL is installed correctly and that the detected diffusion acquisition contained at least six diffusion directions. The processing is set running in the background and may take some time; no confirmation is given when processing is complete (other than appearence of the relevant image files) and this must be taken into consideration when rebooting the computer, especially if using Cygwin. Under UNIX or GNU/Linux, the background jobs are batched to run one after another which should prevent the system running too slowly, however, this feature is not available under Cygwin so be aware that using this option while converting PAR/REC images with more than one diffusion acquisition at any one time will slow down the computer significantly.
-fnomask
By default, the -fdt option, above, calls FSL's bet to create a brain mask. This may not be the appropriate choice for all data. Specifying this option disables creation of a brain mask.
-fnoeddy
By default, the -fdt option, above, calls FSL's eddy_correct script. To skip this step, specify this command line flag.
-spos
Writes an additional text file containing slice positions for each slice in an Analyze file. The program then tries to determine whether the PAR/REC file may contain a multistack acquisition and then examines the slice positions to determine whether the volume may contain overlapping stacks (with an integer number of overlapping slices). If so, then also write another text file containing command like options for mergestacks although mergestacks is not run automatically.
This option works for multistack anatomicals tyle acquisitions, however it may not work in a general case involving multivolume, multiecho, etc., acquisitions, so interpret the results carefully.
Philips_PAR_XML_REC_filename
The filename(s) of the PAR, XML, or REC files to be converted. Filenames may contain either the .par, .xml, or .rec extension, in upper or lower case, or just the base filename, in which case ptoa tries to find the PAR/REC or XML/REC filename pairs. ptoa may fail to find both XML & REC filename pairs if the file extensions have different case, e.g., .XML and .rec, in which case rename the filenames so both filename extensions have the same case and run ptoa again. If both PAR and XML files exist, ptoa uses the PAR file.
-mp2
If the PAR/XML/REC file contains what appears to be appropriate data to perform the MP2RAGE calculation, then attempt also to calculate a MP2RAGE image set.

ptoa converts Philips PAR/XML/REC files to Analyze format. The PAR or XML file is a text header describing the binary images stored in the REC file. As described in the PAR text file, the Philips format incorporates intensity scaling and offset factors to be applied to the actual pixel values stored in the REC file. ptoa copies the pixel values stored in the REC file to those stored in the Analyze .img file. The scaling and offset factors are stored in the Analyze .hdr file in dime.funused1 and dime.funused2 respectively. The scaling factor is multiplicative on the pixel value, after which the additive offset value should be applied.

The PAR/XML/REC format allows a number of different images to be combined in one file. For examples, images in a single REC file may have different intensity scaling factors, slice thicknesses, or bits-per-pixel. This variability is not allowed in a single Analyze file. As such, when the possibility of the conversion not being represented in a single Analyze file occurs, the output is split into multiple Analyze files. Currently, this occurs when a change in scale or offset factors is encountered. Also, images with different echo, cardiac phase, image type (i.e., real, imaginary, phase), or image sequences (e.g., labelled or non-labelled, flow, T1, or T2 maps), are stored in seperate Analyze files. A bug may result in the number of slices in an Analyze file converted from composite PAR/REC files being over-estimated in the .hdr file. Multi-slice dynamic scans should be stored correctly in a single Analyze file.

Images in the REC file may be stored in an ordered or non-ordered format depending on whether the Sort Images option was selected during image export from the scanner. Also, diffusion weighted images with diffusion gradients applied in multiple directions are stored as multiple dynamic acquisitions with the initial number of dynamic scans not present (equal to the number of diffusion directions). ptoa should deal with all these cases correctly. Note that the z voxel size stored in the Analyze header is the slice thickness rather than the slice seperation.

While the feature to convert XML/REC files has been implemented as fully as possible, it has been tested far less that for PAR/REC files. As such, XML/REC conversion may fail, especially in untested cases such as a partial acquisition, e.g., a fMRI acquisition aborted before the end. If this occurs, please email me and pass on both the XML/REC and PAR/REC files and I will investigate.