|
TPCCLIB
|
IO functions for DICOM files. More...
#include "libtpcimgio.h"Go to the source code of this file.
Functions | |
| int | dcmVerifyMagic (const char *filename, FILE *fp) |
| unsigned char | dcmVRReserved (dcmvr id) |
| dcmvr | dcmVRId (const char *s) |
| char * | dcmVRName (dcmvr id) |
| size_t | dcmVRVLength (dcmvr id) |
| char * | dcmVRDescr (dcmvr id) |
| char * | dcmDA2intl (const char *orig, char *intl) |
| char * | dcmTM2intl (const char *orig, char *intl) |
| char * | dcmDT2intl (const char *orig, char *intl) |
| unsigned int | dcmSOPIdentify (const char *s) |
| char * | dcmSOPName (unsigned int i) |
| char * | dcmSOPUID (unsigned int i) |
| char * | dcmSOPUIDName (const char *s) |
| dcmtruid | dcmTrUID (const char *s) |
| char * | dcmTrUIDDescr (dcmtruid id) |
| char * | dcmTrUIDString (dcmtruid id) |
| dcmtruid | dcmReadTransferSyntaxUID (FILE *fp) |
| int | dcmReadFileTag (FILE *fp, DCMTAG *tag) |
| int | dcmWriteFileTag (FILE *fp, DCMTAG *tag) |
| int | dcmWriteFileSQDelimItem (FILE *fp) |
| int | dcmWriteFileSQItemDelimTag (FILE *fp) |
| dcmvr | dcmReadFileVR (FILE *fp, char *vrstr) |
| unsigned int | dcmReadFileVL (FILE *fp, unsigned int n) |
| int | dcmReadFileVRVL (FILE *fp, dcmvr *vr, unsigned int *vl, unsigned int *n) |
| int | dcmWriteFileVRVL (FILE *fp, dcmvr vr, unsigned int vl, unsigned int *n) |
| void | dcmfileInit (DCMFILE *d) |
| void | dcmitemFree (DCMITEM *d) |
| void | dcmfileFree (DCMFILE *d) |
| unsigned short int | dcmitemMaxDepth (DCMITEM *d) |
| unsigned short int | dcmfileMaxDepth (DCMFILE *df) |
| unsigned short int | dcmitemParentNr (DCMITEM *d) |
| char * | dcmValueString (DCMITEM *d) |
| long int | dcmitemGetInt (DCMITEM *d) |
| double | dcmitemGetReal (DCMITEM *d) |
| DCMITEM * | dcmFindTag (DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose) |
| void | dcmitemPrint (DCMITEM *d) |
| void | dcmTagSet (DCMTAG *tag, unsigned short int group, unsigned short int element) |
| int | dcmAddItem (DCMFILE *dcm, DCMITEM *d, short int aschild, DCMTAG tag, dcmvr vr, unsigned int vl, char *rd, const int verbose) |
| int | dcmFileReadNextElement (DCMFILE *dcm, DCMITEM *prev_item, DCMITEM *parent_item, const short int sub, const short int headerOnly, int verbose) |
| int | dcmFileRead (const char *filename, DCMFILE *dcm, const short int headerOnly, int verbose) |
| int | dcmFileWrite (const char *filename, DCMFILE *dcm, int verbose) |
IO functions for DICOM files.
Definition in file dcm.c.
| int dcmAddItem | ( | DCMFILE * | dcm, |
| DCMITEM * | d, | ||
| short int | aschild, | ||
| DCMTAG | tag, | ||
| dcmvr | vr, | ||
| unsigned int | vl, | ||
| char * | rd, | ||
| const int | verbose ) |
Add an item to DCMFILE data struct.
| dcm | Pointer to DCMFILE. |
| d | Pointer to a previous item in DCMFILE, into which to link this item; enter NULL to add as next item to the highest level. |
| aschild | Add as child; 1=yes, 0=no. |
| tag | Tag |
| vr | VR |
| vl | VL; enter 0xFFFFFFFF to use VR's default length. |
| rd | Pointer to the item value as byte array |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 1239 of file dcm.c.
| char * dcmDA2intl | ( | const char * | orig, |
| char * | intl ) |
Convert DICOM date 'DA' to international format YYYY-MM-DD.
| orig | Pointer to original DICOM string. |
| intl | Pointer to string where date in international format will be written; must be allocated for at least 11 characters. |
Definition at line 299 of file dcm.c.
| char * dcmDT2intl | ( | const char * | orig, |
| char * | intl ) |
Convert DICOM datetime 'DT' to international format YYYY-MM-DD hh:mm:ss.
| orig | Pointer to original DICOM string. Should be in format YYYYMMDDhhmmss.FFFFFF+hhmm |
| intl | Pointer to string where date and time in international format will be written; must be allocated for at least 20 characters. |
Definition at line 345 of file dcm.c.
| void dcmfileFree | ( | DCMFILE * | d | ) |
Free memory allocated for DCMFILE data. All contents are destroyed.
| d | Pointer to DCMFILE. |
Definition at line 868 of file dcm.c.
Referenced by dcmFileRead().
| void dcmfileInit | ( | DCMFILE * | d | ) |
Initiate the DCMFILE struct before any use.
| d | Pointer to DCMFILE. |
Definition at line 823 of file dcm.c.
Referenced by dcmfileFree().
| unsigned short int dcmfileMaxDepth | ( | DCMFILE * | df | ) |
Get the maximum depth of DCMFILE items tree.
| df | Pointer to DCMFILE item. |
Definition at line 903 of file dcm.c.
| int dcmFileRead | ( | const char * | filename, |
| DCMFILE * | dcm, | ||
| const short int | headerOnly, | ||
| int | verbose ) |
Read a single DICOM file.
| filename | Pointer to filename. |
| dcm | Pointer to initiated data structure. |
| headerOnly | Read only header (1), or read both header and pixel data (0). |
| verbose | Verbose level; if zero, then nothing is printed into stdout or stderr |
Definition at line 1687 of file dcm.c.
| int dcmFileReadNextElement | ( | DCMFILE * | dcm, |
| DCMITEM * | prev_item, | ||
| DCMITEM * | parent_item, | ||
| const short int | sub, | ||
| const short int | headerOnly, | ||
| int | verbose ) |
Read an element from DICOM file, and add it to the given linked list. This function will be called recursively in case of sequential items.
| dcm | Pointer to DCMFILE struct; must be initiated before first call. |
| prev_item | Pointer to previous element; NULL if none exists (yet). |
| parent_item | Pointer to parent element; NULL if none exists (yet). |
| sub | Add as next element (0) or as child element. |
| headerOnly | Read only header (1), or read both header and pixel data (0). |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 1370 of file dcm.c.
Referenced by dcmFileRead(), and dcmFileReadNextElement().
| int dcmFileWrite | ( | const char * | filename, |
| DCMFILE * | dcm, | ||
| int | verbose ) |
Write a single DICOM file.
| filename | Pointer to file name. |
| dcm | Pointer to DICOM data to be written. |
| verbose | Verbose level; if zero, then nothing is printed into stdout or stderr |
Definition at line 1758 of file dcm.c.
Search for specified tag in DCMITEM data tree.
| d | Pointer to current DICOM item. |
| omit | Omit this item from the search. |
| tag | Pointer to the DICOM tag that is searched for. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 1163 of file dcm.c.
Referenced by dcmFindTag().
| void dcmitemFree | ( | DCMITEM * | d | ) |
Recursively free memory allocated for DCMITEM items and their children items.
| d | Pointer to DCMITEM. |
Definition at line 840 of file dcm.c.
Referenced by dcmfileFree(), and dcmitemFree().
| long int dcmitemGetInt | ( | DCMITEM * | d | ) |
Read integer value from given DICOM item.
VR must be either UL, US, SL, SS, or IS; otherwise 0 is returned.
| d | Pointer to item. |
Definition at line 1084 of file dcm.c.
| double dcmitemGetReal | ( | DCMITEM * | d | ) |
Read floating point value from given DICOM item.
VR must be either FL, FD, DS, UL, US, SL, SS, or IS; otherwise 0 is returned.
| d | Pointer to item. |
Definition at line 1120 of file dcm.c.
| unsigned short int dcmitemMaxDepth | ( | DCMITEM * | d | ) |
Get the maximum depth of DCMITEM tree.
| d | Pointer to DCMITEM item. |
Definition at line 884 of file dcm.c.
Referenced by dcmfileMaxDepth(), and dcmitemMaxDepth().
| unsigned short int dcmitemParentNr | ( | DCMITEM * | d | ) |
Check how deep in DCMITEM tree this item is.
| d | Pointer to DCMITEM. |
Definition at line 923 of file dcm.c.
Referenced by dcmFileReadNextElement().
| void dcmitemPrint | ( | DCMITEM * | d | ) |
Print contents of given DICOM item into stdout.
| d | Pointer to item. |
Definition at line 1205 of file dcm.c.
Referenced by dcmAddItem(), and dcmFileWrite().
| int dcmReadFileTag | ( | FILE * | fp, |
| DCMTAG * | tag ) |
Read DICOM tag from current file position.
| fp | File pointer, positioned at the start of the element (and tag). |
| tag | Pointer to DICOM tag struct; enter NULL if you just need to move file position over the tag. |
Definition at line 553 of file dcm.c.
Referenced by dcmFileReadNextElement(), and dcmReadTransferSyntaxUID().
| unsigned int dcmReadFileVL | ( | FILE * | fp, |
| unsigned int | n ) |
Read DICOM value length (2 or 4 bytes, depending on VR) from current file position.
| fp | File pointer, positioned at the VL start. |
| n | Number of bytes (2 or 4) in the VL representation. |
Definition at line 692 of file dcm.c.
Referenced by dcmFileReadNextElement(), and dcmReadTransferSyntaxUID().
| dcmvr dcmReadFileVR | ( | FILE * | fp, |
| char * | vrstr ) |
Read DICOM value representation (2 or 4 bytes) from current file position.
| fp | File pointer, positioned at the VR start. |
| vrstr | Pointer for VR string, allocated for at least 3 characters to have space for the trailing null; enter NULL if not needed. |
Definition at line 655 of file dcm.c.
Referenced by dcmReadTransferSyntaxUID().
| int dcmReadFileVRVL | ( | FILE * | fp, |
| dcmvr * | vr, | ||
| unsigned int * | vl, | ||
| unsigned int * | n ) |
Read DICOM Value Representation (VR, 2 or 4 bytes) and Value Length (VL, 2 or 4 bytes) from current file position.
| fp | File pointer, positioned at the VR start. |
| vr | Pointer for enumerated VR value; enter NULL if not needed (file pointer moved anyway). |
| vl | Pointer for VL; enter NULL if not needed (file pointer moved anyway). |
| n | Pointer for number of bytes read from file; enter NULL if not needed. |
Definition at line 724 of file dcm.c.
Referenced by dcmFileReadNextElement().
| dcmtruid dcmReadTransferSyntaxUID | ( | FILE * | fp | ) |
Read and identify the DICOM Transfer Syntax UID.
| fp | Pointer to DICOM file opened in binary format, and positioned right after the Magic number. Position will be returned to this position. |
Definition at line 502 of file dcm.c.
Referenced by dcmFileRead().
| unsigned int dcmSOPIdentify | ( | const char * | s | ) |
Identify the DICOM SOP UID.
| s | SOP UID string. |
Definition at line 367 of file dcm.c.
| char * dcmSOPName | ( | unsigned int | i | ) |
Get the DICOM SOP UID Name.
| i | SOP UID list index. |
Definition at line 388 of file dcm.c.
| char * dcmSOPUID | ( | unsigned int | i | ) |
Get the DICOM SOP UID.
| i | SOP UID list index. |
Definition at line 406 of file dcm.c.
| char * dcmSOPUIDName | ( | const char * | s | ) |
Get the name of DICOM SOP UID.
| s | SOP UID string. |
Definition at line 424 of file dcm.c.
| void dcmTagSet | ( | DCMTAG * | tag, |
| unsigned short int | group, | ||
| unsigned short int | element ) |
| char * dcmTM2intl | ( | const char * | orig, |
| char * | intl ) |
Convert DICOM time 'TM' to international format hh:mm:ss.
| orig | Pointer to original DICOM string. |
| intl | Pointer to string where time in international format will be written; must be allocated for at least 9 characters. |
Definition at line 322 of file dcm.c.
| dcmtruid dcmTrUID | ( | const char * | s | ) |
Identify the DICOM Transfer Syntax UID.
| s | UID string. |
Definition at line 445 of file dcm.c.
Referenced by dcmReadTransferSyntaxUID().
| char * dcmTrUIDDescr | ( | dcmtruid | id | ) |
Get the DICOM Transfer Syntax UID description.
| id | Transfer Syntax UID id (DCM_TRUID_LEI, ...). |
Definition at line 466 of file dcm.c.
Referenced by dcmFileRead().
| char * dcmTrUIDString | ( | dcmtruid | id | ) |
Get the DICOM Transfer Syntax UID string.
| id | Transfer Syntax UID id (DCM_TRUID_LEI, ...). |
Definition at line 484 of file dcm.c.
| char * dcmValueString | ( | DCMITEM * | d | ) |
Pre-process the DICOM element value into format suitable for printing.
Attribute tag
Float
Double
Unsigned 32-bit int
Unsigned 16-bit int
Signed 32-bit int
Signed 16-bit int
| d | Pointer to item containing the value to print. |
Definition at line 942 of file dcm.c.
Referenced by dcmitemPrint().
| int dcmVerifyMagic | ( | const char * | filename, |
| FILE * | fp ) |
Verify that given file (either file name or file pointer) appears to be DICOM file, based on the magic number.
| filename | Name of file to open and to verify for the magic number; enter NULL to use the file pointer (next argument) instead. |
| fp | File pointer of file to check, opened with fp=fopen(filename, "rb"); enter NULL to open file (previous argument) locally. Previously opened file pointer is first rewound to start; if DICOM magic number is found, then file pointer is left to the end of magic number, and if not, it is rewound to the file start. |
Definition at line 157 of file dcm.c.
Referenced by dcmFileRead(), and imgFormatDetermine().
| char * dcmVRDescr | ( | dcmvr | id | ) |
Get the DICOM VR description.
| id | VR id (DCM_VR_AE, ...). |
Definition at line 282 of file dcm.c.
Referenced by dcmFileReadNextElement().
| dcmvr dcmVRId | ( | const char * | s | ) |
Identify the DICOM VR based on the two-character long string.
| s | VR string. Two first characters are used. String does not need to be null-terminated. |
Definition at line 223 of file dcm.c.
Referenced by dcmReadFileVR(), and dcmReadFileVRVL().
| char * dcmVRName | ( | dcmvr | id | ) |
Get the DICOM VR name.
| id | VR id (DCM_VR_AE, ...). |
Definition at line 246 of file dcm.c.
Referenced by dcmAddItem(), dcmFileReadNextElement(), dcmitemPrint(), dcmReadFileVR(), and dcmWriteFileVRVL().
| unsigned char dcmVRReserved | ( | dcmvr | id | ) |
Is the explicit VR (2 bytes) followed by reserved 2 bytes? If yes, then the following Value Length is also given as 32-byte integer, if no, then as 16-bit integer.
| id | VR id (DCM_VR_AE, ...). |
Definition at line 205 of file dcm.c.
Referenced by dcmReadFileVR(), dcmReadFileVRVL(), dcmReadTransferSyntaxUID(), and dcmWriteFileVRVL().
| size_t dcmVRVLength | ( | dcmvr | id | ) |
Get the DICOM VR max value length in bytes; 0 if not defined.
| id | VR id (DCM_VR_AE, ...). |
Definition at line 264 of file dcm.c.
Referenced by dcmAddItem(), dcmFileReadNextElement(), dcmFileWrite(), and dcmValueString().
| int dcmWriteFileSQDelimItem | ( | FILE * | fp | ) |
Write DICOM Sequence delimitation item into current file position.
This item consists of four byte sequence delimitation tag (0xFFFE, 0xE0DD) and four byte item length (0x00000000), i.e. together 8 bytes.
| fp | File pointer, at the write position. |
Definition at line 609 of file dcm.c.
Referenced by dcmFileWrite().
| int dcmWriteFileSQItemDelimTag | ( | FILE * | fp | ) |
Write DICOM Sequence Item Delimitation Tag with VL into current file position.
This tag consists of four bytes, sequence item delimitation tag (0xFFFE, 0xE00D), followed by four byte item length (0x00000000), i.e. together 8 bytes.
| fp | File pointer, at the write position. |
Definition at line 634 of file dcm.c.
Referenced by dcmFileWrite().
| int dcmWriteFileTag | ( | FILE * | fp, |
| DCMTAG * | tag ) |
Write DICOM tag into current file position.
| fp | File pointer, at the write position. |
| tag | Pointer to DICOM tag struct to write. |
Definition at line 583 of file dcm.c.
Referenced by dcmFileWrite(), dcmWriteFileSQDelimItem(), and dcmWriteFileSQItemDelimTag().
| int dcmWriteFileVRVL | ( | FILE * | fp, |
| dcmvr | vr, | ||
| unsigned int | vl, | ||
| unsigned int * | n ) |
Write DICOM Value Representation (VR, 2 or 4 bytes) and Value Length (VL, 2 or 4 bytes) into current file position.
| fp | File pointer, opened fro writing in binary mode. |
| vr | Enumerated VR value. |
| vl | VL |
| n | Pointer for number of bytes written into file; enter NULL if not needed. |
Definition at line 784 of file dcm.c.
Referenced by dcmFileWrite().