|
TPCCLIB
|
Header file for libtpcimage. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "tpcextensions.h"#include "tpcift.h"#include "tpcisotope.h"#include "tpctac.h"#include "tpcecat.h"#include "tpcdcm.h"#include "tpcnifti.h"Go to the source code of this file.
Data Structures | |
| struct | IMG |
Functions | |
| void | imgInit (IMG *image) |
| void | imgFree (IMG *image) |
| int | imgAllocate (IMG *img, const unsigned int dimz, const unsigned int dimy, const unsigned int dimx, const unsigned int dimt, TPCSTATUS *status) |
| char * | imgContentDescr (imgcontent c) |
| char * | imgModalityDescr (imgmodality c) |
| int | imgHasData (IMG *img) |
| int | imgHasTimes (IMG *img) |
| int | imgHasCounts (IMG *img) |
| int | imgHasWeights (IMG *img) |
| void | imgContents (IMG *img, FILE *fp) |
| unsigned long long | imgNaNs (IMG *img, int fix) |
| int | imgMinMax (IMG *img, float *minvalue, float *maxvalue) |
| int | imgXRange (IMG *img, double *xmin, double *xmax) |
| int | imgXUnitConvert (IMG *img, const int u) |
| int | imgCopyHeader (IMG *img1, IMG *img2) |
| int | imgFillOHeader (IMG *img, TPCSTATUS *status) |
| char * | imgFormatDescr (imgformat c) |
| char * | imgDefaultExtension (imgformat c) |
| int | imgRead (IMG *img, const char *fname, TPCSTATUS *status) |
| int | imgWrite (IMG *img, const char *fname, TPCSTATUS *status) |
| imgformat | imgFormatFromFName (const char *fname, TPCSTATUS *status) |
| imgformat | imgFormatIdentify (const char *s) |
| int | imgReadDICOM (IMG *img, const char *fname, TPCSTATUS *status) |
| int | imgWriteDICOM (IMG *img, const char *fname, TPCSTATUS *status) |
| int | niftiCreateFNames (const char *filename, char *hdrfile, char *imgfile, char *siffile, int fileformat) |
| int | imgReadNifti (IMG *img, const char *fname, TPCSTATUS *status) |
| int | imgWriteNifti (IMG *img, const char *fname, TPCSTATUS *status) |
| int | imgSetNiftiHeader (IMG *img, NIFTI_DSR *dsr, int verbose) |
| int | imgGetNiftiHeader (IMG *img, NIFTI_DSR *dsr, int verbose) |
| int | imgToSIF (IMG *img, TAC *sif, int copy_header, int copy_frames, int copy_counts, int verbose) |
| int | imgFromSIF (IMG *img, TAC *sif, int copy_header, int copy_frames, int copy_counts, int verbose) |
| int | imgCompareMatrixSize (IMG *d1, IMG *d2) |
| int | imgCompareUnit (IMG *d1, IMG *d2, TPCSTATUS *status) |
| int | imgCompareConc (IMG *d1, IMG *d2, const float test_abs, const float test_rel, TPCSTATUS *status) |
| int | imgCompareTimes (IMG *d1, IMG *d2, const float test_abs, const float test_rel, TPCSTATUS *status) |
Header file for libtpcimage.
Header file for image data processing library libtpcimage.
Definition in file tpcimage.h.
| enum imgcontent |
Image data content codes for IMG data structure.
Definition at line 70 of file tpcimage.h.
| enum imgformat |
Image file format codes for IMG data structure.
Definition at line 32 of file tpcimage.h.
| enum imgmodality |
Image modality codes for IMG data structure.
| Enumerator | |
|---|---|
| IMG_MODALITY_UNKNOWN | Unknown modality. |
| IMG_MODALITY_PET | PET. |
| IMG_MODALITY_SPECT | SPECT. |
| IMG_MODALITY_CT | CT. |
| IMG_MODALITY_MRI | MRI. |
| IMG_MODALITY_LAST | End of list. |
Definition at line 56 of file tpcimage.h.
|
extern |
Allocates memory for image data. Old contents are not saved.
| img | Pointer to initialized image structure; old contents are deleted. |
| dimz | Nr of image planes to allocate. |
| dimy | Nr of image rows to allocate. |
| dimx | Nr of image columns to allocate. |
| dimt | Nr of image time frames (samples) to allocate. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 126 of file image.c.
Referenced by imgReadDICOM(), and imgReadNifti().
|
extern |
Check whether IMG pixel concentrations are the same. Note that units are ignored here.
If either absolute or relative difference is below the limit, the test is reported as passed.
| d1 | Pointer to IMG structure. |
| d2 | Pointer to IMG structure. |
| test_abs | Limit for accepted absolute difference; obligatory. |
| test_rel | Optional limit for accepted relative difference |2*(x1-x2)/(x1+x2)| ; set to negative value to not test this; in case of zero mean, this test is assumed to fail, but test for absolute difference may still pass. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 79 of file imagecomp.c.
Check whether two IMG data have the same matrix (x,y,z) size.
Definition at line 18 of file imagecomp.c.
|
extern |
Check whether IMG frame times (x values) are the same. Note that units are ignored here.
If either absolute or relative difference is below the limit, the test is reported as passed.
| d1 | Pointer to IMG structure. |
| d2 | Pointer to IMG structure. |
| test_abs | Limit for accepted absolute difference. |
| test_rel | Optional limit for accepted relative difference |2*(x1-x2)/(x1+x2)| ; set to negative value to not test this; in case of zero mean, this test is assumed to fail, but test for absolute difference may still pass. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 144 of file imagecomp.c.
Check whether time and concentration units are the same in two IMG data.
| d1 | Pointer to IMG structure. |
| d2 | Pointer to IMG structure. |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 39 of file imagecomp.c.
|
extern |
Return pointer to content type of the image data.
| c | IMG content code |
Definition at line 51 of file image.c.
Referenced by imgContents(), and imgFillOHeader().
|
extern |
Print general information on the contents of the IMG data structure.
| img | Pointer to IMG structure. |
| fp | File pointer for output; usually stdout. |
Definition at line 293 of file image.c.
Copy information fields from one IMG to another. Image dimensions, pixel data, and frame information are not copied.
| img1 | Pointer to source image structure. |
| img2 | Pointer to initiated target image structure. |
Definition at line 18 of file imageheader.c.
|
extern |
Return pointer to default image file name extension based on the format code.
| c | IMG format code |
Definition at line 67 of file imageio.c.
Fill/edit IMG output header.
| img | Pointer to image structure. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 61 of file imageheader.c.
Referenced by imgWrite().
|
extern |
Return pointer to image file format description with the format code.
| c | IMG format code |
Definition at line 36 of file imageio.c.
Referenced by imgContents(), imgFillOHeader(), imgReadNifti(), and imgWrite().
Determine IMG file format from file name.
If file name is actually name of an existing path, then DICOM is assumed. Non-existing path can be identified as path only if it ends with '/'.
Note that NIfTI dual file format, Analyze, and microPET files can not be separated by file naming.
| fname | Name of file that is used to determine format. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 394 of file imageio.c.
Referenced by imgWrite().
|
extern |
Identify the string representation of the IMG file format.
| s | IMG format as a string |
Definition at line 466 of file imageio.c.
|
extern |
Free memory allocated for IMG. All data is cleared.
| img | Pointer to IMG structure. |
Definition at line 107 of file image.c.
Referenced by imgAllocate(), imgRead(), imgReadDICOM(), and imgReadNifti().
|
extern |
Copy information from SIF into IMG.
| img | Pointer to IMG struct into which content is copied from SIF. |
| sif | Pointer to SIF, which actually is stored as a TAC format. |
| copy_header | Select whether header contents are copied (1) or not copied (0) from SIF. |
| copy_frames | Select whether frame times are copied (1) or not copied (0) from SIF. |
| copy_counts | Select whether counts are copied (1) or not copied (0) from SIF. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
Definition at line 126 of file imagesif.c.
Referenced by imgReadNifti().
Copy header information from NIfTI into IMG.
| img | Pointer to IMG structure to be filled. |
| dsr | Pointer to NIfTI header structure from which information is read. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 794 of file imagenii.c.
Referenced by imgReadNifti().
|
extern |
Verify that IMG contains prompts and randoms.
| img | Pointer to image structure. |
Definition at line 251 of file image.c.
Referenced by imgContents(), and imgToSIF().
|
extern |
Verify that image data actually contains pixel data.
| img | Pointer to image structure. |
Definition at line 218 of file image.c.
Referenced by imgContents(), imgCopyHeader(), imgFillOHeader(), imgHasTimes(), imgMinMax(), imgSetNiftiHeader(), imgWrite(), imgWriteNifti(), and imgXRange().
|
extern |
Verify that IMG contains frame times.
| img | Pointer to image structure. |
Definition at line 235 of file image.c.
Referenced by imgContents(), imgToSIF(), and imgWriteNifti().
|
extern |
Check if image contains weights as indicated by the 'weighting' field.
| img | Pointer to image structure. |
Definition at line 278 of file image.c.
Referenced by imgContents().
|
extern |
Initiate the IMG structure before any use.
| img | Pointer to IMG structure. |
Definition at line 64 of file image.c.
Referenced by imgFree().
|
extern |
Searches the min and max pixel value in the image data.
| img | Pointer to IMG structure from where min and max pixel values are searched. |
| minvalue | Pointer to min pixel value; Enter NULL if not needed. |
| maxvalue | Pointer to max pixel value; Enter NULL if not needed. |
Definition at line 396 of file image.c.
Referenced by imgSetNiftiHeader().
|
extern |
Return pointer to modality of the image data.
| c | IMG modality code |
Definition at line 27 of file image.c.
Referenced by imgContents(), and imgFillOHeader().
|
extern |
Searches the image data for missing pixel values, optionally setting those to zero.
| img | Pointer to IMG structure. |
| fix | Set (1) or do not set (0) missing pixels to zero. |
Read image file into IMG structure.
| img | Pointer to initialized image structure; old contents are deleted. |
| fname | Pointer to the file name, possibly path in case of DICOM. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 82 of file imageio.c.
Read DICOM PET image into IMG data structure.
| img | Pointer to image structure. Any previous contents removed. |
| fname | Pointer to the DICOM file name. Path not accepted. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 23 of file imagedcm.c.
Referenced by imgRead().
Read NIfTI into IMG data structure.
| img | Pointer to image structure. Any previous contents removed. |
| fname | Pointer to the database name. Path alone not accepted. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 72 of file imagenii.c.
Referenced by imgRead().
Copy header information in IMG structure into NIfTI header structure.
Header contents will depend on the output format as specified in IMG->oformat, which can be set to IMG_FORMAT_NIFTI_1D, IMG_FORMAT_NIFTI_1S, IMG_FORMAT_NIFTI_2D, or IMG_FORMAT_NIFTI_2S. NIFTI_DSR->n will tell whether NIfTI-1 or NIfTI-2 header was filled.
| img | Pointer to IMG structure from which header information is read. |
| dsr | Pointer to NIfTI header structure to be filled; any previous contents are removed. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 576 of file imagenii.c.
Referenced by imgWriteNifti().
|
extern |
Set SIF contents based on data in IMG.
| img | Pointer to IMG struct from which content is copied to SIF. |
| sif | Pointer to SIF, which actually is stored as a TAC format. Previous contents are optionally kept. |
| copy_header | Select whether header contents are copied (1) or not copied (0) to SIF. |
| copy_frames | Select whether frame times are copied (1) or not copied (0) to SIF. |
| copy_counts | Select whether counts are copied (1) or not copied (0) to SIF, or created if they do not exist (2). |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 18 of file imagesif.c.
Referenced by imgWriteNifti().
Write image file from IMG structure.
| img | Pointer to image structure. |
| fname | Pointer to the file name, possibly path in case of DICOM. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 214 of file imageio.c.
Write DICOM image into IMG data structure.
| img | Pointer to image structure. |
| fname | Pointer to the name of DICOM folder. Must be empty or not exist. |
| status | Pointer to status data; obligatory. |
Definition at line 335 of file imagedcm.c.
Write NIfTI from IMG data structure.
IMG field oformat (or secondarily format) determines whether NIfTI is written in single file format (*.nii) or dual file format (*.hdr and *.img).
SIF file is saved to store frame times, if frame times are available.
| img | Pointer to image structure. Any previous contents removed. |
| fname | Pointer to the database name. Path not accepted. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 390 of file imagenii.c.
Referenced by imgWrite().
|
extern |
Get the range of x values (times) in the image data.
Data is not modified. Data does not need to be sorted.
| img | Pointer to IMG structure. |
| xmin | Pointer to variable for min x value (NULL if not needed). |
| xmax | Pointer to variable for max x value (NULL if not needed). |
Definition at line 430 of file image.c.
| int imgXUnitConvert | ( | IMG * | img, |
| const int | u ) |
Convert X values (frame times) in IMG structure to the specified unit.
| img | Pointer to IMG structure. |
| u | Enum unit |
Definition at line 462 of file image.c.
|
extern |
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); in single file format this will be set to the name of the single file; enter NULL if not needed. |
| imgfile | Image filename will be written in this char pointer (space needs to allocated by caller); in single file format this will be set to the name of the single 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_FORMAT_NIFTI_1D, IMG_FORMAT_NIFTI_1S, IMG_NIFTI_FORMAT_2D, or IMG_FORMAT_NIFTI_2S. |
Definition at line 17 of file imagenii.c.
Referenced by imgWriteNifti().