|
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) |
|
A set of functions to read/edit/write DICOM headers and files.
The model followed by these functions is the following:
-
The DICOM header information is read for a file
-
The header is parsed to construct a dictionary (the 'list')
-
For requests for tag values, the tag location is determined from the list, and the value is determined from the file itself.
-
The edit tag function should be used primarily for changing the value of an existing tag, e.g. to change the image number.
-
Writing a new DICOM file consists of writing the header information, followed by the image data itself.
Testing has been done with DICOM files generated by GE scanners.
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
-
list | List of DICOM entries. |
tag0 | Specific tag. first 16 bits of the tag, |
tag1 | the second set of 16 bits of the tag. |
filename | Name of DICOM file, where im_hdr comes from. |
im_hdr | DICOM header, stored in a char array. |
hdrsize_ptr | The size of the DICOM header. If editing the header changes the size, the new size is returned. |
newvalue | New value to be inserted in header. |
newvalue_length | Length 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
-
list | List of DICOM entries. |
tag0 | A Specific tag. tag0 contains the first 16 bits |
tag1 | tag1 contains the 2nd set of 16 bits |
filename | Name of DICOM file. |
value | Pointer to where the value should be written. |
value_type | String giving the variable type expected (char, float, double, long. ulong, short, ushort) |
max_length | Maximum 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
-
list | List of DICOM entries. |
tag0 | Specific tag. tag0 contains the first 16 bits, |
tag1 | tag1 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
-
filename | Name of DICOM file. |
list | List of tag entries extracted from file. |
Nmax | maximum 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
-
filename | Name 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
-
list | List of DICOM entries. |
filename | Name 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
-
hdr | header information, associated with *buf |
flip_h | Flag to flip horizontally. |
flip_v | Flag to flip vertically. |
rot_90 | Flag to rotate +90 (=+1) or -90 (=-1) degrees. |
imfile | input DICOM file, for header information |
imnum | Number of the slice being written out (between 1 and Nz). |
z_anat | Current z loc, anatomical ordering |
buf | input data |
result | Reconstructed image data |
path_out | Directory where to write result. |