|
TPCCLIB
|
Procedures for reading and writing NIfTI-1 PET images. More...
#include "libtpcimgio.h"Go to the source code of this file.
Functions | |
| void | niftiRemoveFNameExtension (char *fname) |
| int | niftiCreateFNames (const char *filename, char *hdrfile, char *imgfile, char *siffile, int fileformat) |
| int | niftiRemove (const char *dbname, int fileformat, int verbose) |
| int | niftiExists (const char *filename, char *hdrfile, char *imgfile, char *siffile, NIFTI_DSR *header, int verbose, char *status) |
| int | niftiReadHeader (char *filename, NIFTI_DSR *dsr, int verbose, char *status) |
| int | niftiPrintHeader (NIFTI_DSR *dsr, FILE *fp) |
| int | niftiReadImagedata (FILE *fp, NIFTI_DSR *dsr, int frame, float *data, int verbose, char *status) |
| int | niftiWriteHeader (char *filename, NIFTI_DSR *dsr, int verbose, char *status) |
Procedures for reading and writing NIfTI-1 PET images.
Function are not intended to support all NIfTI files or file properties, but only those that have been found necessary in Turku PET Centre. For full NIfTI support, use other libraries e.g. niftilib https://niftilib.sourceforge.net/
NIfTI-1 and NIfTI-2 documentation and source codes in https://nifti.nimh.nih.gov/
Procedures in this file are not dependent on IMG struct.
Definition in file nifti.c.
| int niftiCreateFNames | ( | const char * | filename, |
| char * | hdrfile, | ||
| char * | imgfile, | ||
| char * | siffile, | ||
| int | fileformat ) |
Construct the file names for NIfTI image.
| filename | Filename, either header file, image file, or base name without extensions, but possibly with path name. This string is never modified. |
| hdrfile | Header filename will be written in this char pointer (space needs to allocated by caller); If header and image are combined, then this will be the name of combined file; enter NULL if not needed. |
| imgfile | Image filename will be written in this char pointer (space needs to allocated by caller); If header and image are combined, then this will be the name of combined file; enter NULL if not needed. |
| siffile | SIF filename will be written in this char pointer (space needs to allocated by caller); enter NULL if not needed. |
| fileformat | NIfTI file format, either IMG_NIFTI_1D (31) or IMG_NIFTI_1S (32). |
Definition at line 44 of file nifti.c.
Referenced by imgWriteNifti(), imgWriteNiftiFrame(), and niftiRemove().
| int niftiExists | ( | const char * | filename, |
| char * | hdrfile, | ||
| char * | imgfile, | ||
| char * | siffile, | ||
| NIFTI_DSR * | header, | ||
| int | verbose, | ||
| char * | status ) |
Verify if specified filename is a NIfTI file.
| filename | Filename, either header file, image file, or base name without extensions. This string is never modified. |
| hdrfile | If filename refers to a Nifti file, then header filename will be written in this char pointer (space needs to allocated by caller); If header and image are combined, then this will be the name of combined file; enter NULL if not needed. |
| imgfile | If filename refers to a Nifti file, then image filename will be written in this char pointer (space needs to allocated by caller); If header and image are combined, then this will be the name of combined file; enter NULL if not needed. |
| siffile | If filename refers to a Nifti file, and if SIF exists, then SIF filename will be written in this char pointer (space needs to allocated by caller); NULL if not needed. |
| header | Pointer to Nifti header, which is filled in this function; enter NULL, if not needed. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
| status | Pointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed. |
Definition at line 160 of file nifti.c.
Referenced by imgFormatDetermine(), imgRead(), imgReadNiftiFrame(), imgReadNiftiHeader(), and imgWriteNiftiFrame().
| int niftiPrintHeader | ( | NIFTI_DSR * | dsr, |
| FILE * | fp ) |
Print the contents of Nifti header to specified file pointer.
| dsr | Pointer to combined Nifti header. |
| fp | File pointer where header information is printed. |
Definition at line 501 of file nifti.c.
Referenced by niftiExists().
| int niftiReadHeader | ( | char * | filename, |
| NIFTI_DSR * | dsr, | ||
| int | verbose, | ||
| char * | status ) |
Read Nifti header contents. Currently, does not read Nifti-1 header extension.
| filename | Name of file to read (including path and extension) |
| dsr | Pointer to previously allocated header structure |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
| status | Pointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed |
Definition at line 293 of file nifti.c.
Referenced by niftiExists().
| int niftiReadImagedata | ( | FILE * | fp, |
| NIFTI_DSR * | dsr, | ||
| int | frame, | ||
| float * | data, | ||
| int | verbose, | ||
| char * | status ) |
Read Nifti image data, convert byte order if necessary, and scale values to floats. Reads only one frame at a time!
| fp | File pointer to start of image data file, opened previously in binary mode. |
| dsr | Pointer to previously filled Nifti header structure |
| frame | Frame number to read [1..number of frames]. |
| data | Pointer to image float data allocated previously for dimz*dimy*dimx floats. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
| status | Pointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed. |
Definition at line 619 of file nifti.c.
Referenced by imgReadNiftiFrame().
| int niftiRemove | ( | const char * | dbname, |
| int | fileformat, | ||
| int | verbose ) |
Remove header and voxel data files or the single .nii file belonging to specified NIfTI database.
SIF is not deleted in any case. Validity of NIfTI is not verified, therefore this can be used to delete any files with similar name as NIfTI would have.
| dbname | NIfTI database name with path, possibly with filename extension |
| fileformat | NIfTI file format, either IMG_NIFTI_1D (31) or IMG_NIFTI_1S (32), or IMG_UNKNOWN (0) in case both are to be deleted. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
Definition at line 100 of file nifti.c.
Referenced by imgWriteNifti().
| void niftiRemoveFNameExtension | ( | char * | fname | ) |
Remove any extensions from Nifti file name, leaving only base file name.
| fname | Full name of file. |
Definition at line 23 of file nifti.c.
Referenced by imgReadNiftiFrame(), imgReadNiftiHeader(), niftiCreateFNames(), and niftiExists().
| int niftiWriteHeader | ( | char * | filename, |
| NIFTI_DSR * | dsr, | ||
| int | verbose, | ||
| char * | status ) |
Write NIfTI-1 header contents.
Currently, does not write header extension. Header field 'byte_order' is used to determine the required byte order.
| filename | Name of file to write (including path and extension). |
| dsr | Pointer to previously allocated header structure. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
| status | Pointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed. |
Definition at line 844 of file nifti.c.
Referenced by imgWriteNiftiFrame().