ncigt-fil
Functions
DICOM File Utilities

Functions

void edit_dicom (LIST_NODE *list, short tag0, short tag1, char *filename, char *im_hdr, int *hdrsize_ptr, void *newvalue, short newvalue_length)
 
void eval_dicom (LIST_NODE *list, short tag0, short tag1, char *filename, char *value, char *value_type, short max_length)
 
LIST_NODE find_tag (LIST_NODE *list, short tag0, short tag1)
 
void get_dicom_info (char *filename, LIST_NODE *list, short Nmax)
 
int is_dicom (char *filename)
 
void print_list (LIST_NODE *list, char *filename)
 
short write_ima (SCAN_INFO hdr, short flip_h, short flip_v, short rot_90, char **imfile, int imnum, int z_anat, COMPLEX *buf, COMPLEX *result, char *path_out)
 

Detailed Description

A set of functions to read/edit/write DICOM headers and files.

The model followed by these functions is the following:

Testing has been done with DICOM files generated by GE scanners.

Function Documentation

void edit_dicom ( LIST_NODE *  list,
short  tag0,
short  tag1,
char *  filename,
char *  im_hdr,
int *  hdrsize_ptr,
void *  newvalue,
short  newvalue_length 
)

Change the value of one entry, in a DICOM header.

Parameters
listList of DICOM entries.
tag0Specific tag. first 16 bits of the tag,
tag1the second set of 16 bits of the tag.
filenameName of DICOM file, where im_hdr comes from.
im_hdrDICOM header, stored in a char array.
hdrsize_ptrThe size of the DICOM header. If editing the header changes the size, the new size is returned.
newvalueNew value to be inserted in header.
newvalue_lengthLength in bytes of newvalue. Unless this is a char string, this info tends to be redundant with newvalue_type.
void eval_dicom ( LIST_NODE *  list,
short  tag0,
short  tag1,
char *  filename,
char *  value,
char *  value_type,
short  max_length 
)

Find the value of one particular DICOM entry.

Parameters
listList of DICOM entries.
tag0A Specific tag. tag0 contains the first 16 bits
tag1tag1 contains the 2nd set of 16 bits
filenameName of DICOM file.
valuePointer to where the value should be written.
value_typeString giving the variable type expected (char, float, double, long. ulong, short, ushort)
max_lengthMaximum length, in bytes, to be written out (i.e., size allocated at the address 'value'.
LIST_NODE find_tag ( LIST_NODE *  list,
short  tag0,
short  tag1 
)

In a list of DICOM entries, finds a given tag, and return the associated entry. The returned entry contains the info on where (offset), how (VR) and how much (length) should be read, to get the value associated with the tag.

Returns
DICOM entry relating to this tag, extracted from the list of all entries.
Parameters
listList of DICOM entries.
tag0Specific tag. tag0 contains the first 16 bits,
tag1tag1 the second set of 16 bits.
void get_dicom_info ( char *  filename,
LIST_NODE *  list,
short  Nmax 
)

Takes a DICOM file, and extracts all the tags. Each entry includes the tag number, the VR accociated with the tag, the length of the value field, and the offset in bytes from the beginning of the file to the value field.

Parameters
filenameName of DICOM file.
listList of tag entries extracted from file.
Nmaxmaximum number of entries to be considered (proportional to the amount of memory allocated for the list).
int is_dicom ( char *  filename)

Returns 1 if the file is a DICOM file and 0 otherwise.

Parameters
filenameName of DICOM file
void print_list ( LIST_NODE *  list,
char *  filename 
)

Print out a list of all DICOM tags in a file, along with VR values, offset values, the length of the value field and the actual value. The 'list' was first built using get_dicom_info().

Parameters
listList of DICOM entries.
filenameName of DICOM file.
short write_ima ( SCAN_INFO  hdr,
short  flip_h,
short  flip_v,
short  rot_90,
char **  imfile,
int  imnum,
int  z_anat,
COMPLEX *  buf,
COMPLEX *  result,
char *  path_out 
)

Finish cropping, rotating, flipping, shifting the result, and write it out as a dicom file.

Parameters
hdrheader information, associated with *buf
flip_hFlag to flip horizontally.
flip_vFlag to flip vertically.
rot_90Flag to rotate +90 (=+1) or -90 (=-1) degrees.
imfileinput DICOM file, for header information
imnumNumber of the slice being written out (between 1 and Nz).
z_anatCurrent z loc, anatomical ordering
bufinput data
resultReconstructed image data
path_outDirectory where to write result.