TPCCLIB
Loading...
Searching...
No Matches
libtpcimgio.h
Go to the documentation of this file.
1
5#ifndef _LIBTPCIMGIO_H
6#define _LIBTPCIMGIO_H
7/*****************************************************************************/
8
9/*****************************************************************************/
10#include "tpcclibConfig.h"
11/*****************************************************************************/
12//#include <omp.h>
13/*****************************************************************************/
14#include <stdio.h>
15#include <string.h>
16#include <math.h>
17#include <stdint.h>
18#include <stdlib.h>
19#include <strings.h>
20#include <ctype.h>
21#include <float.h>
22#include <unistd.h>
23#include <locale.h>
24#include <time.h>
25/*****************************************************************************/
26#include "libtpcmisc.h"
27/*****************************************************************************/
28
29/*****************************************************************************/
30#ifndef BACKUP_EXTENSION
32#define BACKUP_EXTENSION ".bak"
33#endif
34/*****************************************************************************/
35
36/*****************************************************************************/
37/* Analyze */
38
40#define ANALYZE_HEADER_KEY_SIZE 40
41#define ANALYZE_HEADER_IMGDIM_SIZE 108
42#define ANALYZE_HEADER_HISTORY_SIZE 200
43#define ANALYZE_FLIP_DEFAULT 1
45
47#define ANALYZE_DT_NONE 0
49#define ANALYZE_DT_UNKNOWN 0
51#define ANALYZE_DT_BINARY 1
53#define ANALYZE_DT_UNSIGNED_CHAR 2
55#define ANALYZE_DT_SIGNED_SHORT 4
57#define ANALYZE_DT_SIGNED_INT 8
59#define ANALYZE_DT_FLOAT 16
61#define ANALYZE_DT_COMPLEX 32
63#define ANALYZE_DT_DOUBLE 64
65#define ANALYZE_DT_RGB 128
67#define ANALYZE_DT_ALL 255
68
70extern int ANALYZE_TEST;
71
73typedef struct {
77 char data_type[10];
79 char db_name[18];
84 short int session_error;
87 char regular;
91
93typedef struct {
96 short int dim[8];
98 short int unused8;
100 short int unused9;
102 short int unused10;
104 short int unused11;
106 short int unused12;
108 short int unused13;
110 short int unused14;
118 short int datatype;
120 short int bitpix;
122 short int dim_un0;
124 float pixdim[8];
130 float funused1;
132 float funused2;
134 float funused3;
136 float cal_max;
138 float cal_min;
142 float verified;
144 int glmax;
146 int glmin;
148
150typedef struct {
152 char descrip[80];
154 char aux_file[24];
158 char orient;
160 char originator[10];
162 char generated[10];
164 char scannum[10];
166 char patient_id[10];
168 char exp_date[10];
170 char exp_time[10];
172 char hist_un0[3];
174 int views;
182 int omax;
184 int omin;
186 int smax;
188 int smin;
190
191
203/*****************************************************************************/
204
205/*****************************************************************************/
206/* ECAT 7.x */
207
208#ifndef MatBLKSIZE
210#define MatBLKSIZE 512
211#endif
212#ifndef MatFirstDirBlk
214#define MatFirstDirBlk 2
215#endif
216
218#define ECAT7V_MAGICNR "MATRIX72v"
219#define ECAT7S_MAGICNR "MATRIX7011"
220#define ECAT7_SW_VERSION 72
222
224#define ECAT7_BYTE 1
226#define ECAT7_VAXI2 2
228#define ECAT7_VAXI4 3
230#define ECAT7_VAXR4 4
232#define ECAT7_IEEER4 5
234#define ECAT7_SUNI2 6
236#define ECAT7_SUNI4 7
238#define M68K_I2 SUN_I2
240#define M68K_I4 SUN_I4
241
243#define ECAT7_UNKNOWN 0
245#define ECAT7_2DSCAN 1
247#define ECAT7_IMAGE16 2
249#define ECAT7_ATTEN 3
251#define ECAT7_2DNORM 4
253#define ECAT7_POLARMAP 5
255#define ECAT7_VOLUME8 6
257#define ECAT7_VOLUME16 7
259#define ECAT7_PROJ 8
261#define ECAT7_PROJ16 9
263#define ECAT7_IMAGE8 10
265#define ECAT7_3DSCAN 11
267#define ECAT7_3DSCAN8 12
269#define ECAT7_3DNORM 13
271#define ECAT7_3DSCANFIT 14
272
274#define ECAT7_Feet_First_Prone 0
276#define ECAT7_Head_First_Prone 1
278#define ECAT7_Feet_First_Supine 2
280#define ECAT7_Head_First_Supine 3
282#define ECAT7_Feet_First_Decubitus_Right 4
284#define ECAT7_Head_First_Decubitus_Right 5
286#define ECAT7_Feet_First_Decubitus_Left 6
288#define ECAT7_Head_First_Decubitus_Left 7
290#define ECAT7_Unknown_Orientation 8
291
293extern char ecat7errmsg[128];
295extern int ECAT7_TEST;
296
300typedef struct ecat7_mainheader { /* 512 bytes, if packed (not aligned) */
302 char magic_number[14];
304 char original_file_name[32];
306 short int sw_version;
308 short int system_type;
310 short int file_type;
312 char serial_number[10];
316 char isotope_name[8];
320 char radiopharmaceutical[32];
330 short int wobble_speed;
340 short int coin_samp_mode;
352 char study_type[12];
354 char patient_id[16];
356 char patient_name[32];
372 char physician_name[32];
374 char operator_name[32];
376 char study_description[32];
383 char facility_name[20];
385 short int num_planes;
387 short int num_frames;
389 short int num_gates;
391 short int num_bed_pos;
395 float bed_position[15];
399 short int lwr_sctr_thres;
401 short int lwr_true_thres;
403 short int upr_true_thres;
405 char user_process_code[10];
409 float bin_size;
416 float dosage;
420 char data_units[32];
422 short int septa_state;
424 short int fill_cti[6];
426
428typedef struct ecat7_imageheader {
430 short int data_type;
432 short int num_dimensions;
434 short int x_dimension;
436 short int y_dimension;
438 short int z_dimension;
440 float x_offset;
442 float y_offset;
444 float z_offset;
450 short int image_min;
452 short int image_max;
464 short int filter_code;
494 short int filter_order;
500 char annotation[40];
502 float mt_1_1;
504 float mt_1_2;
506 float mt_1_3;
508 float mt_2_1;
510 float mt_2_2;
512 float mt_2_3;
514 float mt_3_1;
516 float mt_3_2;
518 float mt_3_3;
524 short int rfilter_code;
526 short int rfilter_order;
532 short int zfilter_code;
534 short int zfilter_order;
536 float mt_1_4;
538 float mt_2_4;
540 float mt_3_4;
542 short int scatter_type;
544 short int recon_type;
546 short int recon_views;
548 short int fill_cti[87];
550 short int fill_user[49];
552
554typedef struct ecat7_scanheader {
556 short int data_type;
558 short int num_dimensions;
560 short int num_r_elements;
562 short int num_angles;
566 short int num_z_elements[64];
570 short int storage_order;
582 short int fill_gate[6];
592 short int scan_min;
594 short int scan_max;
616 short int fill_cti[90];
618 short int fill_user[50];
620 float uncor_singles[128];
622
624typedef struct ecat7_2Dscanheader {
626 short int data_type;
628 short int num_dimensions;
630 short int num_r_elements;
632 short int num_angles;
636 short int num_z_elements;
648 short int fill_gate[6];
658 short int scan_min;
660 short int scan_max;
670 float cor_singles[16];
672 float uncor_singles[16];
686 short int physical_planes[8];
688 short int fill_cti[83];
690 short int fill_user[50];
692
694typedef struct ecat7_2Dnormheader {
696 short int data_type;
698 short int num_dimensions;
700 short int num_r_elements;
702 short int num_angles;
704 short int num_z_elements;
710 float norm_min;
712 float norm_max;
720 short int storage_order;
722 short int span;
724 short int z_elements[64];
726 short int fill_cti[123];
728 short int fill_user[50];
730
732typedef struct ecat7_attenheader {
734 short int data_type;
736 short int num_dimensions;
740 short int num_r_elements;
742 short int num_angles;
744 short int num_z_elements;
758 float x_offset;
760 float y_offset;
762 float x_radius;
764 float y_radius;
778 float additional_atten_coeff[8];
782 short int storage_order;
784 short int span;
786 short int z_elements[64];
788 short int fill_cti[86];
790 short int fill_user[50];
792
794typedef struct ecat7_normheader {
796 short int data_type;
798 short int num_r_elements;
808 short int uld;
810 short int lld;
812 short int scatter_energy;
818 float ring_dtcor1[32];
820 float ring_dtcor2[32];
822 float crystal_dtcor[8];
824 short int span;
826 short int max_ring_diff;
828 short int fill_cti[48];
830 short int fill_user[50];
832
834typedef struct ecat7_polmapheader {
836 short int data_type;
838 short int polar_map_type;
840 short int num_rings;
842 short int sectors_per_ring[32];
844 float ring_position[32];
846 short int ring_angle[32];
848 short int start_angle;
850 short int long_axis_left[3];
852 short int long_axis_right[3];
854 short int position_data;
856 short int image_min;
858 short int image_max;
870 short int quant_units;
872 char annotation[40];
880 char polar_map_protocol[20];
882 char database_name[30];
884 short int fill_cti[27];
886 short int fill_user[27];
888
890typedef struct {
892 int id;
900
910
912typedef struct {
914 int frame;
916 int plane;
918 int gate;
920 int data;
922 int bed;
924/*****************************************************************************/
925
926/*****************************************************************************/
927/* ECAT 6.3 */
928
930#define MatBLKSIZE 512
932#define MatFirstDirBlk 2
933
935#define BYTE_TYPE 1
937#define VAX_I2 2
939#define VAX_I4 3
941#define VAX_R4 4
943#define IEEE_R4 5
945#define SUN_I2 6
947#define SUN_I4 7
948
950#define RAW_DATA 1
952#define IMAGE_DATA 2
954#define ATTN_DATA 3
956#define NORM_DATA 4
957
959#define ECAT63_SYSTEM_TYPE_DEFAULT 931
961extern char ecat63errmsg[128];
963extern int ECAT63_TEST;
964
966typedef struct {
975} MatDir;
976
978typedef struct {
985} MATRIXLIST;
986
988typedef struct {
990 int frame;
992 int plane;
994 int gate;
996 int data;
998 int bed;
999} Matval;
1000
1002typedef struct ecat63_mainheader {
1004 char ecat_format[14];
1006 char fill1[14];
1008 char original_file_name[20];
1010 short int sw_version;
1012 short int data_type;
1014 short int system_type;
1016 short int file_type;
1018 char node_id[10];
1032 char isotope_code[8];
1036 char radiopharmaceutical[32];
1046 short int wobble_speed;
1067 char study_name[12];
1069 char patient_id[16];
1071 char patient_name[32];
1075 char patient_age[10];
1077 char patient_height[10];
1079 char patient_weight[10];
1083 char physician_name[32];
1085 char operator_name[32];
1087 char study_description[32];
1091 short int bed_type;
1093 short int septa_type;
1095 char facility_name[20];
1098 short int num_planes;
1101 short int num_frames;
1104 short int num_gates;
1107 short int num_bed_pos;
1111 float bed_offset[15];
1123 char user_process_code[10];
1125 short int fill2[20];
1127
1129typedef struct ecat63_imageheader {
1131 char fill1[126];
1133 short int data_type;
1137 short int unused1;
1139 short int dimension_1;
1141 short int dimension_2;
1143 short int unused2[12];
1153 short int image_min;
1155 short int image_max;
1157 short int unused3[2];
1177 short int unused4[12];
1179 short int filter_code;
1187 short int unused5[23];
1199 short int unused6[30];
1203 short int unused7;
1205 short int quant_units;
1217 float filter_params[6];
1219 char annotation[40];
1221 short int fill2[26];
1223
1225typedef struct ecat63_scanheader {
1227 char fill1[126];
1229 short int data_type;
1231 short int unused1[2];
1233 short int dimension_1;
1235 short int dimension_2;
1237 short int smoothing;
1241 short int unused2[3];
1245 short int unused3[8];
1255 short int unused4;
1259 short int unused5[3];
1261 short int scan_min;
1263 short int scan_max;
1273 short int unused6[52];
1275 float cor_singles[16];
1277 float uncor_singles[16];
1291 short int fill2[22];
1293
1295typedef struct ecat63_normheader {
1297 char fill1[126];
1299 short int data_type;
1301 short int unused1[2];
1303 short int dimension_1;
1305 short int dimension_2;
1307 short int unused2[23];
1312 short int unused3[6];
1316 short int unused4[85];
1318 short int norm_hour;
1320 short int unused5;
1322 short int norm_minute;
1324 short int unused6;
1326 short int norm_second;
1328 short int unused7;
1330 short int norm_day;
1332 short int unused8;
1334 short int norm_month;
1336 short int unused9;
1338 short int norm_year;
1340 short int unused10;
1342 short int unused11[58];
1344
1346typedef struct ecat63_attnheader {
1348 char fill1[126];
1350 short int data_type;
1354 short int unused1;
1356 short int dimension_1;
1358 short int dimension_2;
1360 short int unused2[23];
1378 short int unused3[149];
1380
1382typedef struct matdirnode {
1392 struct matdirnode *next;
1393} MatDirNode ;
1394
1396typedef struct matdirlist {
1403} MatDirList;
1404
1406typedef struct matrixdata {
1410 char *shptr;
1421} MatrixData ;
1422
1424typedef struct matrix_file {
1430 FILE *fptr ;
1431} Matrix_file;
1432/*****************************************************************************/
1433
1434/*****************************************************************************/
1435/* SIF */
1436
1438extern char siferrmsg[128];
1440extern int SIF_TEST;
1441
1443typedef struct {
1445 time_t scantime;
1453 char studynr[MAX_STUDYNR_LEN+1];
1455 char isotope_name[8];
1457 double *x1;
1459 double *x2;
1461 double *prompts;
1463 double *randoms;
1465 double *trues;
1467 double *weights;
1468} SIF;
1469/*****************************************************************************/
1470
1471/*****************************************************************************/
1472/* IMG */
1473
1475#define IMG_STATUS_UNINITIALIZED 0
1477#define IMG_STATUS_INITIALIZED 1
1479#define IMG_STATUS_OCCUPIED 2
1481#define IMG_STATUS_ERROR 3
1482
1484#define IMG_ERR_OK 0
1486#define IMG_ERR_CALLING 1
1488#define IMG_ERR_OOM 2
1489
1491#define IMG_TYPE_UNKNOWN 0
1493#define IMG_TYPE_IMAGE 1
1495#define IMG_TYPE_RAW 2
1497#define IMG_TYPE_POLARMAP 3
1499#define IMG_TYPE_ATTN 4
1500
1502#define IMG_UNKNOWN 0
1504#define IMG_E63 1
1506#define IMG_E7 2
1508#define IMG_E7_2D 3
1510#define IMG_POLARMAP 9
1512#define IMG_ANA 11
1514#define IMG_ANA_L 12 /* little endian variant */
1516#define IMG_INTERFILE 21
1518#define IMG_NIFTI_1D 31 /* dual file format */
1520#define IMG_NIFTI_1S 32 /* single file format */
1522#define IMG_MICROPET 41
1524#define IMG_FLAT 61
1526#define IMG_DICOM 100
1527
1529#define IMG_DC_UNKNOWN 0
1531#define IMG_DC_CORRECTED 1
1533#define IMG_DC_NONCORRECTED 2
1534
1536#define IMG_MODALITY_UNKNOWN 0
1538#define IMG_MODALITY_PET 1
1540#define IMG_MODALITY_MRI 2
1542#define IMG_MODALITY_CT 3
1544#define IMG_MODALITY_SPECT 4
1545
1547#define SCANNER_UNKNOWN 0
1549#define SCANNER_ECAT931 12
1551#define SCANNER_ADVANCE 12096
1553#define SCANNER_HRPLUS 3
1555#define SCANNER_HRRT 4
1556/* these may change later */
1558#define SCANNER_MRI 5
1560#define SCANNER_STEVCT_PET 6
1562#define SCANNER_STEVCT_CT 7
1564#define SCANNER_DMI_PET 8
1565/* Concorde/MicropET scanners */
1567#define SCANNER_PRIMATE 2000
1569#define SCANNER_RODENT 2001
1571#define SCANNER_MICROPET2 2002
1573#define SCANNER_FOCUS_220 2500
1575#define SCANNER_FOCUS_120 2501
1577#define SCANNER_INVEON_DEDICATED_PET 5000
1579#define SCANNER_INVEON_MM_PET 5500
1581#define SCANNER_MR_PET_HEAD_INSERT 6000
1583#define SCANNER_TUEBINGEN_PET_MR 8000
1584
1586#define MAX_POLARMAP_NUM_RINGS 32
1587
1589enum {STATUS_OK,STATUS_FAULT,STATUS_NOMEMORY,STATUS_NOFILE,STATUS_UNKNOWNFORMAT,
1590 STATUS_UNSUPPORTED,STATUS_MISSINGMATRIX,STATUS_NOWRITEPERM,STATUS_DISKFULL,
1591 STATUS_NOMATLIST,STATUS_INVALIDMATLIST,STATUS_VARMATSIZE,STATUS_NOMAINHEADER,
1592 STATUS_NOSUBHEADER, STATUS_NOMATRIX, STATUS_UNSUPPORTEDAXIALCOMP,
1593 STATUS_NOIMGDATAFILE, STATUS_NOHEADERFILE, STATUS_INVALIDHEADER,
1594 STATUS_NOIMGDATA, STATUS_NOSIFDATA, STATUS_WRONGSIFDATA,
1595 STATUS_CANTWRITEIMGFILE, STATUS_CANTWRITEHEADERFILE, STATUS_WRONGFILETYPE,
1596 STATUS_CANNOTERASE, STATUS_CANNOTREAD, STATUS_CANNOTWRITE,
1597 STATUS_UNSUPPORTEDPOLARMAP, STATUS_INVALIDPOLARMAP};
1598
1600extern int IMG_TEST;
1601
1603typedef struct {
1605 int x;
1607 int y;
1609 int z;
1611 int f;
1612} IMG_PIXEL;
1613
1615typedef struct {
1617 long long int pxlNr;
1619 long long int _pxlNr;
1622} IMG_PIXELS;
1623
1625typedef struct {
1627 int x1;
1629 int x2;
1631 int y1;
1633 int y2;
1635 int z1;
1637 int z2;
1639 int f1;
1641 int f2;
1642} IMG_RANGE;
1643
1645typedef struct {
1647 int x;
1649 int y;
1651 int z;
1653 int t;
1654} VOXEL_4D;
1655
1657typedef struct {
1658
1659 /*
1660 * State of image
1661 */
1667 const char *statmsg;
1668
1669 /*
1670 * Information on the study
1671 */
1673 char unit;
1677 char studyNr[MAX_STUDYNR_LEN+1];
1679 char patientName[32];
1681 char patientID[16];
1683 char radiopharmaceutical[32];
1696 char userProcessCode[11];
1698 char studyDescription[32];
1699
1700 /*
1701 * Information on the image
1702 */
1704 char type;
1706 float zoom;
1714 float sizex;
1716 float sizey;
1718 float sizez;
1720 float gapx;
1722 float gapy;
1724 float gapz;
1741 short int xform[2];
1744 float quatern[18];
1747 float mt[12];
1750
1751 /*
1752 * Definitions for polar map
1753 */
1763 int polarmap_sectors_per_ring[MAX_POLARMAP_NUM_RINGS];
1766 float polarmap_ring_position[MAX_POLARMAP_NUM_RINGS];
1769 short int polarmap_ring_angle[MAX_POLARMAP_NUM_RINGS];
1772
1773 /*
1774 * Image data
1775 */
1776 /* Dimensions */
1778 unsigned short int dimt;
1780 unsigned short int dimx;
1782 unsigned short int dimy;
1784 unsigned short int dimz;
1786
1787 float *_pxl;
1789 float **_col;
1791 float ***_row;
1793 float ****_pln;
1795 float *_header;
1797 /* Pointers for data to be used */
1799 float ****m;
1801 float ****plane;
1803 float ***row;
1805 float **column;
1807 float *pixel;
1810
1811 /*
1812 * Frame times
1813 */
1815 float *start;
1817 float *end;
1819 float *mid;
1820
1821 /*
1822 * Frame weights
1823 */
1827 float *weight;
1829 float *sd;
1831 float *prompts;
1833 float *randoms;
1834
1835 /*
1836 * Decay correction factors for each frame
1837 */
1840
1843
1844} IMG;
1845/*****************************************************************************/
1846
1847/*****************************************************************************/
1848/* IMG units (deprecated) */
1850#define IMGUNIT_UNKNOWN CUNIT_UNKNOWN
1851#define IMGUNIT_CPS CUNIT_CPS
1852#define IMGUNIT_COUNTS CUNIT_COUNTS
1853#define IMGUNIT_KBQ_PER_ML CUNIT_KBQ_PER_ML
1854#define IMGUNIT_SEC_KBQ_PER_ML CUNIT_SEC_KBQ_PER_ML
1855#define IMGUNIT_PER_SEC CUNIT_PER_SEC
1856#define IMGUNIT_PER_MIN CUNIT_PER_MIN
1857#define IMGUNIT_ML_PER_ML CUNIT_ML_PER_ML
1858#define IMGUNIT_ML_PER_DL CUNIT_ML_PER_DL
1859#define IMGUNIT_ML_PER_ML_PER_MIN CUNIT_ML_PER_ML_PER_MIN
1860#define IMGUNIT_ML_PER_DL_PER_MIN CUNIT_ML_PER_DL_PER_MIN
1861#define IMGUNIT_UNITLESS CUNIT_UNITLESS
1862#define IMGUNIT_NCI_PER_ML CUNIT_NCI_PER_ML
1863#define IMGUNIT_MBQ_PER_ML CUNIT_MBQ_PER_ML
1864#define IMGUNIT_BQ_PER_ML CUNIT_BQ_PER_ML
1865#define IMGUNIT_UCI_PER_ML CUNIT_UCI_PER_ML
1866#define IMGUNIT_UMOL_PER_MIN_PER_100G CUNIT_UMOL_PER_MIN_PER_100G
1867#define IMGUNIT_MG_PER_MIN_PER_100G CUNIT_MG_PER_MIN_PER_100G
1869/*****************************************************************************/
1870
1871/*****************************************************************************/
1872/* Definitions for VOL, structure for 3D image volume */
1873
1875extern int VOL_TEST;
1876
1878typedef struct {
1880 int x;
1882 int y;
1884 int z;
1885} VOL_PIXEL;
1886
1888typedef struct {
1890 int x1;
1892 int x2;
1894 int y1;
1896 int y2;
1898 int z1;
1900 int z2;
1901} VOL_RANGE;
1902
1904typedef struct {
1908 char *statmsg;
1912 float sizex;
1914 float sizey;
1916 float sizez;
1918 unsigned short int dimx;
1920 unsigned short int dimy;
1922 unsigned short int dimz;
1924
1925 float *_vxl;
1927 float *_col;
1929 float **_row;
1931 float ***_pln;
1933
1934 float ***v;
1936 float ***plane;
1938 float **row;
1940 float *column;
1942 float *voxel;
1943} VOL;
1944
1946typedef struct {
1950 char *statmsg;
1954 float sizex;
1956 float sizey;
1958 float sizez;
1960 unsigned short int dimx;
1962 unsigned short int dimy;
1964 unsigned short int dimz;
1968
1969 short int *_vxl;
1971 short int *_col;
1973 short int **_row;
1975 short int ***_pln;
1977
1978 short int ***v;
1980 short int ***plane;
1982 short int **row;
1984 short int *column;
1986 short int *voxel;
1987} SVOL;
1988/*****************************************************************************/
1989
1990/*****************************************************************************/
1991/* MicroPET */
1992#ifndef MAX_MICROPET_LINE_LEN
1994#define MAX_MICROPET_LINE_LEN 1024
1995#endif
1997extern int MICROPET_TEST;
1998/*****************************************************************************/
1999
2000/*****************************************************************************/
2001/* NifTI */
2002
2004#define NIFTI_HEADER_SIZE 348
2006#define NIFTI_HEADER_EXTENDER_SIZE 4
2007
2009#define NIFTI_UNITS_UNKNOWN 0
2011#define NIFTI_UNITS_METER 1
2013#define NIFTI_UNITS_MM 2
2015#define NIFTI_UNITS_MICRON 4
2017#define NIFTI_UNITS_SEC 8
2019#define NIFTI_UNITS_MSEC 16
2021#define NIFTI_UNITS_USEC 24
2023#define NIFTI_UNITS_HERTZ 32
2025#define NIFTI_UNITS_PPM 40
2027#define NIFTI_UNITS_RADS 48
2028
2029
2031#define NIFTI_DT_NONE 0
2033#define NIFTI_DT_UNKNOWN 0
2035#define NIFTI_DT_BINARY 1
2037#define NIFTI_DT_UNSIGNED_CHAR 2
2039#define NIFTI_DT_SIGNED_SHORT 4
2041#define NIFTI_DT_SIGNED_INT 8
2043#define NIFTI_DT_FLOAT 16
2045#define NIFTI_DT_COMPLEX 32
2047#define NIFTI_DT_DOUBLE 64
2049#define NIFTI_DT_RGB 128
2051#define NIFTI_DT_ALL 255
2053#define NIFTI_DT_SIGNED_CHAR 256
2055#define NIFTI_DT_UNSIGNED_SHORT 512
2057#define NIFTI_DT_UNSIGNED_INT 768
2059#define NIFTI_DT_LONG_LONG 1024
2061#define NIFTI_DT_UNSIGNED_LONG_LONG 1280
2063#define NIFTI_DT_LONG_DOUBLE 1536
2065#define NIFTI_DT_DOUBLE_PAIR 1792
2067#define NIFTI_DT_LONG_DOUBLE_PAIR 2048
2069#define NIFTI_DT_RGBA 2304
2070
2071
2073#define NIFTI_INTENT_NONE 0
2075#define NIFTI_INTENT_CORREL 2
2077#define NIFTI_INTENT_TTEST 3
2079#define NIFTI_INTENT_FTEST 4
2081#define NIFTI_INTENT_ZSCORE 5
2083#define NIFTI_INTENT_CHISQ 6
2085#define NIFTI_INTENT_BETA 7
2087#define NIFTI_INTENT_BINOM 8
2089#define NIFTI_INTENT_GAMMA 9
2091#define NIFTI_INTENT_POISSON 10
2093#define NIFTI_INTENT_NORMAL 11
2095#define NIFTI_INTENT_FTEST_NONC 12
2097#define NIFTI_INTENT_CHISQ_NONC 13
2099#define NIFTI_INTENT_LOGISTIC 14
2101#define NIFTI_INTENT_LAPLACE 15
2103#define NIFTI_INTENT_UNIFORM 16
2105#define NIFTI_INTENT_TTEST_NONC 17
2107#define NIFTI_INTENT_WEIBULL 18
2109#define NIFTI_INTENT_CHI 19
2111#define NIFTI_INTENT_INVGAUSS 20
2113#define NIFTI_INTENT_EXTVAL 21
2115#define NIFTI_INTENT_PVAL 22
2117#define NIFTI_INTENT_LOGPVAL 23
2119#define NIFTI_INTENT_LOG10PVAL 24
2121#define NIFTI_INTENT_ESTIMATE 1001
2123#define NIFTI_INTENT_LABEL 1002
2125#define NIFTI_INTENT_NEURONAME 1003
2127#define NIFTI_INTENT_GENMATRIX 1004
2129#define NIFTI_INTENT_SYMMATRIX 1005
2131#define NIFTI_INTENT_DISPVECT 1006
2133#define NIFTI_INTENT_VECTOR 1007
2135#define NIFTI_INTENT_POINTSET 1008
2137#define NIFTI_INTENT_TRIANGLE 1009
2139#define NIFTI_INTENT_QUATERNION 1010
2141#define NIFTI_INTENT_DIMLESS 1011
2142
2144#define NIFTI_XFORM_UNKNOWN 0
2146#define NIFTI_XFORM_SCANNER_ANAT 1
2148#define NIFTI_XFORM_ALIGNED_ANAT 2
2150#define NIFTI_XFORM_TALAIRACH 3
2152#define NIFTI_XFORM_MNI_152 4
2153
2154
2155
2157typedef struct {
2161 char data_type[10];
2163 char db_name[18];
2167 short int session_error;
2172
2176 short int dim[8];
2184 short int intent_code;
2186 short int datatype;
2188 short int bitpix;
2190 short int slice_start;
2192 float pixdim[8];
2200 short int slice_end;
2206 float cal_max;
2208 float cal_min;
2212 float toffset;
2217
2219 char descrip[80];
2221 char aux_file[24];
2224 short int qform_code;
2226 short int sform_code;
2240 float srow_x[4];
2242 float srow_y[4];
2244 float srow_z[4];
2246 char intent_name[16];
2250 char magic[4];
2252
2256typedef struct {
2260 char extension[4];
2262
2272/*****************************************************************************/
2273
2274/*****************************************************************************/
2275/* analyze */
2276extern int anaExists(const char *dbname);
2277extern int anaExistsNew(const char *dbname, char *hdrfile, char *imgile, char *siffile);
2278extern int anaRemove(const char *dbname);
2279extern void anaRemoveFNameExtension(char *fname);
2280extern int anaDatabaseExists(const char *dbname, char *hdrfile, char *imgfile, char *siffile);
2281extern int anaMakeSIFName(const char *dbname, char *siffile);
2282extern int anaFlipping();
2283extern int anaReadHeader(char *filename, ANALYZE_DSR *h);
2284extern int anaReadImagedata(FILE *fp, ANALYZE_DSR *h, int frame, float *data);
2285extern int anaWriteHeader(char *filename, ANALYZE_DSR *h);
2286extern int anaPrintHeader(ANALYZE_DSR *h, FILE *fp);
2287extern int anaEditHeader(ANALYZE_DSR *h, char *field, char *value);
2288/*****************************************************************************/
2289
2290/*****************************************************************************/
2291/* ecat7 */
2292
2293/* Read functions */
2294extern int ecat7ReadMainheader(FILE *fp, ECAT7_mainheader *h);
2295extern int ecat7ReadImageheader(FILE *fp, int blk, ECAT7_imageheader *h);
2296extern int ecat7ReadAttenheader(FILE *fp, int blk, ECAT7_attenheader *h);
2297extern int ecat7ReadPolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h);
2298extern int ecat7ReadNormheader(FILE *fp, int blk, ECAT7_normheader *h);
2299extern int ecat7ReadScanheader(FILE *fp, int blk, ECAT7_scanheader *h);
2300extern int ecat7Read2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h);
2301extern int ecat7Read2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h);
2302extern int ecat7ReadMatrixdata(FILE *fp, int start_block, int block_nr, char *data, int dtype);
2303extern float ecat7rFloat(void *bufi, int isvax, int islittle);
2304extern int ecat7rInt(void *bufi, int isvax, int islittle);
2305extern int ecat7ReadImageMatrix(FILE *fp, int first_block, int last_block,
2306 ECAT7_imageheader *h, float **fdata);
2307extern int ecat7Read2DScanMatrix(FILE *fp, int first_block, int last_block,
2308 ECAT7_2Dscanheader *h, float **fdata);
2309extern int ecat7ReadScanMatrix(FILE *fp, int first_block, int last_block,
2310 ECAT7_scanheader *h, float **fdata);
2311extern int ecat7ReadPolarmapMatrix(FILE *fp, int first_block, int last_block,
2312 ECAT7_polmapheader *h, float **fdata);
2313extern int ecat7pxlbytes(short int data_type);
2314
2315/* Matrix list functions */
2316extern void ecat7InitMatlist(ECAT7_MATRIXLIST *mlist);
2317extern void ecat7EmptyMatlist(ECAT7_MATRIXLIST *mlist);
2318extern int ecat7ReadMatlist(FILE *fp, ECAT7_MATRIXLIST *ml, int verbose);
2319extern void ecat7PrintMatlist(ECAT7_MATRIXLIST *ml);
2320extern int ecat7EnterMatrix(FILE *fp, int matrix_id, int block_nr);
2321extern int ecat7_val_to_id(int frame, int plane, int gate, int data, int bed);
2322extern void ecat7_id_to_val(int matrix_id, ECAT7_Matval *matval);
2325extern int ecat7CheckMatlist(ECAT7_MATRIXLIST *ml);
2326extern int ecat7DeleteLateFrames(ECAT7_MATRIXLIST *ml, int frame_nr);
2327extern int ecat7GetPlaneAndFrameNr(
2328 ECAT7_MATRIXLIST *mlist, ECAT7_mainheader *h, int *plane_nr, int *frame_nr);
2329extern int ecat7GetMatrixBlockSize(ECAT7_MATRIXLIST *mlist, int *blk_nr);
2330extern int ecat7GetNums(ECAT7_MATRIXLIST *ml, ECAT7_mainheader *mh, FILE *fp,
2331 short int *num_planes, short int *num_frames, short int *num_gates, short int *num_bed_pos);
2332extern int ecat7GatherMatlist(ECAT7_MATRIXLIST *ml, short int do_planes,
2333 short int do_frames, short int do_gates, short int do_beds);
2334
2335/* Write functions */
2336extern int ecat7WriteMainheader(FILE *fp, ECAT7_mainheader *h);
2337extern int ecat7WriteImageheader(FILE *fp, int blk, ECAT7_imageheader *h);
2338extern int ecat7WriteAttenheader(FILE *fp, int blk, ECAT7_attenheader *h);
2339extern int ecat7WritePolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h);
2340extern int ecat7WriteNormheader(FILE *fp, int blk, ECAT7_normheader *h);
2341extern int ecat7WriteScanheader(FILE *fp, int blk, ECAT7_scanheader *h);
2342extern int ecat7Write2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h);
2343extern int ecat7Write2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h);
2344extern int ecat7WritePolarmapMatrix(FILE *fp, int matrix_id, ECAT7_polmapheader *h, float *fdata);
2345extern int ecat7WriteMatrixdata(FILE *fp, int start_block, char *data, long long pxl_nr, int pxl_size);
2346/*extern void ecat7wFloat(float *bufi, void *bufo, int tovax, int islittle);*/
2347/*extern void ecat7wInt(int *bufi, void *bufo, int tovax, int islittle);*/
2348extern FILE *ecat7Create(const char *fname, ECAT7_mainheader *h);
2349extern int ecat7WriteImageMatrix(FILE *fp, int matrix_id, ECAT7_imageheader *h, float *fdata);
2350extern int ecat7Write2DScanMatrix(FILE *fp, int matrix_id, ECAT7_2Dscanheader *h, float *fdata);
2351extern int ecat7WriteScanMatrix(FILE *fp, int matrix_id, ECAT7_scanheader *h, float *fdata);
2352extern int ecat7_is_scaling_needed(float amax, float *data, long long nr);
2353
2354/* Printing functions */
2355extern void ecat7PrintMainheader(ECAT7_mainheader *h, FILE *fp);
2356extern void ecat7PrintImageheader(ECAT7_imageheader *h, FILE *fp);
2357extern void ecat7PrintScanheader(ECAT7_scanheader *h, FILE *fp);
2358extern void ecat7PrintAttenheader(ECAT7_attenheader *h, FILE *fp);
2359extern void ecat7PrintPolmapheader(ECAT7_polmapheader *h, FILE *fp);
2360extern void ecat7PrintNormheader(ECAT7_normheader *h, FILE *fp);
2361extern void ecat7Print2DScanheader(ECAT7_2Dscanheader *h, FILE *fp);
2362extern void ecat7Print2DNormheader(ECAT7_2Dnormheader *h, FILE *fp);
2363extern int ecat7PrintSubheader(ECAT7_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp);
2364
2365/* Descriptive strings for printing */
2366extern char* ecat7filetype(short int file_type);
2367extern char* ecat7acquisitiontype(short int acquisition_type);
2368extern char* ecat7datatype(short int data_type);
2369
2370/* Header edit functions */
2371extern int ecat7EditMHeader(ECAT7_mainheader *h, char *field, char *value, int verbose);
2372extern int ecat7EditSHeader(ECAT7_scanheader *h, char *field, char *value, int verbose);
2373extern int ecat7EditVHeader(ECAT7_imageheader *h, char *field, char *value, int verbose);
2374/*****************************************************************************/
2375
2376/*****************************************************************************/
2377/* ECAT 6.3 */
2378
2379/* ECAT 6.3 Read functions */
2380extern int ecat63ReadMainheader(FILE *fp, ECAT63_mainheader *h);
2381extern int ecat63ReadImageheader(FILE *fp, int blk, ECAT63_imageheader *h, int verbose, char *errmsg);
2382extern int ecat63ReadScanheader(FILE *fp, int blk, ECAT63_scanheader *h, int verbose, char *errmsg);
2383extern int ecat63ReadAttnheader(FILE *fp, int blk, ECAT63_attnheader *h, int verbose, char *errmsg);
2384extern int ecat63ReadNormheader(FILE *fp, int blk, ECAT63_normheader *h, int verbose, char *errmsg);
2385extern int ecat63ReadMatdata(FILE *fp, int strtblk, int blkNr, char *data, int dtype);
2386extern int ecat63ReadImageMatrix(FILE *fp, int strtblk, int lastblk, ECAT63_imageheader *h, float **f);
2387extern int ecat63ReadScanMatrix(FILE *fp, int strtblk, int lastblk, ECAT63_scanheader *h, float **f);
2388extern int ecat63ReadAttnMatrix(FILE *fp, int strtblk, int lastblk, ECAT63_attnheader *h, float **f);
2389extern float ecat63rFloat(void *bufi, int isvax, int islittle);
2390extern int ecat63rInt(void *bufi, int isvax, int islittle);
2391extern int ecat63pxlbytes(short int data_type);
2392
2393/* ECAT 6.3 Matrix list functions */
2394extern void ecat63InitMatlist(MATRIXLIST *mlist);
2395extern void ecat63EmptyMatlist(MATRIXLIST *mlist);
2396extern int ecat63ReadMatlist(FILE *fp, MATRIXLIST *ml, int verbose);
2397extern void ecat63PrintMatlist(MATRIXLIST *ml);
2398extern int mat_numcod(int frame, int plane, int gate, int data, int bed);
2399extern void mat_numdoc(int matnum, Matval *matval);
2400extern int ecat63Matenter(FILE *fp, int matnum, int blkNr);
2401extern void ecat63SortMatlistByPlane(MATRIXLIST *ml);
2402extern void ecat63SortMatlistByFrame(MATRIXLIST *ml);
2403extern int ecat63CheckMatlist(MATRIXLIST *ml);
2404extern int ecat63DeleteLateFrames(MATRIXLIST *ml, int frame_nr);
2405extern int ecat63GetMatrixBlockSize(MATRIXLIST *mlist, int *blk_nr);
2406extern int ecat63GetPlaneAndFrameNr(
2407 MATRIXLIST *mlist, ECAT63_mainheader *h, int *plane_nr, int *frame_nr);
2408extern int ecat63GetNums(
2409 MATRIXLIST *ml, short int *num_planes, short int *num_frames,
2410 short int *num_gates, short int *num_bed_pos);
2411extern int ecat63GatherMatlist(
2412 MATRIXLIST *ml, short int do_planes, short int do_frames,
2413 short int do_gates, short int do_beds);
2414
2415/* ECAT 6.3 Write functions */
2416extern int ecat63WriteMainheader(FILE *fp, ECAT63_mainheader *h);
2417extern int ecat63WriteImageheader(FILE *fp, int block, ECAT63_imageheader *h);
2418extern int ecat63WriteScanheader(FILE *fp, int block, ECAT63_scanheader *h);
2419extern int ecat63WriteAttnheader(FILE *fp, int block, ECAT63_attnheader *h);
2420extern int ecat63WriteNormheader(FILE *fp, int block, ECAT63_normheader *h);
2421extern FILE *ecat63Create(const char *fname, ECAT63_mainheader *h);
2422extern int ecat63WriteMatdata(FILE *fp, int strtblk, char *data, long long pxlNr, int pxlSize);
2423extern int ecat63WriteScan(FILE *fp, int matnum, ECAT63_scanheader *h, void *data);
2424extern int ecat63WriteImage(FILE *fp, int matnum, ECAT63_imageheader *h, void *data);
2425extern int ecat63WriteNorm(FILE *fp, int matnum, ECAT63_normheader *h, void *data);
2426extern int ecat63WriteAttn(FILE *fp, int matnum, ECAT63_attnheader *h, void *data);
2427extern int ecat63WriteImageMatrix(FILE *fp, int matnum, ECAT63_imageheader *h, float *fdata);
2428extern int ecat63WriteScanMatrix(FILE *fp, int matnum, ECAT63_scanheader *h, float *fdata);
2429extern void ecat63wFloat(float *bufi, void *bufo, int tovax, int islittle);
2430extern void ecat63wInt(int *bufi, void *bufo, int tovax, int islittle);
2431extern int ecat63_is_scaling_needed(float amax, float *data, long long nr);
2432extern struct tm* ecat63ScanstarttimeToTm(const ECAT63_mainheader *h, struct tm *tm);
2433extern time_t ecat63Scanstarttime(const ECAT63_mainheader *h);
2434
2435/* ECAT 6.3 Printing functions */
2436extern void ecat63PrintMainheader(ECAT63_mainheader *h, FILE *fp);
2437extern void ecat63PrintImageheader(ECAT63_imageheader *h, FILE *fp);
2438extern void ecat63PrintScanheader(ECAT63_scanheader *h, FILE *fp);
2439extern void ecat63PrintAttnheader(ECAT63_attnheader *h, FILE *fp);
2440extern void ecat63PrintNormheader(ECAT63_normheader *h, FILE *fp);
2441extern int ecat6PrintSubheader(ECAT63_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp);
2442extern char *ecat63Datatype(short int dtype);
2443extern char *ecat63Unit(short int dunit);
2444extern void float2parts(float *buf);
2445extern char* ecat63ScanstarttimeInt(const ECAT63_mainheader *h, char *buf);
2446
2447/* Header edit functions */
2450extern int ecat63EditMHeader(ECAT63_mainheader *h, char *field, char *value, int verbose);
2451/*****************************************************************************/
2452
2453/*****************************************************************************/
2454/* IMG data functions */
2455
2456/* Initialization and memory handling of img data */
2457extern void imgInit(IMG *image);
2458extern void imgEmpty(IMG *image);
2459extern int imgAllocate(IMG *image, int planes, int rows, int columns, int frames);
2460extern int imgAllocateWithHeader(IMG *image, int planes, int rows, int columns, int frames, IMG *image_from);
2461extern int imgDup(IMG *img1, IMG *img2);
2462
2463/* Retrieving image information */
2464extern char *imgStatus(int status_index);
2465extern void imgSetStatus(IMG *img, int status_index);
2466extern void imgInfo(IMG *image);
2467extern int imgCopyhdr(IMG *image1, IMG *image2);
2468extern int imgExtractRange(IMG *img1, IMG_RANGE r, IMG *img2);
2469extern int imgExistentTimes(IMG *img);
2470extern int imgExistentCounts(IMG *img);
2471extern unsigned long long imgNaNs(IMG *img, int fix);
2472/*****************************************************************************/
2473
2474/*****************************************************************************/
2475/* IMG vs SIF */
2476extern int sif2img(
2477 SIF *sif, IMG *img, int copy_header, int copy_frames, int copy_counts, int verbose
2478);
2479extern int img2sif(
2480 IMG *img, SIF *sif, int copy_header, int copy_frames, int copy_counts, int verbose
2481);
2482/*****************************************************************************/
2483
2484/*****************************************************************************/
2485/* IMG decay correction */
2486extern int imgDecayCorrection(IMG *img, int mode);
2487extern char *imgIsotope(IMG *img);
2488extern int imgSetDecayCorrFactors(IMG *image, int mode);
2489extern int imgBranchingCorrection(IMG *image, int mode, int verbose, char *status);
2490/*****************************************************************************/
2491
2492/*****************************************************************************/
2493/* IMG file i/o */
2494
2495/* General */
2496extern int imgRead(const char *fname, IMG *img);
2497//int extern imgReadMainHeader(const char *fname, IMG *img);
2498extern int imgWrite(const char *fname, IMG *img);
2499extern int imgReadHeader(const char *fname, IMG *img, int format);
2500//extern int imgReadNextFrame(char *fname, IMG *img);
2501extern int imgReadFrame(const char *fname, int frame_to_read, IMG *img, int frame_index);
2502extern int imgWriteFrame(const char *fname, int frame_to_write, IMG *img, int frame_index);
2503extern void imgFormatFromFName(IMG *img, const char *fname);
2504extern int imgFormatDetermine(
2505 const char *fname, char *basename, char *hdrfile, char *imgfile, char *siffile, int *file_format,
2506 int *scanner, int *type, int *modality, int verbose
2507);
2508
2509/* ECAT 6.3 and IMG */
2510extern int ecat63ReadAllToImg(const char *fname, IMG *img);
2511extern int ecat63WriteAllImg(const char *fname, IMG *img);
2512extern int ecat63ReadPlaneToImg(const char *fname, IMG *img);
2513extern int ecat63AddImg(const char *fname, IMG *img);
2514extern void imgGetEcat63MHeader(IMG *img, ECAT63_mainheader *h);
2515extern void imgSetEcat63MHeader(IMG *img, ECAT63_mainheader *h);
2518extern int imgReadEcat63Header(const char *fname, IMG *img);
2519extern int imgReadEcat63FirstFrame(const char *fname, IMG *img);
2520extern int imgReadEcat63Frame(const char *fname, int frame_to_read, IMG *img, int frame_index);
2521extern int imgWriteEcat63Frame(const char *fname, int frame_to_write, IMG *img, int frame_index);
2522extern void imgSetEcat63SHeader(IMG *img, void *h);
2523
2524/* ECAT 7.x and IMG */
2525extern int imgReadEcat7(const char *fname, IMG *img);
2526extern int imgWriteEcat7(const char *fname, IMG *img);
2527extern int imgWrite2DEcat7(const char *fname, IMG *img);
2528extern int imgWritePolarmap(const char *fname, IMG *img);
2529
2530extern void imgGetEcat7MHeader(IMG *img, ECAT7_mainheader *h);
2531extern void imgSetEcat7MHeader(IMG *img, ECAT7_mainheader *h);
2532extern int imgReadEcat7Header(const char *fname, IMG *img);
2533extern int imgEcat7Supported(ECAT7_mainheader *h);
2534extern int imgReadEcat7Frame(const char *fname, int frame_to_read, IMG *img, int frame_index);
2535extern int imgReadEcat7FirstFrame(const char *fname, IMG *img);
2537extern int imgWriteEcat7Frame(const char *fname, int frame_to_write, IMG *img, int frame_index);
2538extern void imgSetEcat7SHeader(IMG *img, void *h);
2539
2540/* Analyze format and IMG */
2541extern int imgReadAnalyze(const char *dbname, IMG *img);
2542extern int imgWriteAnalyze(const char *dbname, IMG *img);
2543extern int imgReadAnalyzeHeader(const char *dbname, IMG *img);
2544extern int imgGetAnalyzeHeader(IMG *img, ANALYZE_DSR *h);
2545extern int imgSetAnalyzeHeader(IMG *img, const char *dbname, ANALYZE_DSR *h, float fmin, float fmax);
2546extern int imgReadAnalyzeFrame(const char *dbname, int frame_to_read, IMG *img, int frame_index);
2547extern int imgReadAnalyzeFirstFrame(const char *fname, IMG *img);
2548extern int imgWriteAnalyzeFrame(
2549 const char *fname, int frame_to_write, IMG *img, int frame_index, float fmin, float fmax
2550);
2551
2552/* MicroPET format and IMG */
2553extern int imgMicropetToEcat7(char *upetname, char *ecatfile, int verbose);
2554extern int imgMicropetPETToEcat7(FILE *fph, FILE *fpi, char *ecatfile, int verbose);
2555extern int imgMicropetCTToEcat7(FILE *fph, FILE *fpi, char *ecatfile, int verbose);
2556extern int imgGetMicropetMainHeader(FILE *fp, IMG *img, float *calibration_factor, int verbose);
2557extern int imgGetMicropetFrameHeader(FILE *fp, IMG *img, int frame_index, int verbose);
2558extern int imgGetMicropetSIF(FILE *fp, SIF *sif);
2559extern int imgGetMicropetHeader(IMG *img);
2560extern int imgReadMicropetHeader(const char *dbname, IMG *img);
2561extern int imgReadMicropetFrame(const char *fname, int frame_to_read, IMG *img, int frame_index);
2562extern int imgReadMicropetFirstFrame(const char *fname, IMG *img);
2563extern int imgReadMicropet(const char *fname, IMG *img);
2564
2565/* NifTI and IMG */
2566extern int imgReadNifti(const char *filename, IMG *img, int verbose);
2567extern int imgReadNiftiFirstFrame(const char *filename, IMG *img, int verbose);
2568extern int imgReadNiftiHeader(const char *filename, IMG *img, int verbose);
2569extern int imgGetNiftiHeader(IMG *img, NIFTI_DSR *h, int verbose);
2570extern int imgReadNiftiFrame(
2571 const char *filename, int frame_to_read, IMG *img, int frame_index, int verbose
2572);
2573extern int imgSetNiftiHeader(
2574 IMG *img, const char *dbname, NIFTI_DSR *dsr, float fmin, float fmax, int verbose
2575);
2576extern int imgWriteNiftiFrame(
2577 const char *dbname, int frame_to_write, IMG *img, int frame_index,
2578 float fmin, float fmax, int verbose
2579);
2580extern int imgWriteNifti(const char *dbname, IMG *img, int save_sif, int verbose);
2581/*****************************************************************************/
2582
2583/*****************************************************************************/
2584/* imgcomp */
2585extern int imgMatch(IMG *img1, IMG *img2, float accuracy);
2586extern int imgMatchMatrix(IMG *img1, IMG *img2, double accuracy);
2587extern int imgMatchHeader(IMG *img1, IMG *img2);
2588extern int imgMatchTransform(IMG *img1, IMG *img2);
2589extern int imgMatchFrames(IMG *img1, IMG *img2);
2590extern int imgMatchPlanes(IMG *img1, IMG *img2);
2591extern int imgMaxDifference(
2592 IMG *img1, IMG *img2, VOXEL_4D *absdiff, float *abs_max, VOXEL_4D *reldiff, float *rel_max
2593);
2594extern int imgSS(IMG *img1, IMG *img2, double *ss);
2595extern int imgMatchMatrixSize(IMG *img1, IMG *img2);
2596/*****************************************************************************/
2597
2598/*****************************************************************************/
2599/* imgminmax */
2600extern int imgMax(IMG *img, float *maxvalue);
2601extern int imgAbsMax(IMG *img, float *maxvalue);
2602extern int imgRangeMinMax(
2603 IMG *img, IMG_RANGE *r, IMG_PIXEL *maxp, float *maxv, IMG_PIXEL *minp, float *minv
2604);
2605extern int imgMinMax(IMG *img, float *minvalue, float *maxvalue);
2606extern int imgFrameMinMax(IMG *img, int frame, float *minvalue, float *maxvalue);
2607extern int imgReadMinMax(const char *fname, float *fmin, float *fmax);
2608extern int imgSmoothMax(IMG *img, float *maxvalue, IMG_PIXEL *p);
2609extern int imgGetPeak(IMG *img, float beforeTime, IMG_PIXEL *p, int verbose);
2610extern int imgGetMaxFrame(IMG *img, IMG *mimg, int verbose);
2611extern int imgGetMaxTime(IMG *img, IMG *mimg, const int w, int verbose);
2612extern int imgAvg(IMG *img, IMG_RANGE *r, float *avg);
2613extern float f_kth_smallest(float *data, long long int n, long long int k);
2614extern float fmedian(float *data, long long int n);
2615extern float fmean(float *data, long long int n, float *sd);
2616extern void fMinMaxFin(float *data, long long int n, float *fmin, float *fmax);
2617/*****************************************************************************/
2618
2619/*****************************************************************************/
2620/* imgunits */
2621extern int imgUnitId(char *unit);
2622extern void imgUnitFromEcat(IMG *img, int ecat_unit);
2623extern void imgUnitFromEcat7(IMG *img, ECAT7_mainheader *h);
2624extern int imgUnitToEcat6(IMG *img);
2625extern void imgUnitToEcat7(IMG *img, ECAT7_mainheader *h);
2626extern char *imgUnit(int dunit);
2627extern int imgSetUnit(IMG *img, char *unit);
2628/*****************************************************************************/
2629
2630/*****************************************************************************/
2631/* interfile */
2632extern int interfile_read(char headerName[256], char searchWord[256],
2633 char returnValue[256], char errorMessage[300]);
2634extern int interfileIsHeader(const char *hdrfile, char *imgfile);
2635extern int interfileExists(
2636 const char *fname, char *hdrfile, char *imgfile, int verbose);
2637/*****************************************************************************/
2638
2639/*****************************************************************************/
2640/* micropet */
2641extern int upetHeaderReadParameter(FILE *fp, char *parameter, char *value);
2642extern int upetIsHeader(char *hdrfile);
2643extern int upetExists(const char *upetname, char *hdrfile, char *imgfile, int verbose);
2644extern int upetGetImageDimensions(FILE *fp, int *z, int *x, int *y, int *f);
2645extern int upetScanStart(FILE *fp, time_t *scant);
2646extern int upetReadImagedata(FILE *fp, IFT *ift, int frame, float *data);
2647/*****************************************************************************/
2648
2649/*****************************************************************************/
2650/* nifti */
2651extern int niftiExists(
2652 const char *dbname, char *hdrfile, char *imgile, char *siffile,
2653 NIFTI_DSR *header, int verbose, char *status
2654);
2655extern int niftiCreateFNames(
2656 const char *filename, char *hdrfile, char *imgfile, char *siffile,
2657 int fileformat
2658);
2659extern int niftiRemove(
2660 const char *dbname, int fileformat, int verbose
2661);
2662extern int niftiReadHeader(
2663 char *filename, NIFTI_DSR *h, int verbose, char *status
2664);
2665extern int niftiPrintHeader(NIFTI_DSR *h, FILE *fp);
2666extern void niftiRemoveFNameExtension(char *fname);
2667extern int niftiReadImagedata(
2668 FILE *fp, NIFTI_DSR *h, int frame, float *data, int verbose, char *status
2669);
2670extern int niftiWriteHeader(
2671 char *filename, NIFTI_DSR *dsr, int verbose, char *status
2672);
2673/*****************************************************************************/
2674
2675/*****************************************************************************/
2676/* sif */
2677//extern void libsif_printdate(FILE *fp);
2678extern int sifRead(char *filename, SIF *data);
2679extern int sifWrite(SIF *data, char *filename);
2680extern void sifPrint(SIF *data);
2681extern void sifEmpty(SIF *data);
2682extern void sifInit(SIF *data);
2683extern int sifSetmem(SIF *data, int frameNr);
2684extern void sifWeight(SIF *data, double halflife);
2685extern void sifWeightByFrames(SIF *data, double halflife);
2686extern void sifWeightNorm(SIF *data);
2687extern void sifModerateTrues(SIF *sif, double limit);
2688extern void sifModerateWeights(SIF *sif, double limit);
2689extern int sifExistentCounts(SIF *sif);
2690/* Deprecated */
2692#define readSIF sifRead
2693#define writeSIF sifWrite
2694#define printSIF sifPrint
2695#define emptySIF sifEmpty
2696#define weightSIF sifWeight
2697#define initSIF sifInit
2698#define setmemSIF sifSetmem
2700/*****************************************************************************/
2701
2702/*****************************************************************************/
2703/* ecat7ift */
2705typedef struct {
2707 int mnum;
2713 float *f;
2714} ECAT_MATRIX;
2715
2717typedef struct {
2721 int nr;
2724} ECAT_HEADERS;
2725/* Functions */
2726extern void ematInitiate(ECAT_MATRIX *emat);
2727extern void ehdrInitiate(ECAT_HEADERS *ehdr);
2728extern void ematEmpty(ECAT_MATRIX *emat);
2729extern void ehdrEmpty(ECAT_HEADERS *ehdr);
2730extern int ehdrAllocate(ECAT_HEADERS *ehdr, int nr);
2731extern int ecat7MHeaderToIFT(ECAT7_mainheader *h, IFT *ift, int verbose);
2732extern int ecat7MainheaderFromIFT(ECAT7_mainheader *h, IFT *ift, int verbose);
2733extern int ecat7ImageheaderToIFT(ECAT7_imageheader *h, IFT *ift, int verbose);
2734extern int ecat7ScanheaderToIFT(ECAT7_scanheader *h, IFT *ift, int verbose);
2735extern int ecat7ReadSubheaderToIFT(FILE *fp, ECAT7_mainheader *h, int strtblk,
2736 IFT *ift, int verbose);
2737extern int ecat7WriteSubheaderFromIFT(FILE *fp, ECAT7_mainheader *h, int strtblk,
2738 IFT *ift, int verbose);
2739extern int ecat7ReadHeaders(const char *fname, ECAT_HEADERS *ehdr, int verbose);
2740extern int ecat7WriteHeaders(const char *fname, ECAT_HEADERS *ehdr, int verbose);
2741/*****************************************************************************/
2742
2743/*****************************************************************************/
2744/* ird */
2745extern int string_to_xyzf(const char *str, IMG_PIXEL *v);
2746extern int irdReorder(IMG_RANGE *img_range);
2747extern int irdRead(char *irdfile, IMG_RANGE *img_range, char *status);
2748extern int irdCheck(IMG_RANGE *r, IMG *img);
2749/*****************************************************************************/
2750
2751/*****************************************************************************/
2752/* vol */
2753/* 4-byte floats */
2754extern void volInit(VOL *vol);
2755extern void volEmpty(VOL *vol);
2756extern int volAllocate(VOL *vol, int planes, int rows, int columns);
2757extern int img2vol(IMG *img, VOL *vol, int frame);
2758extern int vol2img(VOL *vol, IMG *img, int frame);
2759extern void volInfo(VOL *vol, FILE *fp);
2760extern void volContents(VOL *vol, VOL_RANGE r, FILE *fp);
2761extern int volMax(
2762 VOL *vol, VOL_RANGE *r,
2763 VOL_PIXEL *maxp, float *maxv, VOL_PIXEL *minp, float *minv
2764);
2765extern int volAvg(VOL *vol, VOL_RANGE *r, float *avg);
2766/* 2-byte short ints */
2767extern void svolInit(SVOL *svol);
2768extern void svolEmpty(SVOL *svol);
2769extern int svolAllocate(SVOL *svol, int planes, int rows, int columns);
2770extern int img2svol(IMG *img, SVOL *svol, int frame);
2771extern int svol2img(SVOL *svol, IMG *img, int frame);
2772extern void svolInfo(SVOL *svol, FILE *fp);
2773/* General */
2774extern int vrdReorder(VOL_RANGE *vol_range);
2775extern int vrdVxlNr(VOL_RANGE *vol_range);
2776extern int vrd2vol(VOL_RANGE *r, VOL *vol, float in, float out, char *status);
2777extern int vrdRead(char *vdffile, VOL_RANGE *vol_range, char *status);
2778extern int string_to_xyz(char *str, int *x, int *y, int *z);
2779/*****************************************************************************/
2780
2781/*****************************************************************************/
2782/* pixel */
2783extern void pxlInit(IMG_PIXELS *pxl);
2784extern void pxlFree(IMG_PIXELS *pxl);
2785extern int pxlAllocate(IMG_PIXELS *pxl, long long int pxlNr);
2786extern int pxlAllocateMore(IMG_PIXELS *pxl, long long int pxlNr);
2787extern int pxlMakeRoom(IMG_PIXELS *list, long long int i, long long int n);
2788extern int pxlAdd(IMG_PIXELS *list, IMG_PIXEL *pxl);
2789extern int pxlGet(IMG_PIXELS *list, long long int i, IMG_PIXEL *pxl);
2790extern long long int pxlAddFromMask(IMG_PIXELS *list, IMG *img);
2791extern void pxlMove(IMG_PIXELS *list, long long int from, long long int to);
2792extern int pxlRm(IMG_PIXELS *list, long long int index);
2793extern long long int pxlRmDuplicates(IMG_PIXELS *list);
2794extern int pxlWrite(IMG_PIXELS *pxl, FILE *fp, char *status);
2795extern int pxlRead(IMG_PIXELS *pxl, const char *fname, char *status);
2796/*****************************************************************************/
2797
2798/*****************************************************************************/
2799/* DICOM */
2800
2802typedef struct DCMTAG {
2806 unsigned short int group;
2808 unsigned short int element;
2809} DCMTAG;
2810
2840
2881
2908
2910typedef struct DCMFILE {
2912 char filename[FILENAME_MAX];
2914 FILE *fp;
2919} DCMFILE;
2920
2924typedef struct DCMMATRIX {
2929 char acqDate[16];
2931 char acqTime[16];
2934 unsigned int frame;
2936 unsigned int plane;
2940 double frameDur;
2941} DCMMATRIX;
2942
2944typedef struct DCMML {
2946 unsigned int nr;
2948 unsigned int anr;
2951} DCMML;
2952/*****************************************************************************/
2953
2954/*****************************************************************************/
2955/* dcm */
2956extern int dcmVerifyMagic(const char *filename, FILE *fp);
2957extern unsigned char dcmVRReserved(dcmvr id);
2958extern dcmvr dcmVRId(const char *s);
2959extern char *dcmVRName(dcmvr id);
2960extern size_t dcmVRVLength(dcmvr id);
2961extern char *dcmVRDescr(dcmvr id);
2962extern char *dcmDA2intl(const char *orig, char *intl);
2963extern char *dcmTM2intl(const char *orig, char *intl);
2964extern char *dcmDT2intl(const char *orig, char *intl);
2965extern unsigned int dcmSOPIdentify(const char *s);
2966extern char *dcmSOPName(unsigned int i);
2967extern char *dcmSOPUID(unsigned int i);
2968extern char *dcmSOPUIDName(const char *s);
2969extern dcmtruid dcmTrUID(const char *s);
2970extern char *dcmTrUIDDescr(dcmtruid id);
2971extern char *dcmTrUIDString(dcmtruid id);
2972extern dcmtruid dcmReadTransferSyntaxUID(FILE *fp);
2973extern int dcmReadFileTag(FILE *fp, DCMTAG *tag);
2974extern int dcmWriteFileTag(FILE *fp, DCMTAG *tag);
2975extern int dcmWriteFileSQDelimItem(FILE *fp);
2976extern int dcmWriteFileSQItemDelimTag(FILE *fp);
2977extern dcmvr dcmReadFileVR(FILE *fp, char *vrstr);
2978extern unsigned int dcmReadFileVL(FILE *fp, unsigned int n);
2979extern int dcmReadFileVRVL(FILE *fp, dcmvr *vr, unsigned int *vl, unsigned int *n);
2980extern int dcmWriteFileVRVL(FILE *fp, dcmvr vr, unsigned int vl, unsigned int *n);
2981
2982extern void dcmfileInit(DCMFILE *d);
2983extern void dcmitemFree(DCMITEM *d);
2984extern void dcmfileFree(DCMFILE *d);
2985extern unsigned short int dcmfileMaxDepth(DCMFILE *df);
2986extern unsigned short int dcmitemMaxDepth(DCMITEM *d);
2987extern unsigned short int dcmitemParentNr(DCMITEM *d);
2988extern char *dcmValueString(DCMITEM *d);
2989extern long int dcmitemGetInt(DCMITEM *d);
2990extern double dcmitemGetReal(DCMITEM *d);
2991extern DCMITEM *dcmFindTag(DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose);
2992extern void dcmitemPrint(DCMITEM *d);
2993extern void dcmTagSet(DCMTAG *tag, unsigned short int group, unsigned short int element);
2994extern int dcmAddItem(
2995 DCMFILE *dcm, DCMITEM *d, short int aschild, DCMTAG tag, dcmvr vr, unsigned int vl,
2996 char *rd, const int verbose
2997);
2998
2999extern int dcmFileReadNextElement(
3000 DCMFILE *dcm, DCMITEM *prev_item, DCMITEM *parent_item, const short int sub,
3001 const short int headerOnly, int verbose
3002);
3003extern int dcmFileRead(
3004 const char *filename, DCMFILE *dcm, const short int headerOnly,
3005 int verbose
3006);
3007extern int dcmFileWrite(const char *filename, DCMFILE *dcm, int verbose);
3008
3009/*****************************************************************************/
3010
3011/*****************************************************************************/
3012#endif // _LIBTPCIMGIO_H
int ecat63ReadPlaneToImg(const char *fname, IMG *img)
Definition img_e63.c:550
int ecat63Matenter(FILE *fp, int matnum, int blkNr)
Definition ecat63ml.c:159
int ecat7_is_scaling_needed(float amax, float *data, long long nr)
Definition ecat7w.c:604
int pxlMakeRoom(IMG_PIXELS *list, long long int i, long long int n)
Definition pixel.c:110
int imgMicropetPETToEcat7(FILE *fph, FILE *fpi, char *ecatfile, int verbose)
Definition img_upet.c:85
void ecat7PrintNormheader(ECAT7_normheader *h, FILE *fp)
Definition ecat7p.c:327
void ecat7InitMatlist(ECAT7_MATRIXLIST *mlist)
Definition ecat7ml.c:15
void ecat7PrintImageheader(ECAT7_imageheader *h, FILE *fp)
Definition ecat7p.c:102
float ecat63rFloat(void *bufi, int isvax, int islittle)
Definition ecat63r.c:928
int ecat7MainheaderFromIFT(ECAT7_mainheader *h, IFT *ift, int verbose)
Definition ecat7ift.c:221
int anaExistsNew(const char *dbname, char *hdrfile, char *imgile, char *siffile)
Definition analyze.c:45
int IMG_TEST
Definition img.c:6
int imgUnitToEcat6(IMG *img)
Definition imgunits.c:175
int imgMatchPlanes(IMG *img1, IMG *img2)
Definition imgcomp.c:307
int imgWrite2DEcat7(const char *fname, IMG *img)
Definition img_e7.c:526
int ecat63WriteScan(FILE *fp, int matnum, ECAT63_scanheader *h, void *data)
Definition ecat63w.c:461
char * ecat7acquisitiontype(short int acquisition_type)
Definition ecat7p.c:468
void ecat7SortMatlistByFrame(ECAT7_MATRIXLIST *ml)
Definition ecat7ml.c:303
int anaMakeSIFName(const char *dbname, char *siffile)
Definition analyze.c:763
int dcmAddItem(DCMFILE *dcm, DCMITEM *d, short int aschild, DCMTAG tag, dcmvr vr, unsigned int vl, char *rd, const int verbose)
Definition dcm.c:1239
int anaEditHeader(ANALYZE_DSR *h, char *field, char *value)
Definition analyze.c:783
char * imgIsotope(IMG *img)
Definition imgdecayc.c:76
void ecat63PrintMainheader(ECAT63_mainheader *h, FILE *fp)
Definition ecat63p.c:16
int ecat63_is_scaling_needed(float amax, float *data, long long nr)
Definition ecat63w.c:662
void sifModerateTrues(SIF *sif, double limit)
Definition weight.c:131
void imgGetEcat7MHeader(IMG *img, ECAT7_mainheader *h)
Definition img_e7.c:742
int irdRead(char *irdfile, IMG_RANGE *img_range, char *status)
Definition ird.c:75
int ecat7ReadSubheaderToIFT(FILE *fp, ECAT7_mainheader *h, int strtblk, IFT *ift, int verbose)
Definition ecat7ift.c:502
int imgWriteEcat7(const char *fname, IMG *img)
Definition img_e7.c:382
int ecat7pxlbytes(short int data_type)
Definition ecat7r.c:1274
int ecat7WriteImageMatrix(FILE *fp, int matrix_id, ECAT7_imageheader *h, float *fdata)
Definition ecat7w.c:635
int ecat63ReadMatlist(FILE *fp, MATRIXLIST *ml, int verbose)
Definition ecat63ml.c:46
int imgSetNiftiHeader(IMG *img, const char *dbname, NIFTI_DSR *dsr, float fmin, float fmax, int verbose)
Definition img_nii.c:471
char ecat63errmsg[128]
Definition ecat63h.c:7
int string_to_xyz(char *str, int *x, int *y, int *z)
Definition vol.c:653
int imgFormatDetermine(const char *fname, char *basename, char *hdrfile, char *imgfile, char *siffile, int *file_format, int *scanner, int *type, int *modality, int verbose)
Definition imgfile.c:536
int ecat7MHeaderToIFT(ECAT7_mainheader *h, IFT *ift, int verbose)
Definition ecat7ift.c:85
int ecat63GetPlaneAndFrameNr(MATRIXLIST *mlist, ECAT63_mainheader *h, int *plane_nr, int *frame_nr)
Definition ecat63ml.c:400
int ecat7GetPlaneAndFrameNr(ECAT7_MATRIXLIST *mlist, ECAT7_mainheader *h, int *plane_nr, int *frame_nr)
Definition ecat7ml.c:372
int imgSetAnalyzeHeader(IMG *img, const char *dbname, ANALYZE_DSR *h, float fmin, float fmax)
Definition img_ana.c:486
int ecat7GetMatrixBlockSize(ECAT7_MATRIXLIST *mlist, int *blk_nr)
Definition ecat7ml.c:418
void pxlFree(IMG_PIXELS *pxl)
Definition pixel.c:28
void ecat63InitMatlist(MATRIXLIST *mlist)
Definition ecat63ml.c:20
dcmtruid dcmReadTransferSyntaxUID(FILE *fp)
Definition dcm.c:502
void svolInit(SVOL *svol)
Definition vol.c:50
int imgGetMicropetMainHeader(FILE *fp, IMG *img, float *calibration_factor, int verbose)
Definition img_upet.c:300
void volContents(VOL *vol, VOL_RANGE r, FILE *fp)
Definition vol.c:464
char * ecat63Datatype(short int dtype)
Definition ecat63p.c:218
int imgRead(const char *fname, IMG *img)
Definition imgfile.c:26
int imgGetMaxTime(IMG *img, IMG *mimg, const int w, int verbose)
Definition imgminmax.c:345
int imgGetMicropetHeader(IMG *img)
Definition img_upet.c:583
int ecat63rInt(void *bufi, int isvax, int islittle)
Definition ecat63r.c:953
int ecat63ReadNormheader(FILE *fp, int blk, ECAT63_normheader *h, int verbose, char *errmsg)
Definition ecat63r.c:483
int imgReadEcat7Frame(const char *fname, int frame_to_read, IMG *img, int frame_index)
Definition img_e7.c:1103
long int dcmitemGetInt(DCMITEM *d)
Definition dcm.c:1084
unsigned short int dcmitemMaxDepth(DCMITEM *d)
Definition dcm.c:884
unsigned char dcmVRReserved(dcmvr id)
Definition dcm.c:205
int ecat63EditMHeader(ECAT63_mainheader *h, char *field, char *value, int verbose)
Definition ecat63h.c:140
int ecat7Read2DScanMatrix(FILE *fp, int first_block, int last_block, ECAT7_2Dscanheader *h, float **fdata)
Definition ecat7r.c:959
int imgAvg(IMG *img, IMG_RANGE *r, float *avg)
Definition imgminmax.c:503
int imgExistentTimes(IMG *img)
Definition img.c:613
unsigned int dcmSOPIdentify(const char *s)
Definition dcm.c:367
void ecat63EmptyMatlist(MATRIXLIST *mlist)
Definition ecat63ml.c:31
float fmean(float *data, long long int n, float *sd)
Definition imgminmax.c:618
void fMinMaxFin(float *data, long long int n, float *fmin, float *fmax)
Definition imgminmax.c:649
void sifModerateWeights(SIF *sif, double limit)
Definition weight.c:167
int sifWrite(SIF *data, char *filename)
Definition sifio.c:145
int dcmWriteFileVRVL(FILE *fp, dcmvr vr, unsigned int vl, unsigned int *n)
Definition dcm.c:784
int ECAT63_TEST
Definition ecat63h.c:6
char * dcmTrUIDDescr(dcmtruid id)
Definition dcm.c:466
void ehdrEmpty(ECAT_HEADERS *ehdr)
Definition ecat7ift.c:47
int imgReadMinMax(const char *fname, float *fmin, float *fmax)
Definition imgminmax.c:211
int ecat63WriteImageheader(FILE *fp, int block, ECAT63_imageheader *h)
Definition ecat63w.c:106
void imgInfo(IMG *image)
Definition img.c:359
int ecat7WriteScanMatrix(FILE *fp, int matrix_id, ECAT7_scanheader *h, float *fdata)
Definition ecat7w.c:802
int ecat7WriteNormheader(FILE *fp, int blk, ECAT7_normheader *h)
Definition ecat7w.c:330
int imgGetEcat63Fileformat(ECAT63_mainheader *h)
Definition img_e63.c:1288
int dcmFileRead(const char *filename, DCMFILE *dcm, const short int headerOnly, int verbose)
Definition dcm.c:1687
int vrdReorder(VOL_RANGE *vol_range)
Definition vol.c:607
int imgSetUnit(IMG *img, char *unit)
Definition imgunits.c:328
int ecat63WriteScanMatrix(FILE *fp, int matnum, ECAT63_scanheader *h, float *fdata)
Definition ecat63w.c:781
int pxlAllocateMore(IMG_PIXELS *pxl, long long int pxlNr)
Definition pixel.c:74
size_t dcmVRVLength(dcmvr id)
Definition dcm.c:264
int ecat63ReadAttnMatrix(FILE *fp, int strtblk, int lastblk, ECAT63_attnheader *h, float **f)
Definition ecat63r.c:830
int ecat7ReadScanheader(FILE *fp, int blk, ECAT7_scanheader *h)
Definition ecat7r.c:536
int imgWriteAnalyze(const char *dbname, IMG *img)
Definition img_ana.c:162
int niftiWriteHeader(char *filename, NIFTI_DSR *dsr, int verbose, char *status)
Definition nifti.c:844
int ecat63GatherMatlist(MATRIXLIST *ml, short int do_planes, short int do_frames, short int do_gates, short int do_beds)
Definition ecat63ml.c:510
int ecat7WriteScanheader(FILE *fp, int blk, ECAT7_scanheader *h)
Definition ecat7w.c:383
int ecat63WriteMatdata(FILE *fp, int strtblk, char *data, long long pxlNr, int pxlSize)
Definition ecat63w.c:618
int anaWriteHeader(char *filename, ANALYZE_DSR *h)
Definition analyze.c:282
int ecat63ReadScanheader(FILE *fp, int blk, ECAT63_scanheader *h, int verbose, char *errmsg)
Definition ecat63r.c:377
int imgReadNiftiFirstFrame(const char *filename, IMG *img, int verbose)
Definition img_nii.c:78
int imgEcat63Supported(ECAT63_mainheader *h)
Definition img_e63.c:1155
int imgFrameMinMax(IMG *img, int frame, float *minvalue, float *maxvalue)
Definition imgminmax.c:171
int MICROPET_TEST
Definition micropet.c:6
int ecat63WriteAllImg(const char *fname, IMG *img)
Definition img_e63.c:335
float ecat7rFloat(void *bufi, int isvax, int islittle)
Definition ecat7r.c:1233
int imgGetMicropetFrameHeader(FILE *fp, IMG *img, int frame_index, int verbose)
Definition img_upet.c:457
int imgSS(IMG *img1, IMG *img2, double *ss)
Definition imgcomp.c:412
void dcmfileInit(DCMFILE *d)
Definition dcm.c:823
int imgReadNiftiHeader(const char *filename, IMG *img, int verbose)
Definition img_nii.c:134
int imgWriteFrame(const char *fname, int frame_to_write, IMG *img, int frame_index)
Definition imgfile.c:392
void dcmTagSet(DCMTAG *tag, unsigned short int group, unsigned short int element)
Definition dcm.c:1221
int VOL_TEST
Definition vol.c:6
int ecat7WriteImageheader(FILE *fp, int blk, ECAT7_imageheader *h)
Definition ecat7w.c:113
int ecat7ReadPolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h)
Definition ecat7r.c:397
int svolAllocate(SVOL *svol, int planes, int rows, int columns)
Definition vol.c:204
int imgEcat7Supported(ECAT7_mainheader *h)
Definition img_e7.c:1036
dcmvr dcmVRId(const char *s)
Definition dcm.c:223
int ecat7ReadMatrixdata(FILE *fp, int start_block, int block_nr, char *data, int dtype)
Definition ecat7r.c:791
void ecat7SortMatlistByPlane(ECAT7_MATRIXLIST *ml)
Definition ecat7ml.c:277
int ecat7EditMHeader(ECAT7_mainheader *h, char *field, char *value, int verbose)
Definition ecat7h.c:16
int ecat7WriteMatrixdata(FILE *fp, int start_block, char *data, long long pxl_nr, int pxl_size)
Definition ecat7w.c:974
void ecat7_id_to_val(int matrix_id, ECAT7_Matval *matval)
Definition ecat7ml.c:262
int upetScanStart(FILE *fp, time_t *scant)
Definition micropet.c:194
int ecat7GetNums(ECAT7_MATRIXLIST *ml, ECAT7_mainheader *mh, FILE *fp, short int *num_planes, short int *num_frames, short int *num_gates, short int *num_bed_pos)
Definition ecat7ml.c:452
int ecat63WriteAttnheader(FILE *fp, int block, ECAT63_attnheader *h)
Definition ecat63w.c:190
void volInit(VOL *vol)
Definition vol.c:26
dcmvr
@ DCM_VR_INVALID
Invalid DICOM value representation.
@ DCM_VR_DT
DICOM date time, max 26 bytes.
@ DCM_VR_UI
DICOM unique identifier (UID), max 64 bytes.
@ DCM_VR_FD
DICOM floating point double precision, 8 bytes fixed.
@ DCM_VR_UC
DICOM unlimited characters.
@ DCM_VR_PN
DICOM person name, max 64 chars per component group.
@ DCM_VR_CS
DICOM code (control) string, max 16 bytes.
@ DCM_VR_SS
DICOM signed short (16-bit integer), 2 bytes fixed.
@ DCM_VR_SH
DICOM short string, max 16 chars.
@ DCM_VR_OF
DICOM other float (32-bit) stream, endian sensitive.
@ DCM_VR_UT
DICOM unlimited text, character string.
@ DCM_VR_US
DICOM unsigned short (16-bit) integer, 2 bytes fixed.
@ DCM_VR_TM
DICOM time HHMMSS.FFFFFF, max 14 bytes.
@ DCM_VR_OB
DICOM other byte string, even bytes, endian insensitive.
@ DCM_VR_AS
DICOM age string, 4 bytes fixed.
@ DCM_VR_ST
DICOM short text, max 1024 chars.
@ DCM_VR_AT
DICOM attribute tag, 4 bytes fixed.
@ DCM_VR_LT
DICOM long text, max 10240 chars.
@ DCM_VR_DA
DICOM date in format YYYYMMDD, 8 bytes fixed.
@ DCM_VR_UL
DICOM unsigned long (32-bit) integer, 4 bytes fixed.
@ DCM_VR_UN
DICOM unknown, any valid length of another VR.
@ DCM_VR_DS
DICOM decimal string, max 16 bytes.
@ DCM_VR_OW
DICOM other word (16-bit) stream, even bytes, endian sensitive.
@ DCM_VR_IS
DICOM integer string, max 12 bytes.
@ DCM_VR_AE
DICOM application entity, max 16 bytes.
@ DCM_VR_UR
DICOM URI or URL, string of characters.
@ DCM_VR_LO
DICOM long string, max 64 chars.
@ DCM_VR_SQ
DICOM sequence of zero or more elements (used for nested data).
@ DCM_VR_FL
DICOM floating point single precision, 4 bytes fixed.
@ DCM_VR_SL
DICOM signed long (32-bit integer), 4 bytes fixed.
@ DCM_VR_OL
DICOM other long (32-bit) stream, endian sensitive.
@ DCM_VR_OD
DICOM other double (64-bit) stream, endian sensitive.
int niftiCreateFNames(const char *filename, char *hdrfile, char *imgfile, char *siffile, int fileformat)
Definition nifti.c:44
void ecat63wFloat(float *bufi, void *bufo, int tovax, int islittle)
Definition ecat63w.c:860
int imgReadNifti(const char *filename, IMG *img, int verbose)
Definition img_nii.c:23
int ecat7ReadNormheader(FILE *fp, int blk, ECAT7_normheader *h)
Definition ecat7r.c:472
char * ecat7filetype(short int file_type)
Definition ecat7p.c:447
DCMITEM * dcmFindTag(DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose)
Definition dcm.c:1163
int dcmFileWrite(const char *filename, DCMFILE *dcm, int verbose)
Definition dcm.c:1758
int anaFlipping()
Definition analyze.c:635
int ecat7ReadMatlist(FILE *fp, ECAT7_MATRIXLIST *ml, int verbose)
Definition ecat7ml.c:41
unsigned long long imgNaNs(IMG *img, int fix)
Definition img.c:658
void ecat7EmptyMatlist(ECAT7_MATRIXLIST *mlist)
Definition ecat7ml.c:26
int imgReadNiftiFrame(const char *filename, int frame_to_read, IMG *img, int frame_index, int verbose)
Definition img_nii.c:311
char * dcmDT2intl(const char *orig, char *intl)
Definition dcm.c:345
void svolEmpty(SVOL *svol)
Definition vol.c:103
int imgReadEcat7FirstFrame(const char *fname, IMG *img)
Definition img_e7.c:1060
char * imgUnit(int dunit)
Definition imgunits.c:315
int imgExtractRange(IMG *img1, IMG_RANGE r, IMG *img2)
Definition img.c:548
int imgReadMicropetFirstFrame(const char *fname, IMG *img)
Definition img_upet.c:925
int imgMatchMatrixSize(IMG *img1, IMG *img2)
Definition imgcomp.c:447
int anaPrintHeader(ANALYZE_DSR *h, FILE *fp)
Definition analyze.c:380
void niftiRemoveFNameExtension(char *fname)
Definition nifti.c:23
int imgMicropetCTToEcat7(FILE *fph, FILE *fpi, char *ecatfile, int verbose)
Definition img_upet.c:196
int pxlGet(IMG_PIXELS *list, long long int i, IMG_PIXEL *pxl)
Definition pixel.c:163
void imgSetEcat63SHeader(IMG *img, void *h)
Definition img_e63.c:1872
void ecat63PrintImageheader(ECAT63_imageheader *h, FILE *fp)
Definition ecat63p.c:94
int ecat7WritePolarmapMatrix(FILE *fp, int matrix_id, ECAT7_polmapheader *h, float *fdata)
Definition ecat7w.c:888
int ecat63WriteScanheader(FILE *fp, int block, ECAT63_scanheader *h)
Definition ecat63w.c:242
int ecat7ReadAttenheader(FILE *fp, int blk, ECAT7_attenheader *h)
Definition ecat7r.c:311
void sifInit(SIF *data)
Definition sif.c:17
int ecat7rInt(void *bufi, int isvax, int islittle)
Definition ecat7r.c:1256
int niftiPrintHeader(NIFTI_DSR *h, FILE *fp)
Definition nifti.c:501
int volMax(VOL *vol, VOL_RANGE *r, VOL_PIXEL *maxp, float *maxv, VOL_PIXEL *minp, float *minv)
Definition vol.c:492
int ecat7WriteHeaders(const char *fname, ECAT_HEADERS *ehdr, int verbose)
Definition ecat7ift.c:755
char ecat7errmsg[128]
Definition ecat7h.c:7
void ecat63PrintScanheader(ECAT63_scanheader *h, FILE *fp)
Definition ecat63p.c:137
void dcmfileFree(DCMFILE *d)
Definition dcm.c:868
int niftiReadImagedata(FILE *fp, NIFTI_DSR *h, int frame, float *data, int verbose, char *status)
Definition nifti.c:619
int imgReadFrame(const char *fname, int frame_to_read, IMG *img, int frame_index)
Definition imgfile.c:269
void ecat63PrintNormheader(ECAT63_normheader *h, FILE *fp)
Definition ecat63p.c:197
char * dcmDA2intl(const char *orig, char *intl)
Definition dcm.c:299
int anaDatabaseExists(const char *dbname, char *hdrfile, char *imgfile, char *siffile)
Definition analyze.c:704
void dcmitemFree(DCMITEM *d)
Definition dcm.c:840
int imgWriteNiftiFrame(const char *dbname, int frame_to_write, IMG *img, int frame_index, float fmin, float fmax, int verbose)
Definition img_nii.c:594
char * dcmTM2intl(const char *orig, char *intl)
Definition dcm.c:322
char * dcmVRName(dcmvr id)
Definition dcm.c:246
int imgRangeMinMax(IMG *img, IMG_RANGE *r, IMG_PIXEL *maxp, float *maxv, IMG_PIXEL *minp, float *minv)
Definition imgminmax.c:71
dcmvr dcmReadFileVR(FILE *fp, char *vrstr)
Definition dcm.c:655
int imgUnitId(char *unit)
Definition imgunits.c:14
int imgWriteEcat63Frame(const char *fname, int frame_to_write, IMG *img, int frame_index)
Definition img_e63.c:1711
int mat_numcod(int frame, int plane, int gate, int data, int bed)
Definition ecat63ml.c:242
void ematEmpty(ECAT_MATRIX *emat)
Definition ecat7ift.c:33
int irdReorder(IMG_RANGE *img_range)
Definition ird.c:44
int SIF_TEST
Definition sif.c:6
void anaRemoveFNameExtension(char *fname)
Definition analyze.c:687
void ecat7PrintPolmapheader(ECAT7_polmapheader *h, FILE *fp)
Definition ecat7p.c:276
int upetGetImageDimensions(FILE *fp, int *z, int *x, int *y, int *f)
Definition micropet.c:154
int ecat7ReadMainheader(FILE *fp, ECAT7_mainheader *h)
Definition ecat7r.c:15
int imgReadEcat7(const char *fname, IMG *img)
Definition img_e7.c:19
int svol2img(SVOL *svol, IMG *img, int frame)
Definition vol.c:385
int ecat63ReadMatdata(FILE *fp, int strtblk, int blkNr, char *data, int dtype)
Definition ecat63r.c:568
int imgMatchMatrix(IMG *img1, IMG *img2, double accuracy)
Definition imgcomp.c:47
int imgReadEcat7Header(const char *fname, IMG *img)
Definition img_e7.c:860
int imgReadEcat63FirstFrame(const char *fname, IMG *img)
Definition img_e63.c:1457
int ANALYZE_TEST
Definition analyze.c:8
int volAllocate(VOL *vol, int planes, int rows, int columns)
Definition vol.c:139
void dcmitemPrint(DCMITEM *d)
Definition dcm.c:1205
int imgGetAnalyzeHeader(IMG *img, ANALYZE_DSR *h)
Definition img_ana.c:427
int ecat63WriteAttn(FILE *fp, int matnum, ECAT63_attnheader *h, void *data)
Definition ecat63w.c:563
int imgExistentCounts(IMG *img)
Definition img.c:630
int upetIsHeader(char *hdrfile)
Definition micropet.c:55
int ecat63WriteNorm(FILE *fp, int matnum, ECAT63_normheader *h, void *data)
Definition ecat63w.c:512
void float2parts(float *buf)
Definition ecat63p.c:277
int ecat63GetNums(MATRIXLIST *ml, short int *num_planes, short int *num_frames, short int *num_gates, short int *num_bed_pos)
Definition ecat63ml.c:450
int ecat63GetMatrixBlockSize(MATRIXLIST *mlist, int *blk_nr)
Definition ecat63ml.c:366
void sifWeightByFrames(SIF *data, double halflife)
Calculate weights for frames in SIF data based on frame lengths. Weights are normalized to have an av...
Definition weight.c:72
int dcmReadFileTag(FILE *fp, DCMTAG *tag)
Definition dcm.c:553
int imgReadAnalyzeFirstFrame(const char *fname, IMG *img)
Definition img_ana.c:592
int imgAbsMax(IMG *img, float *maxvalue)
Definition imgminmax.c:44
int ecat7EditSHeader(ECAT7_scanheader *h, char *field, char *value, int verbose)
Definition ecat7h.c:199
int niftiExists(const char *dbname, char *hdrfile, char *imgile, char *siffile, NIFTI_DSR *header, int verbose, char *status)
Definition nifti.c:160
int imgBranchingCorrection(IMG *image, int mode, int verbose, char *status)
Definition imgdecayc.c:132
char * imgStatus(int status_index)
Definition img.c:330
double dcmitemGetReal(DCMITEM *d)
Definition dcm.c:1120
void sifPrint(SIF *data)
Definition sifio.c:234
int dcmReadFileVRVL(FILE *fp, dcmvr *vr, unsigned int *vl, unsigned int *n)
Definition dcm.c:724
int ecat7EnterMatrix(FILE *fp, int matrix_id, int block_nr)
Definition ecat7ml.c:147
int imgMatchHeader(IMG *img1, IMG *img2)
Definition imgcomp.c:128
int imgDecayCorrection(IMG *img, int mode)
Definition imgdecayc.c:16
int ecat63WriteImageMatrix(FILE *fp, int matnum, ECAT63_imageheader *h, float *fdata)
Definition ecat63w.c:697
char * dcmSOPUIDName(const char *s)
Definition dcm.c:424
int sifExistentCounts(SIF *sif)
Definition weight.c:207
int imgWriteNifti(const char *dbname, IMG *img, int save_sif, int verbose)
Definition img_nii.c:811
int imgReadMicropetFrame(const char *fname, int frame_to_read, IMG *img, int frame_index)
Definition img_upet.c:819
int anaExists(const char *dbname)
Definition analyze.c:20
int imgMinMax(IMG *img, float *minvalue, float *maxvalue)
Definition imgminmax.c:154
int imgMatchTransform(IMG *img1, IMG *img2)
Definition imgcomp.c:85
void imgUnitFromEcat(IMG *img, int ecat_unit)
Definition imgunits.c:95
int imgGetEcat7Fileformat(ECAT7_mainheader *h)
Definition img_e7.c:827
int imgAllocate(IMG *image, int planes, int rows, int columns, int frames)
Definition img.c:194
int upetHeaderReadParameter(FILE *fp, char *parameter, char *value)
Definition micropet.c:16
int ecat63DeleteLateFrames(MATRIXLIST *ml, int frame_nr)
Definition ecat63ml.c:342
char * ecat7datatype(short int data_type)
Definition ecat7p.c:489
int ecat7WritePolmapheader(FILE *fp, int blk, ECAT7_polmapheader *h)
Definition ecat7w.c:271
int irdCheck(IMG_RANGE *r, IMG *img)
Definition ird.c:152
int ecat7ReadPolarmapMatrix(FILE *fp, int first_block, int last_block, ECAT7_polmapheader *h, float **fdata)
Definition ecat7r.c:1154
void ecat7PrintAttenheader(ECAT7_attenheader *h, FILE *fp)
Definition ecat7p.c:230
int upetExists(const char *upetname, char *hdrfile, char *imgfile, int verbose)
Definition micropet.c:86
void ecat63SortMatlistByPlane(MATRIXLIST *ml)
Definition ecat63ml.c:271
int ecat7Write2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h)
Definition ecat7w.c:450
int dcmFileReadNextElement(DCMFILE *dcm, DCMITEM *prev_item, DCMITEM *parent_item, const short int sub, const short int headerOnly, int verbose)
Definition dcm.c:1370
int ecat7Read2DScanheader(FILE *fp, int blk, ECAT7_2Dscanheader *h)
Definition ecat7r.c:631
char * ecat63ScanstarttimeInt(const ECAT63_mainheader *h, char *buf)
Convert scan_start_time in ECAT 6.3 main header into a null-terminated string of the form YYYY-MM-DD ...
Definition ecat63p.c:391
int dcmWriteFileSQItemDelimTag(FILE *fp)
Definition dcm.c:634
int ecat7ScanheaderToIFT(ECAT7_scanheader *h, IFT *ift, int verbose)
Definition ecat7ift.c:408
int imgWriteEcat7Frame(const char *fname, int frame_to_write, IMG *img, int frame_index)
Definition img_e7.c:1295
int niftiReadHeader(char *filename, NIFTI_DSR *h, int verbose, char *status)
Definition nifti.c:293
int ecat63AddImg(const char *fname, IMG *img)
Definition img_e63.c:878
void volInfo(VOL *vol, FILE *fp)
Definition vol.c:415
int imgWriteAnalyzeFrame(const char *fname, int frame_to_write, IMG *img, int frame_index, float fmin, float fmax)
Definition img_ana.c:751
void sifWeight(SIF *data, double halflife)
Calculate weights for frames in SIF data based on true counts. Weights are normalized to have an aver...
Definition weight.c:28
int interfile_read(char headerName[256], char searchWord[256], char returnValue[256], char errorMessage[300])
Definition interfile.c:43
int anaReadHeader(char *filename, ANALYZE_DSR *h)
Definition analyze.c:131
int string_to_xyzf(const char *str, IMG_PIXEL *v)
Definition ird.c:14
int ecat63ReadImageMatrix(FILE *fp, int strtblk, int lastblk, ECAT63_imageheader *h, float **f)
Definition ecat63r.c:627
int ecat7Write2DScanMatrix(FILE *fp, int matrix_id, ECAT7_2Dscanheader *h, float *fdata)
Definition ecat7w.c:719
void ecat7Print2DScanheader(ECAT7_2Dscanheader *h, FILE *fp)
Definition ecat7p.c:364
void ecat63PrintMatlist(MATRIXLIST *ml)
Definition ecat63ml.c:130
int imgWritePolarmap(const char *fname, IMG *img)
Definition img_e7.c:661
int vrdVxlNr(VOL_RANGE *vol_range)
Definition vol.c:634
int ecat7Write2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h)
Definition ecat7w.c:517
int imgSetDecayCorrFactors(IMG *image, int mode)
Definition imgdecayc.c:87
FILE * ecat7Create(const char *fname, ECAT7_mainheader *h)
Definition ecat7w.c:567
int ecat63WriteNormheader(FILE *fp, int block, ECAT63_normheader *h)
Definition ecat63w.c:313
int imgGetMaxFrame(IMG *img, IMG *mimg, int verbose)
Definition imgminmax.c:454
int interfileExists(const char *fname, char *hdrfile, char *imgfile, int verbose)
Definition interfile.c:193
int pxlAdd(IMG_PIXELS *list, IMG_PIXEL *pxl)
Definition pixel.c:139
void volEmpty(VOL *vol)
Definition vol.c:74
int imgGetPeak(IMG *img, float beforeTime, IMG_PIXEL *p, int verbose)
Definition imgminmax.c:294
int imgGetNiftiHeader(IMG *img, NIFTI_DSR *h, int verbose)
Definition img_nii.c:218
int pxlWrite(IMG_PIXELS *pxl, FILE *fp, char *status)
Definition pixel.c:299
void svolInfo(SVOL *svol, FILE *fp)
Definition vol.c:439
unsigned short int dcmfileMaxDepth(DCMFILE *df)
Definition dcm.c:903
int ecat63WriteImage(FILE *fp, int matnum, ECAT63_imageheader *h, void *data)
Definition ecat63w.c:410
int imgMaxDifference(IMG *img1, IMG *img2, VOXEL_4D *absdiff, float *abs_max, VOXEL_4D *reldiff, float *rel_max)
Definition imgcomp.c:328
int ecat7WriteAttenheader(FILE *fp, int blk, ECAT7_attenheader *h)
Definition ecat7w.c:208
int img2vol(IMG *img, VOL *vol, int frame)
Definition vol.c:267
FILE * ecat63Create(const char *fname, ECAT63_mainheader *h)
Definition ecat63w.c:365
int pxlRead(IMG_PIXELS *pxl, const char *fname, char *status)
Definition pixel.c:331
void ehdrInitiate(ECAT_HEADERS *ehdr)
Definition ecat7ift.c:21
float f_kth_smallest(float *data, long long int n, long long int k)
Definition imgminmax.c:558
unsigned int dcmReadFileVL(FILE *fp, unsigned int n)
Definition dcm.c:692
int img2svol(IMG *img, SVOL *svol, int frame)
Definition vol.c:305
char * dcmTrUIDString(dcmtruid id)
Definition dcm.c:484
int imgCopyhdr(IMG *image1, IMG *image2)
Definition img.c:471
void imgFormatFromFName(IMG *img, const char *fname)
Definition imgfile.c:483
int imgMatchFrames(IMG *img1, IMG *img2)
Definition imgcomp.c:286
int anaReadImagedata(FILE *fp, ANALYZE_DSR *h, int frame, float *data)
Definition analyze.c:454
int volAvg(VOL *vol, VOL_RANGE *r, float *avg)
Definition vol.c:562
void ematInitiate(ECAT_MATRIX *emat)
Definition ecat7ift.c:12
void ecat63PrintAttnheader(ECAT63_attnheader *h, FILE *fp)
Definition ecat63p.c:173
char * ecat63Unit(short int dunit)
Definition ecat63p.c:243
int sifSetmem(SIF *data, int frameNr)
Definition sif.c:56
void ecat7PrintMainheader(ECAT7_mainheader *h, FILE *fp)
Definition ecat7p.c:16
long long int pxlRmDuplicates(IMG_PIXELS *list)
Definition pixel.c:273
void ecat63wInt(int *bufi, void *bufo, int tovax, int islittle)
Definition ecat63w.c:884
int ecat7ReadImageMatrix(FILE *fp, int first_block, int last_block, ECAT7_imageheader *h, float **fdata)
Definition ecat7r.c:858
int imgMax(IMG *img, float *maxvalue)
Definition imgminmax.c:15
int imgMatch(IMG *img1, IMG *img2, float accuracy)
Definition imgcomp.c:15
int upetReadImagedata(FILE *fp, IFT *ift, int frame, float *data)
Definition micropet.c:243
int imgAllocateWithHeader(IMG *image, int planes, int rows, int columns, int frames, IMG *image_from)
Definition img.c:279
int ecat7ReadImageheader(FILE *fp, int blk, ECAT7_imageheader *h)
Definition ecat7r.c:162
int imgReadAnalyzeFrame(const char *dbname, int frame_to_read, IMG *img, int frame_index)
Definition img_ana.c:639
int imgReadAnalyzeHeader(const char *dbname, IMG *img)
Definition img_ana.c:360
int vrd2vol(VOL_RANGE *r, VOL *vol, float in, float out, char *status)
Definition vol.c:681
int ecat7_val_to_id(int frame, int plane, int gate, int data, int bed)
Definition ecat7ml.c:245
#define MAX_POLARMAP_NUM_RINGS
int anaRemove(const char *dbname)
Definition analyze.c:666
unsigned short int dcmitemParentNr(DCMITEM *d)
Definition dcm.c:923
int imgMicropetToEcat7(char *upetname, char *ecatfile, int verbose)
Definition img_upet.c:15
int ecat7PrintSubheader(ECAT7_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
Definition ecat7p.c:506
int imgGetMicropetSIF(FILE *fp, SIF *sif)
Definition img_upet.c:517
int ecat7ReadHeaders(const char *fname, ECAT_HEADERS *ehdr, int verbose)
Definition ecat7ift.c:687
int ecat6PrintSubheader(ECAT63_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
Definition ecat63p.c:293
int ecat7GatherMatlist(ECAT7_MATRIXLIST *ml, short int do_planes, short int do_frames, short int do_gates, short int do_beds)
Definition ecat7ml.c:535
dcmtruid
@ DCM_TRUID_LEI
Little Endian Implicit VR (DICOM default)
@ DCM_TRUID_JPEG81
Lossy JPEG-LS.
@ DCM_TRUID_JPEG93
Multicomponent JPEG 2000.
@ DCM_TRUID_MPEG100
MPEG-2.
@ DCM_TRUID_JPEG92
Lossless multicomponent JPEG 2000.
@ DCM_TRUID_JPEG91
JPEG 2000.
@ DCM_TRUID_JPEG70
Lossless JPEG.
@ DCM_TRUID_XML
XML encoding.
@ DCM_TRUID_INVALID
Invalid Transfer Syntax UID.
@ DCM_TRUID_MPEG103
MPEG-4 BD-compatible.
@ DCM_TRUID_RFC
RFC 2557.
@ DCM_TRUID_JPEG80
Lossless JPEG-LS.
@ DCM_TRUID_UNKNOWN
Unknown Transfer Syntax UID
@ DCM_TRUID_BEE
Big Endian Explicit VR.
@ DCM_TRUID_JPEG51
Lossy JPEG 12-bit compression.
@ DCM_TRUID_RLE
Lossless RLE.
@ DCM_TRUID_LEE
Little Endian Explicit VR.
@ DCM_TRUID_JPEG90
Lossless JPEG 2000.
@ DCM_TRUID_JPEG50
Lossy JPEG 8-bit compression.
@ DCM_TRUID_MPEG102
MPEG-4.
void imgUnitToEcat7(IMG *img, ECAT7_mainheader *h)
Definition imgunits.c:209
char * dcmValueString(DCMITEM *d)
Definition dcm.c:942
void imgSetStatus(IMG *img, int status_index)
Definition img.c:345
int ecat63CheckMatlist(MATRIXLIST *ml)
Definition ecat63ml.c:324
void imgGetEcat63MHeader(IMG *img, ECAT63_mainheader *h)
Definition img_e63.c:1172
int imgDup(IMG *img1, IMG *img2)
Definition img.c:304
int imgReadMicropetHeader(const char *dbname, IMG *img)
Definition img_upet.c:767
void sifEmpty(SIF *data)
Definition sif.c:33
int imgReadEcat63Header(const char *fname, IMG *img)
Definition img_e63.c:1318
int vrdRead(char *vdffile, VOL_RANGE *vol_range, char *status)
Definition vol.c:742
int ecat63ReadAttnheader(FILE *fp, int blk, ECAT63_attnheader *h, int verbose, char *errmsg)
Definition ecat63r.c:296
void ecat7PrintMatlist(ECAT7_MATRIXLIST *ml)
Definition ecat7ml.c:112
void pxlInit(IMG_PIXELS *pxl)
Definition pixel.c:14
void pxlMove(IMG_PIXELS *list, long long int from, long long int to)
Definition pixel.c:220
int ecat63ReadImageheader(FILE *fp, int blk, ECAT63_imageheader *h, int verbose, char *errmsg)
Definition ecat63r.c:187
int imgWrite(const char *fname, IMG *img)
Definition imgfile.c:136
int ecat63CopyMainheader(ECAT63_mainheader *h1, ECAT63_mainheader *h2)
Definition ecat63h.c:16
int niftiRemove(const char *dbname, int fileformat, int verbose)
Definition nifti.c:100
char * dcmVRDescr(dcmvr id)
Definition dcm.c:282
int ecat7Read2DNormheader(FILE *fp, int blk, ECAT7_2Dnormheader *h)
Definition ecat7r.c:725
void imgEmpty(IMG *image)
Definition img.c:121
int ecat7DeleteLateFrames(ECAT7_MATRIXLIST *ml, int frame_nr)
Definition ecat7ml.c:346
void sifWeightNorm(SIF *data)
Definition weight.c:105
int img2sif(IMG *img, SIF *sif, int copy_header, int copy_frames, int copy_counts, int verbose)
Definition img_sif.c:71
void ecat7PrintScanheader(ECAT7_scanheader *h, FILE *fp)
Definition ecat7p.c:181
int ecat7EditVHeader(ECAT7_imageheader *h, char *field, char *value, int verbose)
Definition ecat7h.c:320
int ehdrAllocate(ECAT_HEADERS *ehdr, int nr)
Definition ecat7ift.c:63
void imgSetEcat7MHeader(IMG *img, ECAT7_mainheader *h)
Definition img_e7.c:781
int ecat63CopyScanheader(ECAT63_scanheader *h1, ECAT63_scanheader *h2)
Definition ecat63h.c:94
int imgSmoothMax(IMG *img, float *maxvalue, IMG_PIXEL *p)
Definition imgminmax.c:248
char * dcmSOPUID(unsigned int i)
Definition dcm.c:406
int ecat7CheckMatlist(ECAT7_MATRIXLIST *ml)
Definition ecat7ml.c:329
struct tm * ecat63ScanstarttimeToTm(const ECAT63_mainheader *h, struct tm *tm)
Convert scan_start_time in ECAT 6.3 main header into a struct tm.
Definition ecat63w.c:900
int interfileIsHeader(const char *hdrfile, char *imgfile)
Definition interfile.c:154
int ecat7WriteMainheader(FILE *fp, ECAT7_mainheader *h)
Definition ecat7w.c:16
dcmtruid dcmTrUID(const char *s)
Definition dcm.c:445
int sifRead(char *filename, SIF *data)
Definition sifio.c:21
int ecat63ReadScanMatrix(FILE *fp, int strtblk, int lastblk, ECAT63_scanheader *h, float **f)
Definition ecat63r.c:731
int imgReadMicropet(const char *fname, IMG *img)
Definition img_upet.c:971
int vol2img(VOL *vol, IMG *img, int frame)
Definition vol.c:351
void imgSetEcat7SHeader(IMG *img, void *h)
Definition img_e7.c:1482
int pxlAllocate(IMG_PIXELS *pxl, long long int pxlNr)
Definition pixel.c:44
int dcmWriteFileTag(FILE *fp, DCMTAG *tag)
Definition dcm.c:583
void imgSetEcat63MHeader(IMG *img, ECAT63_mainheader *h)
Definition img_e63.c:1223
char siferrmsg[128]
Definition sif.c:7
int imgReadHeader(const char *fname, IMG *img, int format)
Definition imgfile.c:199
int ECAT7_TEST
Definition ecat7h.c:6
int ecat7WriteSubheaderFromIFT(FILE *fp, ECAT7_mainheader *h, int strtblk, IFT *ift, int verbose)
Definition ecat7ift.c:583
int ecat7ReadScanMatrix(FILE *fp, int first_block, int last_block, ECAT7_scanheader *h, float **fdata)
Definition ecat7r.c:1055
long long int pxlAddFromMask(IMG_PIXELS *list, IMG *img)
Definition pixel.c:185
int imgReadAnalyze(const char *dbname, IMG *img)
Definition img_ana.c:24
int sif2img(SIF *sif, IMG *img, int copy_header, int copy_frames, int copy_counts, int verbose)
Definition img_sif.c:13
int dcmVerifyMagic(const char *filename, FILE *fp)
Definition dcm.c:157
int imgReadEcat63Frame(const char *fname, int frame_to_read, IMG *img, int frame_index)
Definition img_e63.c:1503
int pxlRm(IMG_PIXELS *list, long long int index)
Definition pixel.c:249
void mat_numdoc(int matnum, Matval *matval)
Definition ecat63ml.c:254
char * dcmSOPName(unsigned int i)
Definition dcm.c:388
int ecat63pxlbytes(short int data_type)
Definition ecat63r.c:973
int ecat63WriteMainheader(FILE *fp, ECAT63_mainheader *h)
Definition ecat63w.c:24
int ecat63ReadAllToImg(const char *fname, IMG *img)
Definition img_e63.c:22
void ecat63SortMatlistByFrame(MATRIXLIST *ml)
Definition ecat63ml.c:297
int dcmWriteFileSQDelimItem(FILE *fp)
Definition dcm.c:609
int ecat63ReadMainheader(FILE *fp, ECAT63_mainheader *h)
Definition ecat63r.c:25
void imgInit(IMG *image)
Definition img.c:60
int ecat7ImageheaderToIFT(ECAT7_imageheader *h, IFT *ift, int verbose)
Definition ecat7ift.c:251
time_t ecat63Scanstarttime(const ECAT63_mainheader *h)
Get calendar time from ECAT 6.3 main header.
Definition ecat63w.c:925
float fmedian(float *data, long long int n)
Definition imgminmax.c:593
void ecat7Print2DNormheader(ECAT7_2Dnormheader *h, FILE *fp)
Definition ecat7p.c:415
void imgUnitFromEcat7(IMG *img, ECAT7_mainheader *h)
Definition imgunits.c:149
Header file for libtpcmisc.
#define MAX_STUDYNR_LEN
Definition libtpcmisc.h:163
ANALYZE_HEADER_HISTORY hist
ANALYZE_HEADER_KEY hk
ANALYZE_HEADER_IMGDIM dime
short int session_error
Definition libtpcimgio.h:84
dcmtruid truid
DCMITEM * item
char filename[FILENAME_MAX]
FILE * fp
dcmtruid truid
struct DCMITEM * child_item
struct DCMITEM * next_item
unsigned int vl
FILE * fp
fpos_t pos
char * rd
struct DCMITEM * prev_item
struct DCMITEM * parent_item
DCMTAG tag
double frameDur
unsigned int plane
double frameStart
char * filename
char acqTime[16]
char acqDate[16]
unsigned int frame
DCMMATRIX * m
unsigned int anr
unsigned int nr
unsigned short int element
unsigned short int group
short int dimension_1
short int dimension_2
short int attenuation_type
short int recon_start_month
short int recon_start_day
short int slice_location
short int processing_code
short int recon_start_min
short int recon_start_year
short int num_dimensions
short int recon_start_hour
short int recon_start_sec
short int scan_start_month
short int coin_samp_mode
short int lwr_true_thres
short int compression_code
short int wobble_speed
short int scan_start_second
short int num_bed_pos
short int transaxial_samp_mode
short int rot_source_speed
short int acquisition_type
short int calibration_units
short int scan_start_year
short int scan_start_day
short int transm_source_type
short int scan_start_minute
short int lwr_sctr_thres
short int axial_samp_mode
short int scan_start_hour
short int upr_true_thres
short int system_type
short int dimension_1
short int norm_second
short int dimension_2
short int norm_minute
short int dimension_2
short int processing_code
short int dimension_1
short int frame_duration_sec
short int num_dimensions
short int ring_difference
short int storage_order
short int num_z_elements
short int norm_quality_factor_code
short int num_r_elements
short int corrections_applied
float deadtime_correction_factor
short int num_z_elements
short int num_r_elements
short int ring_difference
short int num_dimensions
ECAT7_MatDir * matdir
short int num_r_elements
short int attenuation_type
short int num_additional_atten_coeff
short int num_dimensions
float edge_finding_threshold
short int num_z_elements
short int data_type
short int num_angles
short int storage_order
short int ring_difference
float filter_scatter_fraction
short int filter_code
short int image_max
short int image_min
short int zfilter_order
short int rfilter_code
float filter_cutoff_frequency
short int zfilter_code
short int filter_order
short int y_dimension
short int z_dimension
short int recon_type
short int scatter_type
short int recon_views
short int num_dimensions
short int rfilter_order
short int x_dimension
short int data_type
short int file_type
short int compression_code
short int system_type
short int num_frames
short int coin_samp_mode
float well_counter_corr_factor
short int angular_compression
short int calibration_units
short int septa_state
short int num_gates
short int num_planes
short int lwr_true_thres
short int wobble_speed
short int acquisition_mode
short int calibration_units_label
short int num_bed_pos
float ecat_calibration_factor
short int sw_version
short int transm_source_type
short int acquisition_type
short int axial_samp_mode
short int patient_orientation
short int upr_true_thres
short int lwr_sctr_thres
short int num_r_elements
short int data_type
short int num_transaxial_crystals
short int num_geo_corr_planes
short int crystals_per_ring
short int max_ring_diff
float norm_quality_factor
short int num_crystal_rings
short int norm_quality_factor_code
short int scatter_energy
short int processing_code
short int start_angle
short int polar_map_type
short int position_data
short int quant_units
short int scan_min
short int num_r_elements
short int num_angles
short int data_type
float deadtime_correction_factor
short int num_dimensions
short int axial_compression
short int storage_order
short int scan_max
short int ring_difference
short int corrections_applied
ECAT_MATRIX * m
ECAT7_Matval matval
long long int _pxlNr
IMG_PIXEL * p
long long int pxlNr
float * pixel
float sizex
int polarmap_num_rings
unsigned short int dimx
float branchingFraction
char type
float resolutionx
int errstatus
float * sd
float resolutiony
float sampleDistance
short int polarmap_start_angle
float gapx
float **** m
char decayCorrection
float transaxialFOV
char unit
float *** row
char status
time_t scanStart
int _fileFormat
float * prompts
unsigned short int dimt
int _dataType
int * planeNumber
IFT ift
int scanner
float sizey
float * weight
float **** plane
float * start
unsigned short int dimz
int modality
unsigned short int dimy
int orientation
float * end
float calibrationFactor
float ** column
float zoom
float * decayCorrFactor
const char * statmsg
float isotopeHalflife
float gapy
float * randoms
float gapz
float axialFOV
float * mid
char isWeight
float sizez
float resolutionz
MatDir * matdir
int matstat
int endblk
int matnum
int strtblk
MatDirNode * first
MatDirNode * last
struct matdirnode * next
MatDirList * dirlist
ECAT63_mainheader * mhptr
char * data_ptr
int frame
int plane
short int qform_code
short int slice_start
short int slice_end
short int datatype
short int bitpix
short int sform_code
short int intent_code
short int session_error
NIFTI_1_HEADER h
NIFTI_EXTENDER e
double * x1
double * prompts
int frameNr
double * x2
int version
time_t scantime
double * weights
int colNr
double * randoms
double * trues
float sizey
unsigned short int dimx
unsigned short int dimz
int orientation
short int ** row
float sizez
short int * voxel
unsigned short int dimy
short int *** plane
float scale_factor
char status
char * statmsg
short int *** v
float sizex
short int * column
char status
float * column
unsigned short int dimx
unsigned short int dimy
float ** row
int orientation
unsigned short int dimz
float sizex
char * statmsg
float *** plane
float * voxel
float *** v
float sizez
float sizey