Converting Between Special Image Formats

While imconvert is the most general file conversion utility, there are a few cases in which it is either less convenient, or in which it does not preserve enough information:

To convert from: To: Use: Source
Analyze 3D Analyze (4D) Ana3to4d Ana3to4d.c
Signa Genesis bshort gen2bshort gen2bshort.c
Signa Genesis Analyze (4D) Genesis2Analyze Genesis2Analyze.c
DICOM Analyze (4D) dcm2img dcm2img.c
Analyze (4D) Signa Genesis Analyze2Genesis Analyze2Genesis.c
Ana3to4d
Convert a series of Analyze 3D files to a single Analyze 4D file, sharing the same header. This format is very conveient for storage, file transfer and backup. It is read directly by single subject analysis programs such as scanSTAT and CC_gr.
 
Ana3to4d OutputFileBaseName InputFileName(s).img
 
A typical command line might be:
Ana3to4d My4DFile myFile.t*.img
 
This will convert all image names matching the "myFile.t*.img" wildcard to a single output called, My4DFile.img

gen2bshort

Convert a series of Signa Genesis files to a single bshort file, sharing the same header. This format is particularly useful when viewing images using xds. It is read directly by single subject analysis programs such as scanSTAT and CC_gr.
 
gen2bshort OutputFileBaseName InputFileName(s).MR
 
A typical command line might be:
gen2bshort MyBshortFile E2156S3I*.MR
 
This will convert all image names matching the "E2156S3I*.MR" wildcard to a single output called, MyBshortFile.bshort

Genesis2Analyze

Create an Analyze (4D) file from a series of Signa genesis files, preserving all header in a separate .GenesisHeaders file and a series of original input names in a .NAME_FILE. Genesis files are first renumbered with 3 digit image file numbers.
 
This program was created to smoothly move from Genesis to our local image processing tools and back to Genesis for re-insertion into programs that handle Signa Format
 
Genesis2Analyze InputFileName(s).MR
 
A typical command line might be:
Genesis2Analyze E2156S3I*.MR
 
This will convert all image names matching the "E2156S3I*.MR" wildcard to a single output called, E2156S3.img. Note that the output name is generated automatically, based on the input name. In addition, the program will create:
 
E2156S3.NAME_FILE and E2156S3.GenesisHeaders
These latter files can be used to back convert the Analyze4D files to a series of valid Signa Genesis images

dcm2img
Convert a DICOM image, or a mosaick'd DICOM image (e.g., from a Siemens MR scanner) to analyze format.
This progarm is still developmental and anomalies are likely.
A typical command transcript might be (user input in bold):
> dcm2img *.dcm
Are the input files from a pc or a DEC alpha (Little endian)?: y
What is the center to center spacing (thickness+gap) of the slices (mm)?: 5
How many pixels in the x dimension (for each file)?: 320
How many pixels in the y dimension (for each file)?: 320
Is each file a separate time point (y) or a separate slice (n): y
How many slices are in each file?: 25
rows: 5 cols: 5
xs: 64 ys: 64
What tr was used (msec)?: 3000
Save to a single output file?: y
Output file base name: myOutput

Remove originals?: n

>

Analyze2Genesis
This is effectively the inverse operation for Genesis2Analyze, above.
 
Analyze2Genesis -i nFileBaseName.img -n InputNameFile.NAME_FILE
 
A typical command line might be:
Analyze2Genesis -i E2156S3.img -n E2156S3.NAME_FILE
 
The output will be a series of Genesis files with slightly modified names, in the series:
 
Ec2156S3I001.MR Ec2156S3I002.MR Ec2156S3I003.MR Ec2156S3I004.MR ...
 
Note the added 'c' in the file name, for "converted".
 
The most common (intended) use of Analyze2Genesis and Genesis2Analyze is in RF correction. The transcript below shows the process:
 

						Usage: Genesis2Analyze basename*.MR
Renumber all files ending in '*.MR' with 3 digit numbers
Create an analyze 4D file with these contents
Note that you must keep a copy of the NameFile (which ends in .NAME_FILE)
         and the headers file, which ends in: .GenesisHeaders, in order to
        successfully reconstruct the genesis headers using Analyze2Genesis
More (y/n)?: y
This is part of a set of utilities to pre-process signa files for intensity correction,
and to post-process the resulting files to convert them to a valid Signa format.
==============
The tool Genesis2Analyze takes a series of ExxxxSxxxIxxx.MR files and makes them into a single
4-D analyze file. It also saves a record of the original names, and the complete header for each
Typing Genesis2Analyze (my way of providing simple help) gives:
Usage: Genesis2Analyze basename*.MR
Renumber all files ending in '*.MR' with 3 digit numbers
Create an analyze 4D file with these contents
Note that you must keep a copy of the NameFile (which ends in .NAME_FILE)
        and the headers file, which ends in: .GenesisHeaders, in order to
        successfully reconstruct the genesis headers using Analyze2Genesis
===============
Analyze2Genesis does the reverse operation, extracting each slice in an analyze file, and giving
it a name and header from the output derived from Genesis2Analyze.
Typing Analyze2Genesis gives:
Usage:
Analyze2Genesis -i AnalyzeInputFile -n NameFile
        Analyze2Genesis will convert a (4D) analyze file to a series of genesis
        files having names corresponding to the contents of the NameFile
Note that you must keep a copy of the NameFile (which ends in .NAME_FILE)
         and the headers file, which ends in: .GenesisHeaders, in order to
        successfully reconstruct the genesis headers using Analyze2Genesis
        The user is responsible for ensuring that the name file has a separate
        entry for each slice location in the analyze file
================
A complete session transcript follows for RF correction. Note that the warning messages for mv
and differing byte order are expected.
 Genesis2Analyze E*.MR
Renaming files
mv: E2123S2I124.MR and E2123S2I124.MR are identical.
... etc ...
mv: E2123S2I100.MR and E2123S2I100.MR are identical.
WARNING: Computer and data differ in byte order
        Patience for a moment
Created Analyze (4D) file: E2123S2.img
        Save these files!: E2123S2.NAME_FILE and E2123S2.GenesisHdrs
To create corresponding genesis images from an analyze file named XXX.img, use:
        Analyze2Genesis -n E2123S2.NAME_FILE -i XXX.img
All done
--------------------
> EQ -i E2123S2.img -o eqTst
EQ
        $Revision: 1.5 $$Date: 2002/04/09 00:49:20 $
Working
Done. Thank you for using EQ.
mscohen@ucla.edu -- http://www.brainmapping.org
--------------------
 Analyze2Genesis -n E2123S2.NAME_FILE -i eqTst.img
Using E2123S2.GenesisHdrs for genesis headers
......................................................................
> ls Ec*
Ec2123S2I001.MR   Ec2123S2I026.MR   Ec2123S2I051.MR   Ec2123S2I076.MR Ec2123S2I101.MR
 ... etc ...
Ec2123S2I025.MR   Ec2123S2I050.MR   Ec2123S2I075.MR   Ec2123S2I100.MR

Back to HowTo pages
This page is maintained by Mark Cohen [updated 3.6.03]