Computing Resources

REC file Utilities

Johns Hopkins, MR Research and 

Kennedy Krieger Institute, F.M. Kirby Research Center

Table of Contents

Local file conversion tools


Local file conversion tools

rec2dcm Philips PAR/REC file to standard DICOM converter
rec_convert Philips PAR/REC file to Analyze format converter
readrec_V4 Matlab script to read PAR/REC files
   

rec2dcm - Convert Philips PAR/REC file into standard DICOM format

Usage: rec2dcm.pl

This script requires that there be a DICOM scan with the same geometry as the PAR/REC scan. Preferably the DICOM scan should have all imaging parameters exactly the same as the PAR/REC since the headers from this scan will be stripped off and attached to the image files from the REC file. The script will prompt for new values for various scan and patient information fields like the study date and time and patient name but no imaging parameters are modified. New UIDs are generated for the new DICOM files: all get the same Study Instance and Series Instance UID but unique Image Instance UID.

The script checks that the slice, echo, phase and dynamic number of DICOM headers matches these values in the PAR file for each image extracted. For Philips DICOM images that have Philips private fields, it also checks the b-value and b-direction indexes for diffusion scans and the label indexes for ASL scans. For ASL only 2 labels, CONTROL and LABEL are supported. Note that private fields may be removed if images were stored to and then retrieved from a PACS.

To Use: Create a new empty directory, copy the PAR and REC files into it and copy a directory named MR to it that contains the files of the DICOM scan with matching geometry. Make sure the MR folder has ONLY the DICOM files that match the PAR/REC scan. The script creates a directory named output containing the new DICOM files with modified headers and REC file data.

Requires dcmdump and dcmodify from the OFFIS DCMtk toolkit.

This script should not be used for clinical scans.

PERL Script: Any Platform

rec_convert - Convert Philips PAR/REC file into Analyze formats

Usage:  rec_convert [-o <output root>] [-n] [-3] [-q] [-d] [-s] <input-recfile>

<input-recfile>  is the Philips REC file to convert into Anaylze format. These files are trasnsferred from the scanner to your directory with names of the form <iden>_<n>_1.rec where <iden> is an identifying name selected when the data is exported into REC file form and <n> is the acquistion number. The final 1 indicates it is the first reconstruction - post-processing can increment this number.
<output root>  is an optional output filename root. If not given, the root of the input file is used. It can include a path if you want the output files in a different directory than the input REC file. The output root for 4D Analyze format has .img appended for the image data file and .hdr appended for the Analyze header file. For 3D Analyze files, the volume number is appended ahead of the .img or .hdr suffix.
-n do not swap bytes. By default byte swapping is performed to make files that are SunOS or Macintosh compatible. Do not swap bytes for use on IBM PC compatibles (all Windows variants) or DEC systems.
-3 output 3D Analyze files rather than 4D.
-q Run quietly.
-s Make a subdirectory for output files named using root of the input file.
-d Delete REC file after conversion.

The Philips REC data input file's name can have any form but must end with ".REC" or ".rec". There must be a parameter file with root name matching the rec file and ending in ".PAR" or ".par". The PAR file is used for header info and data ordering so no DICOM file is needed as for version 1.x. Since it reads the PAR file ordering information the REC file does not need to be sorted.

It can convert rec files containing magnitude, real, imaginary and/or phase data. Output file name has Philips "type" code appened when not magnitude. (_1 real, _2 imaginary, _3 phase).

Examples:


/g1/jgillen> rec_convert 20070418bsa18_6_1.rec
JHU REC File Conversion Utility v2.3.3 (samfs)
Header Info:
date: 2007.04.18  time: 18:25:25  name: bsa18
iden: none
orig: FM Kirby Research Center
desc: 
nrows: 512  ncols: 512  bits: 16
xspc: 0.449000  yspc: 0.449000  slthk: 5.000000  slspc: 0.000000
FOVap: 230.000000  FOVfh: 5.000000   FOVrh: 186.875000
echos: 1  phases: 1  dynamics: 34  slices: 1   plane: 0  TR: 6000.000000
echo phase dynamic
  1     1     34
done
/g1/jgillen>

The input file is acquistion 6 of a study identified as 20070418bsa18. The output files have the same root as the input and are in the same directory since no output root was given. All 34 dynamics for all slices are in the .img file.

/g1/jgillen> rec_convert -s -3 rl10_7_1.rec
JHU REC File Conversion Utility v2.3.3 (samfs)
Header Info:
date: 2006.04.20  time: 14:57:15  name: xxxxxx xxxxxx
iden: #-#/g2/xxxxx/Emergent2
orig: FM Kirby Research Center
desc: 
nrows: 128  ncols: 128  bits: 16
xspc: 1.875000  yspc: 1.875000  slthk: 3.000000  slspc: 0.000000
FOVap: 216.000000  FOVfh: 150.000000   FOVrh: 240.000000
echos: 1  phases: 1  dynamics: 239  slices: 50   plane: 0  TR: 3000.000000
echo phase dynamic
  1     1    239
done
/g1/jgillen> ls rl10_7_1
rl10_7_1.001.hdr  rl10_7_1.061.hdr  rl10_7_1.121.hdr  rl10_7_1.181.hdr
rl10_7_1.001.img  rl10_7_1.061.img  rl10_7_1.121.img  rl10_7_1.181.img
rl10_7_1.002.hdr  rl10_7_1.062.hdr  rl10_7_1.122.hdr  rl10_7_1.182.hdr
rl10_7_1.002.img  rl10_7_1.062.img  rl10_7_1.122.img  rl10_7_1.182.img
rl10_7_1.003.hdr  rl10_7_1.063.hdr  rl10_7_1.123.hdr  rl10_7_1.183.hdr
.
.
.
rl10_7_1.058.hdr  rl10_7_1.118.hdr  rl10_7_1.178.hdr  rl10_7_1.238.hdr
rl10_7_1.058.img  rl10_7_1.118.img  rl10_7_1.178.img  rl10_7_1.238.img
rl10_7_1.059.hdr  rl10_7_1.119.hdr  rl10_7_1.179.hdr  rl10_7_1.239.hdr
rl10_7_1.059.img  rl10_7_1.119.img  rl10_7_1.179.img  rl10_7_1.239.img
rl10_7_1.060.hdr  rl10_7_1.120.hdr  rl10_7_1.180.hdr
rl10_7_1.060.img  rl10_7_1.120.img  rl10_7_1.180.img
/g1/jgillen> 

Output is to a directory named rl10_7_1. 3D files are selected so the is a header and image file for each of the 239 dynamics containing 1 volume (time point).
Binary: Solaris2
Source: Builds on Solaris, MacOSX, Centos6, Lubuntu

readrec_V4.2 - Matlab script to read in PAR/REC files

Usage: [data, header] = readrec_V4.2 (filename [, 'quiet'][, 'par'])

This script will read in a Philips PAR/REC file. It reads in REC files with multiple data types (magnitude, phase, real and/or imaginary), and does the appropriate signal intensity scaling using the rescale slope and intercept and scale slope.The script supports PAR file versions 3, 4, 4.1, 4.2 and Corbadumper. If the REC file is gziped, it will be gunzipped into a temporary file to be read.

The variable "data" will contain the image data read from the REC file. Returned with all possible dimensions for the PAR file version. Any singleton dimensions can be eliminated using squeeze.

The variable "header" will be returned with a structure containing all parameters from the PAR file. Some header fields:


MATLAB script: Any platform

Supported by NIH Grant P41 EB015909
© 2015 Kennedy Krieger Institute. Baltimore, Maryland.
All rights reserved.
Contact by email