This file is indexed.

/usr/include/teem/nrrd.h is in libteem-dev 1.11.0~svn5226-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
/*
  Teem: Tools to process and visualize scientific data and images              
  Copyright (C) 2011, 2010, 2009  University of Chicago
  Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
  Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public License
  (LGPL) as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  The terms of redistributing and/or modifying this software also
  include exceptions to the LGPL that facilitate static linking.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with this library; if not, write to Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef NRRD_HAS_BEEN_INCLUDED
#define NRRD_HAS_BEEN_INCLUDED

#include <errno.h>
#include <stddef.h>      /* for ptrdiff_t */

/* ---- BEGIN non-NrrdIO */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <float.h>

#include <teem/air.h>
#include <teem/hest.h>
#include <teem/biff.h>

#include "nrrdDefines.h"
#include "nrrdMacros.h"
#include "nrrdEnums.h"

#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(TEEM_STATIC)
#  if defined(TEEM_BUILD) || defined(nrrd_EXPORTS) || defined(teem_EXPORTS)
#    define NRRD_EXPORT extern __declspec(dllexport)
#  else
#    define NRRD_EXPORT extern __declspec(dllimport)
#  endif
#else /* TEEM_STATIC || UNIX */
#  define NRRD_EXPORT extern
#endif
/* ---- END non-NrrdIO */


#ifdef __cplusplus
extern "C" {
#endif

#define NRRD nrrdBiffKey

/*
******** NrrdAxisInfo struct
**
** all the information which can sensibly be associated with
** one axis of a nrrd.  The only member which MUST be explicitly
** set to something meaningful is "size".
**
** If an axis lies conceptually along some direction in an enclosing
** space of dimension nrrd->spaceDim, then the first nrrd->spaceDim
** entries of spaceDirection[] must be non-NaN, and min, max, spacing,
** and units must NOT be set;  thickness, center, and label can still
** be used.  The mutual exclusion between axis-aligned and general
** direction information is enforced per-axis, not per-array.
**
** The min and max values give the range of positions "represented"
** by the samples along this axis.  In node-centering, "min" IS the
** position at the lowest index.  In cell-centering, the position at
** the lowest index is between min and max (a touch bigger than min,
** assuming min < max).
**
** There needs to be a one-to-one correspondence between these variables
** and the nrrdAxisInfo* enum (nrrdEnums.h), the per-axis header fields
** (see nrrdField* enum in nrrdEnums.h), and the various methods in axis.c
*/
typedef struct {
  size_t size;              /* number of elements along each axis */
  double spacing;           /* if non-NaN, distance between samples */
  double thickness;         /* if non-NaN, nominal thickness of region
                               represented by one sample along the axis. No
                               semantics relative to spacing are assumed or
                               imposed, and unlike spacing, there is no
                               sensible way to alter thickness- it is either
                               copied (as with cropping and slicing) or set to
                               NaN (when resampled). */
  double min, max;          /* if non-NaN, range of positions spanned by the
                               samples on this axis.  Obviously, one can set
                               "spacing" to something incompatible with min
                               and max: the idea is that only one (min and
                               max, or spacing) should be taken to be
                               significant at any time. */
  double spaceDirection[NRRD_SPACE_DIM_MAX]; 
                            /* the vector, in "space" (as described by
                               nrrd->space and/or nrrd->spaceDim), from one
                               sample to the next sample along this axis.  It
                               is the column vector of the transform from
                               index space to "space" space */
  int center;               /* cell vs. node centering (value should be one of
                               nrrdCenter{Unknown,Node,Cell} */
  int kind;                 /* what kind of information is along this axis
                               (from the nrrdKind* enum) */
  char *label,              /* short info string for each axis */
    *units;                 /* string identifying the unit */
} NrrdAxisInfo;

/*
******** Nrrd struct
**
** The struct used to wrap around the raw data array
*/
typedef struct {
  /* 
  ** NECESSARY information describing the main array.  This is
  ** generally set at the same time that either the nrrd is created,
  ** or at the time that the nrrd is wrapped around an existing array 
  */

  void *data;                       /* the data in memory */
  int type;                         /* a value from the nrrdType enum */
  unsigned int dim;                 /* the dimension (rank) of the array */

  /* 
  ** All per-axis specific information
  */
  NrrdAxisInfo axis[NRRD_DIM_MAX];  /* axis[0] is the fastest axis in the scan-
                                       line ordering, the one who's coordinates
                                       change the fastest as the elements are
                                       accessed in the order in which they
                                       appear in memory */

  /* 
  ** Optional information descriptive of whole array, some of which is
  ** meaningfuly for only some uses of a nrrd
  */
  char *content;                    /* brief account of what this data is */
  char *sampleUnits;                /* units of measurement of the values 
                                       stored in the array itself (not the 
                                       array axes and not space coordinates).
                                       The logical name might be "dataUnits",
                                       but that's perhaps ambiguous.  Note that
                                       these units may apply to non-scalar
                                       kinds (e.g. coefficients of a vector
                                       have the same units) */
  int space;                        /* from nrrdSpace* enum, and often 
                                       implies the value of spaceDim */
  unsigned int spaceDim;            /* if non-zero, the dimension of the space
                                       in which the regular sampling grid
                                       conceptually lies.  This is a separate
                                       variable because this dimension can be
                                       different than the array dimension. 
                                       The non-zero-ness of this value is in 
                                       fact the primary indicator that space
                                       and orientation information is set.
                                       This identifies the number of entries in
                                       "origin" and the per-axis "direction"
                                       vectors that are taken as meaningful */
  char *spaceUnits[NRRD_SPACE_DIM_MAX];
                                    /* units for coordinates of space */
  double spaceOrigin[NRRD_SPACE_DIM_MAX];
                                    /* the location of the center the first
                                       (lowest memory address) array sample,
                                       regardless of node-vs-cell centering */
  double measurementFrame[NRRD_SPACE_DIM_MAX][NRRD_SPACE_DIM_MAX];
                                    /* if spaceDim is non-zero, this may store 
                                       a spaceDim-by-spaceDim matrix which 
                                       transforms vector/matrix coefficients
                                       in the "measurement frame" to those in
                                       the world space described by spaceDim
                                       (and hopefully space).  Coeff [i][j] is
                                       *column* i & *row* j, which is probably
                                       the *transpose* of what you expect.
                                       There are no semantics linking this to
                                       the "kind" of any axis, for a variety
                                       of reasons */
  size_t blockSize;                 /* for nrrdTypeBlock, block byte size */
  double oldMin, oldMax;            /* if non-NaN, and if nrrd is of integral
                                       type, extremal values for the array
                                       BEFORE it was quantized */
  void *ptr;                        /* never read or set by nrrd; use/abuse
                                       as you see fit */

  /* 
  ** Comments.  Read from, and written to, header.
  ** The comment array "cmt" is NOT NULL-terminated.
  ** The number of comments is cmtArr->len.
  */
  char **cmt;
  airArray *cmtArr;

  /*
  ** Key-value pairs.
  */
  char **kvp;
  airArray *kvpArr;
} Nrrd;

struct NrrdIoState_t;
struct NrrdEncoding_t;

/*
******** NrrdFormat
**
** All information and behavior relevent to one datafile format
*/
typedef struct {
  char name[AIR_STRLEN_SMALL];    /* short identifying string */
  int isImage,    /* this format is intended solely for "2D" images, which
                     controls the invocation of _nrrdReshapeUpGrayscale()
                     if nrrdStateGrayscaleImage3D */
    readable,     /* we can read as well as write this format */
    usesDIO;      /* this format can use Direct IO */

  /* tests if this format is currently available in this build */
  int (*available)(void);

  /* (for writing) returns non-zero if a given filename could likely be
     represented by this format */
  int (*nameLooksLike)(const char *filename);

  /* (for writing) returns non-zero if a given nrrd/encoding pair will fit
     in this format */
  int (*fitsInto)(const Nrrd *nrrd, const struct NrrdEncoding_t *encoding, 
                   int useBiff);

  /* (for reading) returns non-zero if what has been read in so far 
     is recognized as the beginning of this format */
  int (*contentStartsLike)(struct NrrdIoState_t *nio);

  /* reader and writer */
  int (*read)(FILE *file, Nrrd *nrrd, struct NrrdIoState_t *nio);
  int (*write)(FILE *file, const Nrrd *nrrd, struct NrrdIoState_t *nio);
} NrrdFormat;

/*
******** NrrdEncoding
**
** All information and behavior relevent to one way of encoding data
**
** The data readers are responsible for memory allocation.
** This is necessitated by the memory restrictions of direct I/O
*/
typedef struct NrrdEncoding_t {
  char name[AIR_STRLEN_SMALL],    /* short identifying string */
    suffix[AIR_STRLEN_SMALL];     /* costumary filename suffix */
  int endianMatters,
    isCompression;
  int (*available)(void);
  /* The "data" and "elementNum" values have to be passed explicitly
     to read/wrote because they will be different from nrrd->data and
     nrrdElementNumber(nrrd) in the case of multiple data files.  You
     might think that the only other thing required to be passed is
     nrrdElementSize(nrrd), but no, it is in fact best to pass the
     whole Nrrd, instead of just certain attributes.  The stupid details:
             nrrd->dim: needed to know whether to put one value per line
                        in case of 1-D nrrdEncodingAscii
    nrrd->axis[0].size: need for proper formatting of nrrdEncodingAscii
            nrrd->type: needed for nrrdEncodingAscii, since its action is
                        entirely parameterized by type
       nrrd->blockSize: needed for nrrdElementSize in case of nrrdTypeBlock */
  int (*read)(FILE *file, void *data, size_t elementNum,
              Nrrd *nrrd, struct NrrdIoState_t *nio);
  int (*write)(FILE *file, const void *data, size_t elementNum,
               const Nrrd *nrrd, struct NrrdIoState_t *nio);
} NrrdEncoding;

/*
******** NrrdIoState struct
**
** Everything relating to how the nrrd is read and written.
** Multiple parameters for writing are set here (like format, encoding, 
** zlib parameters).  Also, this is the place where those few parameters
** of reading are stored (like skipData and keepNrrdDataFileOpen).  Also,
** after the nrrd has been read, it is a potentially useful record of what
** it took to read it in.
*/
typedef struct NrrdIoState_t {
  char *path,               /* allows us to remember the directory
                               from whence this nrrd was "load"ed, or
                               to whence this nrrd is "save"ed, MINUS the
                               trailing "/", so as to facilitate games with
                               header-relative data files */
    *base,                  /* when "save"ing a nrrd into separate
                               header and data, the name of the header
                               file (e.g. "output.nhdr") MINUS the ".nhdr".
                               This is massaged to produce a header-
                               relative data filename.  */
    *line,                  /* buffer for saving one line from file */
    *dataFNFormat,          /* if non-NULL, the format string (containing 
                               something like "%d" as a substring) to be 
                               used to identify multiple detached datafiles.
                               NB: This is "format" in the sense of a printf-
                               style format string, not in the sense of a 
                               file format.  This may need header-relative
                               path processing. */
    **dataFN,               /* ON READ + WRITE: array of data filenames. These
                               are not passed directly to fopen, they may need
                               header-relative path processing. Like the
                               cmtArr in the Nrrd, this array is not NULL-
                               terminated */
    *headerStringWrite;     /* ON WRITE: string from to which the header can
                               be written.  On write, it is assumed allocated
                               for as long as it needs to be (probably via a
                               first pass with learningHeaderStrlen). NOTE:
                               It is the non-NULL-ity of this which signifies
                               the intent to do string-based writing */
  const char
    *headerStringRead;      /* ON READ: like headerStringWrite, but for
                               reading the header from.  NOTE: It is the
                               non-NULL-ity of this which signifies the
                               intent to do string-based reading */
  airArray *dataFNArr;      /* for managing the above */

  FILE *headerFile,         /* if non-NULL, the file from which the NRRD
                               header is being read */
    *dataFile;              /* this used to be a central part of how the 
                               I/O code worked, but now it is simply the 
                               place to store the dataFile in the case of
                               keepNrrdDataFileOpen */
  unsigned int dataFileDim, /* The dimension of the data in each data file.
                               Together with dataFNArr->len, this determines
                               how many bytes should be in each data file */
    lineLen,                /* allocated size of line, including the
                               last character for \0 */
    charsPerLine,           /* when writing ASCII data in which we
                               intend only to write a huge long list
                               of numbers whose text formatting
                               implies nothing, then how many
                               characters do we limit ourselves to per
                               line */
    valsPerLine,            /* when writing ASCII data in which we DO
                               intend to sigify (or at least hint at)
                               something with the formatting, then
                               what is the max number of values to
                               write on a line */
    lineSkip,               /* if dataFile non-NULL, the number of
                               lines in dataFile that should be
                               skipped over (so as to bypass another
                               form of ASCII header preceeding raw
                               data) */
    headerStrlen,           /* ON WRITE, for NRRDs, if learningHeaderStrlen,
                               the learned strlen of the header so far */
    headerStrpos;           /* ON READ, for NRRDs, if headerStringRead is
                               non-NULL, the current location of reading
                               in the header */
  long int byteSkip;        /* exactly like lineSkip, but bytes
                               instead of lines.  First the lines are
                               skipped, then the bytes */
  int dataFNMin,            /* used with dataFNFormat to identify .. */
    dataFNMax,              /* .. all the multiple detached datafiles */
    dataFNStep,             /* how to step from max to min */
    dataFNIndex,            /* which of the data files are being read */
    pos,                    /* line[pos] is beginning of stuff which
                               still has yet to be parsed */
    endian,                 /* endian-ness of the data in file, for
                               those encoding/type combinations for
                               which it matters (from nrrdEndian) */
    seen[NRRD_FIELD_MAX+1], /* for error checking in header parsing */
    detachedHeader,         /* ON WRITE: request for file (NRRD format only)
                               to be split into distinct header and data. 
                               This only has an effect if detaching the header
                               is not already necessary, as it is with multiple
                               data files */
    bareText,               /* when writing a plain text file, is there any
                               effort made to record the nrrd struct
                               info in the text file */
    skipData,               /* if non-zero (all formats):
                               ON READ: don't allocate memory for, and don't
                               read in, the data portion of the file (but we
                               do verify that for nrrds, detached datafiles
                               can be opened).  Note: Does NOT imply 
                               keepNrrdDataFileOpen.  Warning: resulting
                               nrrd struct will have "data" pointer NULL.
                               ON WRITE: don't write data portion of file
                               (for nrrds, don't even try to open detached
                               datafiles).  Warning: can result in broken
                               noncomformant files.
                               (be careful with this) */
    skipFormatURL,          /* if non-zero for NRRD format ON WRITE:
                               skip the comment lines that document where
                               to find the NRRD file format specs */
    keepNrrdDataFileOpen,   /* ON READ: when there is only a single dataFile,
                               don't close nio->dataFile when
                               you otherwise would, when reading the
                               nrrd format. Probably used in conjunction with
                               skipData.  (currently for "unu data")
                               ON WRITE: no semantics */
    zlibLevel,              /* zlib compression level (0-9, -1 for
                               default[6], 0 for no compression). */
    zlibStrategy,           /* zlib compression strategy, can be one
                               of the nrrdZlibStrategy enums, default is
                               nrrdZlibStrategyDefault. */
    bzip2BlockSize,         /* block size used for compression, 
                               roughly equivalent to better but slower
                               (1-9, -1 for default[9]). */
    learningHeaderStrlen;   /* ON WRITE, for nrrds, learn and save the total
                               length of header into headerStrlen. This is
                               used to allocate a buffer for header */
  void *oldData;            /* ON READ: if non-NULL, pointer to space that 
                               has already been allocated for oldDataSize */
  size_t oldDataSize;       /* ON READ: size of mem pointed to by oldData */

  /* The format and encoding.  These are initialized to nrrdFormatUnknown
     and nrrdEncodingUnknown, respectively. USE THESE VALUES for 
     any kind of initialization or flagging; DO NOT USE NULL */
  const NrrdFormat *format;
  const NrrdEncoding *encoding;
} NrrdIoState;

/* ---- BEGIN non-NrrdIO */

/*
******** NrrdRange
**
** information about a range of values, used as both a description
** of an existing nrrd, or as input to functions like nrrdQuantize
** (in which case the given min,max may not correspond to the actual
** min,max of the nrrd in question).
**
** This information has been removed from the Nrrd struct (as of Teem1.6) 
** and put into this separate entity because:
** 1) when intended to be descriptive of a nrrd, it can't be guaranteed
** to be true across nrrd calls
** 2) when used as input parameters (e.g. to nrrdQuantize), its not
** data-flow friendly (you can't modify input)
*/
typedef struct {
  double min, max;  /* if non-NaN, nominally: extremal values for array, but
                       practically: the min and max values to use for nrrd
                       calls for which a min and max values are used */
  int hasNonExist;  /* from the nrrdHasNonExist* enum values */
} NrrdRange;

/*
******** NrrdKernel struct
**
** these are essentially the methods of the various kernels implemented.
**
** Nrrd's use of this sort of kernel always assumes support symmetric
** around zero, but does not assume anything about even- or oddness
**
** It is a strong but very simplifying assumption that the parameter
** array ("parm") is always type double.  There is essentially no
** value in allowing flexibility between float and double, and much
** Teem code assumes that it will always be type double.
*/
typedef struct {
  /* terse string representation of kernel function, irrespective of
     the parameter vector */
  char name[AIR_STRLEN_SMALL];
  
  /* number of parameters needed (# elements in parm[] used) */
  unsigned int numParm;  /* HEY: should be "parmNum" in standard convention */

  /* smallest x (x > 0) such that k(y) = 0 for all y > x, y < -x */
  double (*support)(const double *parm); 

  /* integral of kernel from -support to +support */
  double (*integral)(const double *parm);

  /* evaluate once, single precision */
  float (*eval1_f)(float x, const double *parm);
  
  /* evaluate N times, single precision */
  void (*evalN_f)(float *f, const float *x, size_t N, const double *parm);

  /* evaluate once, double precision */
  double (*eval1_d)(double x, const double *parm);

  /* evaluate N times, double precision */
  void (*evalN_d)(double *f, const double *x, size_t N, const double *parm);
} NrrdKernel;

/*
******** NrrdKernelSpec struct
** 
** for those times when it makes most sense to directly associate a
** NrrdKernel with its parameter vector (that is, a full kernel
** "spec"ification), basically: using hest.
*/
typedef struct {
  const NrrdKernel *kernel;
  double parm[NRRD_KERNEL_PARMS_NUM];
} NrrdKernelSpec;

/*
******** NrrdResampleInfo struct
**
** a struct to contain the many parameters needed for nrrdSpatialResample()
*/
typedef struct {
  const NrrdKernel 
    *kernel[NRRD_DIM_MAX]; /* which kernel to use on each axis; use NULL to
                              say no resampling whatsoever on this axis */
  size_t samples[NRRD_DIM_MAX]; /* number of samples per axis */
  double parm[NRRD_DIM_MAX][NRRD_KERNEL_PARMS_NUM], /* kernel arguments */
    min[NRRD_DIM_MAX],
    max[NRRD_DIM_MAX];     /* min[i] and max[i] are the range, in WORLD space,
                              along which to resample axis i.  axis mins and
                              maxs are required on resampled axes. */
  int boundary,            /* value from the nrrdBoundary enum */
    type,                  /* desired type of output, use nrrdTypeUnknown for
                              "same as input" */
    renormalize,           /* when downsampling with a kernel with non-zero
                              integral, should we renormalize the weights to
                              match the kernel integral so as to remove
                              annoying ripple */
    round,                 /* when copying from the last intermediate (floating
                              point) result to the output nrrd, for integer
                              outputs, do we round to the nearest integer
                              first, before clamping and assigning.  Enabling
                              this fixed the mystery of downsampling large
                              constant regions of 255 (uchar), and ending up
                              with 254 */
    clamp,                  /* when copying from the last intermediate
                               (floating point) result to the output nrrd,
                               should we clamp the values to the range of
                               values for the output type, a concern only for
                               integer outputs */
    cheap;                  /* when *downsampling* (reducing the number of
                               samples), don't bother expanding the kernel to
                               achieve filtering in the old index space; with
                               nrrdKernelBox this can lead to subsampling by
                               picking using every other value */
  double padValue;          /* if padding, what value to pad with */
} NrrdResampleInfo;

/*
******** NrrdResampleAxis struct
**
** specific to one pass (one pass per axis) of resampling process
*/
typedef struct {
  /* ----------- input ---------- */
  const NrrdKernel *kernel;  /* which kernel to use on this axis; use NULL to
                                say no resampling whatsoever on this axis */
  double kparm[NRRD_KERNEL_PARMS_NUM]; /* kernel arguments */
  double min, max;           /* range in INDEX space of resampling */
  size_t samples;            /* number output samples on this axis (sizeOut) */
  int overrideCenter;        /* possible explicit setting of centering */
  /* ----------- internal ---------- */
  int center;                /* centering for this axis */
  size_t sizeIn,             /* number input samples on this axis */
    sizePerm[NRRD_DIM_MAX];  /* permutation of axis sizes for this pass */
  unsigned int axIdx,        /* what axis are we (redundant with other info) */
    passIdx,                 /* exactly which pass are we on */
    axisPerm[NRRD_DIM_MAX];  /* permutation of axis indices for this pass */
  double ratio;              /* > 1: upsampling; < 1: downsampling */
  Nrrd *nrsmp,               /* intermediate resampling result; input to 
                                this pass */
    *nline,                  /* input scanline buffer (includes extra sample 
                                at end for storing pad value) */
    *nindex,                 /* row of input indices for each output sample */
    *nweight;                /* row of input weights for each output sample */
} NrrdResampleAxis;

/*
******** NrrdResampleContext struct
**
** contains the parameters and state associated with resampling,
** geared towards quickly resampling multiple different nrrds with the
** same shape.
*/
typedef struct {
  /* ----------- input ---------- */
  const Nrrd *nin;          /* the nrrd being resampled */
  int verbose,              /* blah blah blah */
    boundary,               /* value from the nrrdBoundary enum */
    typeOut,                /* desired type of output, use nrrdTypeDefault for
                               "same as input" */
    renormalize,            /* when downsampling with a kernel with non-zero
                               integral, should we renormalize the weights to
                               match the kernel integral so as to remove
                               annoying ripple */
    round,                  /* when copying from the last intermediate
                               (floating point) result to the output nrrd,
                               for integer outputs, do we round to the nearest
                               integer first, before clamping and assigning.
                               Enabling this fixed the mystery of downsampling
                               large constant regions of 255 (uchar), and
                               ending up with 254 */
    clamp,                   /* when copying from the last intermediate
                                (floating point) result to the output nrrd,
                               should we clamp the values to the range of
                                values for the output type, a concern only for
                                integer outputs */
    defaultCenter,           /* lacking known centering on input axis, what
                                centering to use when resampling */
    nonExistent;             /* from nrrdResampleNonExistent enum */
  double padValue;           /* if padding, what value to pad with */
  /* ----------- input/internal ---------- */
  unsigned int dim,          /* dimension of nin (saved here to help
                                manage state in NrrdResampleAxis[]) */
    passNum,                 /* number of passes needed */
    topRax, botRax,          /* fastest, slowest axes undergoing resampling */
    permute[NRRD_DIM_MAX+1], /* how each pass permutes axes */
    passAxis[NRRD_DIM_MAX];  /* mapping from pass index to axis index */
  NrrdResampleAxis
    axis[NRRD_DIM_MAX+1];    /* axis[j] stores information for input to
                                pass which is resampling nin->axis[j]; 
                                axis[NRRD_DIM_MAX] stores info about the
                                final output of all passes */
  int *flag;                 /* flags for managing state */
  /* ----------- output ---------- */
  double time;               /* time required for resampling */
} NrrdResampleContext;

/*
******** NrrdIter struct
**
** To hold values: either a single value, or a whole nrrd of values.
** Also, this facilitates iterating through those values
*/
typedef struct {
  const Nrrd *nrrd;            /* read-only nrrd to get values from */
  Nrrd *ownNrrd;               /* another nrrd to get values from, which we
                                  do "own", and do delete on nrrdIterNix */
  double val;                  /* single fixed value */
  size_t size;                 /* type size */
  char *data;                  /* where to get the next value */
  size_t left;                 /* number of values beyond what "data"
                                  currently points to */
  double (*load)(const void*); /* how to get a value out of "data" */
} NrrdIter;

/* ---- END non-NrrdIO */

/******** defaults (nrrdDefault..) and state (nrrdState..) */
/* defaultsNrrd.c */
NRRD_EXPORT int nrrdDefaultWriteEncodingType;
NRRD_EXPORT int nrrdDefaultWriteBareText;
NRRD_EXPORT unsigned int nrrdDefaultWriteCharsPerLine;
NRRD_EXPORT unsigned int nrrdDefaultWriteValsPerLine;
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT int nrrdDefaultResampleBoundary;
NRRD_EXPORT int nrrdDefaultResampleType;
NRRD_EXPORT int nrrdDefaultResampleRenormalize;
NRRD_EXPORT int nrrdDefaultResampleRound;
NRRD_EXPORT int nrrdDefaultResampleClamp;
NRRD_EXPORT int nrrdDefaultResampleCheap;
NRRD_EXPORT double nrrdDefaultResamplePadValue;
NRRD_EXPORT int nrrdDefaultResampleNonExistent;
NRRD_EXPORT double nrrdDefaultKernelParm0;
/* ---- END non-NrrdIO */
NRRD_EXPORT int nrrdDefaultCenter;
NRRD_EXPORT double nrrdDefaultSpacing;
NRRD_EXPORT int nrrdStateVerboseIO;
NRRD_EXPORT int nrrdStateKeyValuePairsPropagate;
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT int nrrdStateBlind8BitRange;
NRRD_EXPORT int nrrdStateMeasureType;
NRRD_EXPORT int nrrdStateMeasureModeBins;
NRRD_EXPORT int nrrdStateMeasureHistoType;
NRRD_EXPORT int nrrdStateDisallowIntegerNonExist;
/* ---- END non-NrrdIO */
NRRD_EXPORT int nrrdStateAlwaysSetContent;
NRRD_EXPORT int nrrdStateDisableContent;
NRRD_EXPORT char *nrrdStateUnknownContent;
NRRD_EXPORT int nrrdStateGrayscaleImage3D;
NRRD_EXPORT int nrrdStateKeyValueReturnInternalPointers;
NRRD_EXPORT int nrrdStateKindNoop;
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT const char *const nrrdEnvVarDefaultWriteEncodingType;
NRRD_EXPORT const char *const nrrdEnvVarDefaultWriteBareText;
NRRD_EXPORT const char *const nrrdEnvVarDefaultWriteBareTextOld;
NRRD_EXPORT const char *const nrrdEnvVarDefaultCenter;
NRRD_EXPORT const char *const nrrdEnvVarDefaultCenterOld;
NRRD_EXPORT const char *const nrrdEnvVarDefaultWriteCharsPerLine;
NRRD_EXPORT const char *const nrrdEnvVarDefaultWriteValsPerLine;
NRRD_EXPORT const char *const nrrdEnvVarDefaultKernelParm0;
NRRD_EXPORT const char *const nrrdEnvVarDefaultSpacing;
NRRD_EXPORT const char *const nrrdEnvVarStateKindNoop;
NRRD_EXPORT const char *const nrrdEnvVarStateVerboseIO;
NRRD_EXPORT const char *const nrrdEnvVarStateKeyValuePairsPropagate;
NRRD_EXPORT const char *const nrrdEnvVarStateBlind8BitRange;
NRRD_EXPORT const char *const nrrdEnvVarStateAlwaysSetContent;
NRRD_EXPORT const char *const nrrdEnvVarStateDisableContent;
NRRD_EXPORT const char *const nrrdEnvVarStateMeasureType;
NRRD_EXPORT const char *const nrrdEnvVarStateMeasureModeBins;
NRRD_EXPORT const char *const nrrdEnvVarStateMeasureHistoType;
NRRD_EXPORT const char *const nrrdEnvVarStateGrayscaleImage3D;
NRRD_EXPORT int nrrdGetenvBool(int *val, char **envStr,
                               const char *envVar);
NRRD_EXPORT int nrrdGetenvEnum(int *val, char **envStr, const airEnum *enm,
                               const char *envVar);
NRRD_EXPORT int nrrdGetenvInt(int *val, char **envStr,
                              const char *envVar);
NRRD_EXPORT int nrrdGetenvUInt(unsigned int *val, char **envStr,
                               const char *envVar);
NRRD_EXPORT int nrrdGetenvDouble(double *val, char **envStr,
                                 const char *envVar);
NRRD_EXPORT void nrrdDefaultGetenv(void);
NRRD_EXPORT void nrrdStateGetenv(void);
/* ---- END non-NrrdIO */

/******** all the airEnums used through-out nrrd */
/* 
** the actual C enums are in nrrdEnums.h; experience has shown that it
** is not particularly useful to name those enums, since the shortest
** name is best used for the airEnums here
*/
/* enumsNrrd.c */
NRRD_EXPORT const airEnum *const nrrdFormatType;
NRRD_EXPORT const airEnum *const nrrdType;
NRRD_EXPORT const airEnum *const nrrdEncodingType;
NRRD_EXPORT const airEnum *const nrrdCenter;
NRRD_EXPORT const airEnum *const nrrdKind;
NRRD_EXPORT const airEnum *const nrrdField;
NRRD_EXPORT const airEnum *const nrrdSpace;
NRRD_EXPORT const airEnum *const nrrdSpacingStatus;
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT const airEnum *const nrrdBoundary;
NRRD_EXPORT const airEnum *const nrrdMeasure;
NRRD_EXPORT const airEnum *const nrrdUnaryOp;
NRRD_EXPORT const airEnum *const nrrdBinaryOp;
NRRD_EXPORT const airEnum *const nrrdTernaryOp;
NRRD_EXPORT const airEnum *const nrrdFFTWPlanRigor;
NRRD_EXPORT const airEnum *const nrrdResampleNonExistent;
/* ---- END non-NrrdIO */

/******** arrays of things (poor-man's functions/predicates) */
/* arraysNrrd.c */
NRRD_EXPORT const char nrrdTypePrintfStr[NRRD_TYPE_MAX+1][AIR_STRLEN_SMALL];
NRRD_EXPORT const size_t nrrdTypeSize[NRRD_TYPE_MAX+1];
NRRD_EXPORT const double nrrdTypeMin[NRRD_TYPE_MAX+1];
NRRD_EXPORT const double nrrdTypeMax[NRRD_TYPE_MAX+1];
NRRD_EXPORT const int nrrdTypeIsIntegral[NRRD_TYPE_MAX+1];
NRRD_EXPORT const int nrrdTypeIsUnsigned[NRRD_TYPE_MAX+1];

/******** pseudo-constructors, pseudo-destructors, and such */
/* methodsNrrd.c */
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT const int nrrdPresent;
/* ---- END non-NrrdIO */
NRRD_EXPORT NrrdIoState *nrrdIoStateNew(void);
NRRD_EXPORT void nrrdIoStateInit(NrrdIoState *nio);
NRRD_EXPORT NrrdIoState *nrrdIoStateNix(NrrdIoState *nio);
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT NrrdResampleInfo *nrrdResampleInfoNew(void);
NRRD_EXPORT NrrdResampleInfo *nrrdResampleInfoNix(NrrdResampleInfo *info);
NRRD_EXPORT NrrdKernelSpec *nrrdKernelSpecNew();
NRRD_EXPORT NrrdKernelSpec *nrrdKernelSpecCopy(const NrrdKernelSpec *ksp);
NRRD_EXPORT void nrrdKernelSpecSet(NrrdKernelSpec *ksp, const NrrdKernel *k,
                                   const double kparm[NRRD_KERNEL_PARMS_NUM]);
NRRD_EXPORT void nrrdKernelParmSet(const NrrdKernel **kP,
                                   double kparm[NRRD_KERNEL_PARMS_NUM],
                                   NrrdKernelSpec *ksp);
NRRD_EXPORT NrrdKernelSpec *nrrdKernelSpecNix(NrrdKernelSpec *ksp);
/* ---- END non-NrrdIO */
NRRD_EXPORT void nrrdInit(Nrrd *nrrd);
NRRD_EXPORT Nrrd *nrrdNew(void);
NRRD_EXPORT Nrrd *nrrdNix(Nrrd *nrrd);
NRRD_EXPORT Nrrd *nrrdEmpty(Nrrd *nrrd);
NRRD_EXPORT Nrrd *nrrdNuke(Nrrd *nrrd);
NRRD_EXPORT int nrrdWrap_nva(Nrrd *nrrd, void *data, int type,
                             unsigned int dim, const size_t *size);
NRRD_EXPORT int nrrdWrap_va(Nrrd *nrrd, void *data, int type, unsigned int dim,
                            ... /* size_t sx, sy, .., axis(dim-1) size */);
NRRD_EXPORT void nrrdBasicInfoInit(Nrrd *nrrd, int excludeBitflag);
NRRD_EXPORT int nrrdBasicInfoCopy(Nrrd *nout, const Nrrd *nin,
                                  int excludeBitflag);
NRRD_EXPORT int nrrdCopy(Nrrd *nout, const Nrrd *nin);
NRRD_EXPORT int nrrdAlloc_nva(Nrrd *nrrd, int type, unsigned int dim,
                              const size_t *size);
NRRD_EXPORT int nrrdAlloc_va(Nrrd *nrrd, int type, unsigned int dim,
                             ... /* size_t sx, sy, .., axis(dim-1) size */);
NRRD_EXPORT int nrrdMaybeAlloc_nva(Nrrd *nrrd, int type, unsigned int dim,
                                   const size_t *size);
NRRD_EXPORT int nrrdMaybeAlloc_va(Nrrd *nrrd, int type, unsigned int dim,
                                  ... /* size_t sx, sy, .., ax(dim-1) size */);
NRRD_EXPORT int nrrdPPM(Nrrd *, size_t sx, size_t sy);
NRRD_EXPORT int nrrdPGM(Nrrd *, size_t sx, size_t sy);

/******** axis info related */
/* axis.c */
NRRD_EXPORT int nrrdKindIsDomain(int kind);
NRRD_EXPORT unsigned int nrrdKindSize(int kind);
NRRD_EXPORT int nrrdAxisInfoCopy(Nrrd *nout, const Nrrd *nin,
                                 const int *axmap, int excludeBitflag);
NRRD_EXPORT void nrrdAxisInfoSet_nva(Nrrd *nin, int axInfo, const void *info);
NRRD_EXPORT void nrrdAxisInfoSet_va(Nrrd *nin, int axInfo,
                                    ... /* const void* */);
NRRD_EXPORT void nrrdAxisInfoGet_nva(const Nrrd *nrrd, int axInfo, void *info);
NRRD_EXPORT void nrrdAxisInfoGet_va(const Nrrd *nrrd, int axInfo,
                                    ... /* ??? */);
NRRD_EXPORT double nrrdAxisInfoPos(const Nrrd *nrrd, unsigned int ax,
                                   double idx);
NRRD_EXPORT double nrrdAxisInfoIdx(const Nrrd *nrrd, unsigned int ax,
                                   double pos);
NRRD_EXPORT void nrrdAxisInfoPosRange(double *loP, double *hiP,
                                      const Nrrd *nrrd, unsigned int ax,
                                      double loIdx, double hiIdx);
NRRD_EXPORT void nrrdAxisInfoIdxRange(double *loP, double *hiP,
                                      const Nrrd *nrrd, unsigned int ax,
                                      double loPos, double hiPos);
NRRD_EXPORT void nrrdAxisInfoSpacingSet(Nrrd *nrrd, unsigned int ax);
NRRD_EXPORT void nrrdAxisInfoMinMaxSet(Nrrd *nrrd, unsigned int ax,
                                       int defCenter);
NRRD_EXPORT unsigned int nrrdDomainAxesGet(const Nrrd *nrrd,
                                           unsigned int axisIdx[NRRD_DIM_MAX]);
NRRD_EXPORT unsigned int nrrdRangeAxesGet(const Nrrd *nrrd,
                                          unsigned int axisIdx[NRRD_DIM_MAX]);
NRRD_EXPORT unsigned int nrrdSpatialAxesGet(const Nrrd *nrrd,
                                            unsigned int
                                            axisIdx[NRRD_DIM_MAX]);
NRRD_EXPORT unsigned int nrrdNonSpatialAxesGet(const Nrrd *nrrd,
                                               unsigned int
                                               axisIdx[NRRD_DIM_MAX]);
NRRD_EXPORT int nrrdSpacingCalculate(const Nrrd *nrrd, unsigned int ax,
                                     double *spacing,
                                     double vector[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT int nrrdOrientationReduce(Nrrd *nout, const Nrrd *nin,
                                      int setMinsFromOrigin);

/******** simple things */
/* simple.c */
NRRD_EXPORT const char *nrrdBiffKey;
NRRD_EXPORT unsigned int nrrdSpaceDimension(int space);
NRRD_EXPORT int nrrdSpaceSet(Nrrd *nrrd, int space);
NRRD_EXPORT int nrrdSpaceDimensionSet(Nrrd *nrrd, unsigned int spaceDim);
NRRD_EXPORT unsigned int nrrdSpaceOriginGet(const Nrrd *nrrd,
                                            double vector[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT int nrrdSpaceOriginSet(Nrrd *nrrd,
                                   double vector[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT int nrrdOriginCalculate(const Nrrd *nrrd,
                                    unsigned int *axisIdx,
                                    unsigned int axisIdxNum,
                                    int defaultCenter, double *origin);
NRRD_EXPORT int nrrdContentSet_va(Nrrd *nout, const char *func,
                                  const Nrrd *nin, const char *format,
                                  ... /* printf-style arg list */ );
NRRD_EXPORT void nrrdDescribe(FILE *file, const Nrrd *nrrd);
NRRD_EXPORT int nrrdCheck(const Nrrd *nrrd);
NRRD_EXPORT int _nrrdCheck(const Nrrd *nrrd, int checkData, int useBiff);
NRRD_EXPORT size_t nrrdElementSize(const Nrrd *nrrd);
NRRD_EXPORT size_t nrrdElementNumber(const Nrrd *nrrd);
NRRD_EXPORT int nrrdSanity(void);
NRRD_EXPORT int nrrdSameSize(const Nrrd *n1, const Nrrd *n2, int useBiff);
NRRD_EXPORT void nrrdSpaceVecCopy(double dst[NRRD_SPACE_DIM_MAX], 
                                  const double src[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT void nrrdSpaceVecScaleAdd2(double sum[NRRD_SPACE_DIM_MAX], 
                                       double sclA, 
                                       const double vecA[NRRD_SPACE_DIM_MAX],
                                       double sclB, 
                                       const double vecB[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT void nrrdSpaceVecScale(double out[NRRD_SPACE_DIM_MAX], 
                                   double scl, 
                                   const double vec[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT double nrrdSpaceVecNorm(int sdim,
                                    const double vec[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT int nrrdSpaceVecExists(int sdim,
                                   double vec[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT void nrrdSpaceVecSetNaN(double vec[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT void nrrdSpaceVecSetZero(double vec[NRRD_SPACE_DIM_MAX]);
NRRD_EXPORT void nrrdZeroSet(Nrrd *nout);

/******** comments related */
/* comment.c */
NRRD_EXPORT int nrrdCommentAdd(Nrrd *nrrd, const char *str);
NRRD_EXPORT void nrrdCommentClear(Nrrd *nrrd);
NRRD_EXPORT int nrrdCommentCopy(Nrrd *nout, const Nrrd *nin);

/******** key/value pairs */
/* keyvalue.c */
NRRD_EXPORT unsigned int nrrdKeyValueSize(const Nrrd *nrrd);
NRRD_EXPORT int nrrdKeyValueAdd(Nrrd *nrrd,
                                const char *key, const char *value);
NRRD_EXPORT char *nrrdKeyValueGet(const Nrrd *nrrd, const char *key);
NRRD_EXPORT void nrrdKeyValueIndex(const Nrrd *nrrd, 
                                   char **keyP, char **valueP,
                                   unsigned int ki);
NRRD_EXPORT int nrrdKeyValueErase(Nrrd *nrrd, const char *key);
NRRD_EXPORT void nrrdKeyValueClear(Nrrd *nrrd);
NRRD_EXPORT int nrrdKeyValueCopy(Nrrd *nout, const Nrrd *nin);

/******** endian related */
/* endianNrrd.c */
NRRD_EXPORT void nrrdSwapEndian(Nrrd *nrrd);

/******** getting information to and from files */
/* formatXXX.c */
NRRD_EXPORT const NrrdFormat *const nrrdFormatNRRD;
NRRD_EXPORT const NrrdFormat *const nrrdFormatPNM;
NRRD_EXPORT const NrrdFormat *const nrrdFormatPNG;
NRRD_EXPORT const NrrdFormat *const nrrdFormatVTK;
NRRD_EXPORT const NrrdFormat *const nrrdFormatText;
NRRD_EXPORT const NrrdFormat *const nrrdFormatEPS;
/* format.c */
NRRD_EXPORT const NrrdFormat *const nrrdFormatUnknown;
NRRD_EXPORT const NrrdFormat *
  const nrrdFormatArray[NRRD_FORMAT_TYPE_MAX+1];

/* encodingXXX.c */
NRRD_EXPORT const NrrdEncoding *const nrrdEncodingRaw;
NRRD_EXPORT const NrrdEncoding *const nrrdEncodingAscii;
NRRD_EXPORT const NrrdEncoding *const nrrdEncodingHex;
NRRD_EXPORT const NrrdEncoding *const nrrdEncodingGzip;
NRRD_EXPORT const NrrdEncoding *const nrrdEncodingBzip2;
/* encoding.c */
NRRD_EXPORT const NrrdEncoding *const nrrdEncodingUnknown;
NRRD_EXPORT const NrrdEncoding *
  const nrrdEncodingArray[NRRD_ENCODING_TYPE_MAX+1];

/* parseNrrd.c */
/* this needs the "FILE *file" first arg for the sole reason that
   parsing a "data file: " field which identifies a LIST must then
   read in all the data filenames from the same file */
NRRD_EXPORT int (*nrrdFieldInfoParse[NRRD_FIELD_MAX+1])(FILE *file, Nrrd *nrrd,
                                                        NrrdIoState *nio,
                                                        int useBiff);
NRRD_EXPORT unsigned int _nrrdDataFNNumber(NrrdIoState *nio);
NRRD_EXPORT int _nrrdContainsPercentThisAndMore(const char *str, char thss);
NRRD_EXPORT int _nrrdDataFNCheck(NrrdIoState *nio, Nrrd *nrrd, int useBiff);

/* read.c */
NRRD_EXPORT int _nrrdOneLine(unsigned int *lenP, NrrdIoState *nio, FILE *file);
NRRD_EXPORT int nrrdLineSkip(FILE *dataFile, NrrdIoState *nio);
NRRD_EXPORT int nrrdByteSkip(FILE *dataFile, Nrrd *nrrd, NrrdIoState *nio);
NRRD_EXPORT int nrrdLoad(Nrrd *nrrd, const char *filename, NrrdIoState *nio);
NRRD_EXPORT int nrrdLoadMulti(Nrrd *const *nin, unsigned int ninLen,
                              const char *fnameFormat,
                              unsigned int numStart, NrrdIoState *nio);
NRRD_EXPORT int nrrdRead(Nrrd *nrrd, FILE *file, NrrdIoState *nio);
NRRD_EXPORT int nrrdStringRead(Nrrd *nrrd, const char *string,
                               NrrdIoState *nio);

/* write.c */
NRRD_EXPORT int nrrdIoStateSet(NrrdIoState *nio, int parm, int value);
NRRD_EXPORT int nrrdIoStateEncodingSet(NrrdIoState *nio,
                                       const NrrdEncoding *encoding);
NRRD_EXPORT int nrrdIoStateFormatSet(NrrdIoState *nio, 
                                     const NrrdFormat *format);
NRRD_EXPORT int nrrdIoStateGet(NrrdIoState *nio, int parm);
NRRD_EXPORT const NrrdEncoding *nrrdIoStateEncodingGet(NrrdIoState *nio);
NRRD_EXPORT const NrrdFormat *nrrdIoStateFormatGet(NrrdIoState *nio);
NRRD_EXPORT int nrrdSave(const char *filename, const Nrrd *nrrd, 
                         NrrdIoState *nio);
NRRD_EXPORT int nrrdSaveMulti(const char *fnameFormat,
                              const Nrrd *const *nin, unsigned int ninLen,
                              unsigned int numStart, NrrdIoState *nio);
NRRD_EXPORT int nrrdWrite(FILE *file, const Nrrd *nrrd, 
                          NrrdIoState *nio);
NRRD_EXPORT int nrrdStringWrite(char **stringP, const Nrrd *nrrd,
                                NrrdIoState *nio);

/******** getting value into and out of an array of general type, and
   all other simplistic functionality pseudo-parameterized by type */
/* accessors.c */
NRRD_EXPORT double (*nrrdDLoad[NRRD_TYPE_MAX+1])(const void *v);
NRRD_EXPORT float  (*nrrdFLoad[NRRD_TYPE_MAX+1])(const void *v);
NRRD_EXPORT int    (*nrrdILoad[NRRD_TYPE_MAX+1])(const void *v);
NRRD_EXPORT unsigned int (*nrrdUILoad[NRRD_TYPE_MAX+1])(const void *v);
NRRD_EXPORT double (*nrrdDStore[NRRD_TYPE_MAX+1])(void *v, double d);
NRRD_EXPORT float  (*nrrdFStore[NRRD_TYPE_MAX+1])(void *v, float f);
NRRD_EXPORT int    (*nrrdIStore[NRRD_TYPE_MAX+1])(void *v, int j);
NRRD_EXPORT unsigned int (*nrrdUIStore[NRRD_TYPE_MAX+1])(void *v,
                                                         unsigned int j);
NRRD_EXPORT double (*nrrdDLookup[NRRD_TYPE_MAX+1])(const void *v, size_t I);
NRRD_EXPORT float  (*nrrdFLookup[NRRD_TYPE_MAX+1])(const void *v, size_t I);
NRRD_EXPORT int    (*nrrdILookup[NRRD_TYPE_MAX+1])(const void *v, size_t I);
NRRD_EXPORT unsigned int (*nrrdUILookup[NRRD_TYPE_MAX+1])(const void *v,
                                                          size_t I);
NRRD_EXPORT double (*nrrdDInsert[NRRD_TYPE_MAX+1])(void *v, size_t I,
                                                   double d);
NRRD_EXPORT float  (*nrrdFInsert[NRRD_TYPE_MAX+1])(void *v, size_t I,
                                                   float f);
NRRD_EXPORT int    (*nrrdIInsert[NRRD_TYPE_MAX+1])(void *v, size_t I,
                                                   int j);
NRRD_EXPORT unsigned int (*nrrdUIInsert[NRRD_TYPE_MAX+1])(void *v, size_t I,
                                                          unsigned int j);
NRRD_EXPORT int    (*nrrdSprint[NRRD_TYPE_MAX+1])(char *, const void *);
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT int    (*nrrdFprint[NRRD_TYPE_MAX+1])(FILE *, const void *);
NRRD_EXPORT void (*nrrdMinMaxExactFind[NRRD_TYPE_MAX+1])(void *minP, 
                                                         void *maxP,
                                                         int *hasNonExistP,
                                                         const Nrrd *nrrd);
NRRD_EXPORT int (*nrrdValCompare[NRRD_TYPE_MAX+1])(const void *, const void *);
NRRD_EXPORT int (*nrrdValCompareInv[NRRD_TYPE_MAX+1])(const void *, const void *);
/* ---- END non-NrrdIO */


/******** permuting, shuffling, and all flavors of reshaping */
/* reorder.c */
NRRD_EXPORT int nrrdAxesInsert(Nrrd *nout, const Nrrd *nin, unsigned int ax);
NRRD_EXPORT int nrrdInvertPerm(unsigned int *invp, const unsigned int *perm,
                               unsigned int n);
NRRD_EXPORT int nrrdAxesPermute(Nrrd *nout, const Nrrd *nin,
                                const unsigned int *axes);
NRRD_EXPORT int nrrdShuffle(Nrrd *nout, const Nrrd *nin, unsigned int axis,
                            const size_t *perm);
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT int nrrdAxesSwap(Nrrd *nout, const Nrrd *nin,
                             unsigned int ax1, unsigned int ax2);
NRRD_EXPORT int nrrdFlip(Nrrd *nout, const Nrrd *nin, unsigned int axis);
NRRD_EXPORT int nrrdJoin(Nrrd *nout, const Nrrd *const *nin,
                         unsigned int numNin, 
                         unsigned int axis, int incrDim);
NRRD_EXPORT int nrrdReshape_va(Nrrd *nout, const Nrrd *nin, unsigned int dim,
                               ... /* sx, sy, .., axis(dim-1) size */ );
NRRD_EXPORT int nrrdReshape_nva(Nrrd *nout, const Nrrd *nin,
                                unsigned int dim, const size_t *size);
NRRD_EXPORT int nrrdAxesSplit(Nrrd *nout, const Nrrd *nin, unsigned int ax,
                              size_t sizeFast, size_t sizeSlow);
NRRD_EXPORT int nrrdAxesDelete(Nrrd *nout, const Nrrd *nin, unsigned int ax);
NRRD_EXPORT int nrrdAxesMerge(Nrrd *nout, const Nrrd *nin, unsigned int ax);
NRRD_EXPORT int nrrdBlock(Nrrd *nout, const Nrrd *nin);
NRRD_EXPORT int nrrdUnblock(Nrrd *nout, const Nrrd *nin, int type);
NRRD_EXPORT int nrrdTile2D(Nrrd *nout, const Nrrd *nin,
                           unsigned int ax0, unsigned int ax1,
                           unsigned int axSplit,
                           size_t sizeFast, size_t sizeSlow);
NRRD_EXPORT int nrrdUntile2D(Nrrd *nout, const Nrrd *nin, 
                             unsigned int ax0, unsigned int ax1,
                             unsigned int axMerge, size_t sizeFast,
                             size_t sizeSlow);

/******** things useful with hest */
/* hestNrrd.c */
NRRD_EXPORT hestCB *nrrdHestNrrd;
NRRD_EXPORT hestCB *nrrdHestKernelSpec;
NRRD_EXPORT hestCB *nrrdHestIter;

/******** nrrd value iterator gadget */
/* iter.c */
NRRD_EXPORT NrrdIter *nrrdIterNew(void);
NRRD_EXPORT void nrrdIterSetValue(NrrdIter *iter, double val);
NRRD_EXPORT void nrrdIterSetNrrd(NrrdIter *iter, const Nrrd *nrrd);
NRRD_EXPORT void nrrdIterSetOwnNrrd(NrrdIter *iter, Nrrd *nrrd);
NRRD_EXPORT double nrrdIterValue(NrrdIter *iter);
NRRD_EXPORT char *nrrdIterContent(NrrdIter *iter);
NRRD_EXPORT NrrdIter *nrrdIterNix(NrrdIter *iter);

/******** expressing the range of values in a nrrd */
/* range.c */
NRRD_EXPORT NrrdRange *nrrdRangeNew(double min, double max);
NRRD_EXPORT NrrdRange *nrrdRangeCopy(const NrrdRange *range);
NRRD_EXPORT NrrdRange *nrrdRangeNix(NrrdRange *range);
NRRD_EXPORT void nrrdRangeReset(NrrdRange *range);
NRRD_EXPORT void nrrdRangeSet(NrrdRange *range,
                              const Nrrd *nrrd, int blind8BitRange);
NRRD_EXPORT void nrrdRangeSafeSet(NrrdRange *range,
                                  const Nrrd *nrrd, int blind8BitRange);
NRRD_EXPORT NrrdRange *nrrdRangeNewSet(const Nrrd *nrrd, int blind8BitRange);
NRRD_EXPORT int nrrdHasNonExist(const Nrrd *nrrd);

/******** some of the point-wise value remapping, conversion, and such */
/* map.c */
NRRD_EXPORT float  (*nrrdFClamp[NRRD_TYPE_MAX+1])(float);
NRRD_EXPORT double (*nrrdDClamp[NRRD_TYPE_MAX+1])(double);
NRRD_EXPORT int nrrdConvert(Nrrd *nout, const Nrrd *nin, int type);
NRRD_EXPORT int nrrdClampConvert(Nrrd *nout, const Nrrd *nin, int type);
NRRD_EXPORT int nrrdQuantize(Nrrd *nout, const Nrrd *nin,
                             const NrrdRange *range, unsigned int bits);

NRRD_EXPORT int nrrdUnquantize(Nrrd *nout, const Nrrd *nin, int type);
NRRD_EXPORT int nrrdHistoEq(Nrrd *nout, const Nrrd *nin, Nrrd **nhistP,
                            unsigned int bins,
                            unsigned int smart, float amount);

/******** rest of point-wise value remapping, and "color"mapping */
/* apply1D.c */
NRRD_EXPORT int nrrdApply1DLut(Nrrd *nout,
                               const Nrrd *nin, const NrrdRange *range,
                               const Nrrd *nlut, int typeOut, int rescale);
NRRD_EXPORT int nrrdApplyMulti1DLut(Nrrd *nout, const Nrrd *nin,
                                    const NrrdRange *range, const Nrrd *nmlut,
                                    int typeOut, int rescale);
NRRD_EXPORT int nrrdApply1DRegMap(Nrrd *nout,
                                  const Nrrd *nin, const NrrdRange *range,
                                  const Nrrd *nmap, int typeOut, int rescale);
NRRD_EXPORT int nrrdApplyMulti1DRegMap(Nrrd *nout, const Nrrd *nin,
                                       const NrrdRange *range,
                                       const Nrrd *nmmap,
                                       int typeOut, int rescale);
NRRD_EXPORT int nrrd1DIrregMapCheck(const Nrrd *nmap);
NRRD_EXPORT int nrrd1DIrregAclGenerate(Nrrd *nacl, const Nrrd *nmap,
                                       size_t aclLen);
NRRD_EXPORT int nrrd1DIrregAclCheck(const Nrrd *nacl);
NRRD_EXPORT int nrrdApply1DIrregMap(Nrrd *nout,
                                    const Nrrd *nin, const NrrdRange *range, 
                                    const Nrrd *nmap, const Nrrd *nacl,
                                    int typeOut, int rescale);
NRRD_EXPORT int nrrdApply1DSubstitution(Nrrd *nout,
                                        const Nrrd *nin, const Nrrd *nsubst);

/* apply2D.c */
NRRD_EXPORT int nrrdApply2DLut(Nrrd *nout,
                               const Nrrd *nin, unsigned int domainAxis,
                               const NrrdRange *range0,
                               const NrrdRange *range1,
                               const Nrrd *nlut, int typeOut,
                               int rescale0, int rescale1);

/* ---- END non-NrrdIO */

/******** sampling, slicing, cropping */
/* subset.c */
NRRD_EXPORT int nrrdSlice(Nrrd *nout, const Nrrd *nin,
                          unsigned int axis, size_t pos);
NRRD_EXPORT int nrrdCrop(Nrrd *nout, const Nrrd *nin,
                         size_t *min, size_t *max);
/* ---- BEGIN non-NrrdIO */
NRRD_EXPORT int nrrdSliceSelect(Nrrd *noutAbove, Nrrd *noutBelow,
                                const Nrrd *nin, unsigned int axi,
                                Nrrd *nline, double thresh);
NRRD_EXPORT int nrrdSample_nva(void *val, const Nrrd *nin,
                               const size_t *coord);
NRRD_EXPORT int nrrdSample_va(void *val, const Nrrd *nin,
                              ... /* size_t idx0, idx1, .., idx(dim-1) */ );
NRRD_EXPORT int nrrdSimpleCrop(Nrrd *nout, const Nrrd *nin, unsigned int crop);
NRRD_EXPORT int nrrdCropAuto(Nrrd *nout, const Nrrd *nin, 
                             size_t _min[NRRD_DIM_MAX],
                             size_t _max[NRRD_DIM_MAX],
                             const unsigned int *keep, unsigned int keepNum,
                             int measr, double frac, int offset);

/******** padding */
/* superset.c */
NRRD_EXPORT int nrrdSplice(Nrrd *nout, const Nrrd *nin, const Nrrd *nslice,
                           unsigned int axis, size_t pos);
NRRD_EXPORT int nrrdPad_nva(Nrrd *nout, const Nrrd *nin,
                            const ptrdiff_t *min, const ptrdiff_t *max,
                            int boundary, double padValue);
NRRD_EXPORT int nrrdPad_va(Nrrd *nout, const Nrrd *nin,
                           const ptrdiff_t *min, const ptrdiff_t *max,
                           int boundary,
                           ... /* double value (if nrrdBoundaryPad) */);
NRRD_EXPORT int nrrdSimplePad_nva(Nrrd *nout, const Nrrd *nin,
                                  unsigned int pad,
                                  int boundary, double padValue);
NRRD_EXPORT int nrrdSimplePad_va(Nrrd *nout, const Nrrd *nin, unsigned int pad,
                                 int boundary,
                                 ... /* double value (if nrrdBoundaryPad) */);
NRRD_EXPORT int nrrdInset(Nrrd *nout, const Nrrd *nin,
                          const Nrrd *nsub, const size_t *min);

/******** measuring and projecting */
/* measure.c */
NRRD_EXPORT void (*nrrdMeasureLine[NRRD_MEASURE_MAX+1])(void *ans, int ansType,
                                                        const void *line,
                                                        int lineType,
                                                        size_t lineLen,
                                                        double axMin,
                                                        double axMax);
NRRD_EXPORT int nrrdProject(Nrrd *nout, const Nrrd *nin,
                            unsigned int axis, int measr, int type);

/********* various kinds of histograms and their analysis */
/* histogram.c */
NRRD_EXPORT int nrrdHisto(Nrrd *nout, const Nrrd *nin, const NrrdRange *range,
                          const Nrrd *nwght, size_t bins, int type);
NRRD_EXPORT int nrrdHistoCheck(const Nrrd *nhist);
NRRD_EXPORT int nrrdHistoDraw(Nrrd *nout, const Nrrd *nin, size_t sy,
                              int showLog, double max);
NRRD_EXPORT int nrrdHistoAxis(Nrrd *nout, const Nrrd *nin,
                              const NrrdRange *range,
                              unsigned int axis, size_t bins, int type);
NRRD_EXPORT int nrrdHistoJoint(Nrrd *nout, const Nrrd *const *nin,
                               const NrrdRange *const *range,
                               unsigned int ninNum,
                               const Nrrd *nwght, const size_t *bins,
                               int type, const int *clamp);
NRRD_EXPORT int nrrdHistoThresholdOtsu(double *threshP, const Nrrd *nhist,
                                       double expo);

/******** arithmetic and math on nrrds */
/* arith.c */
NRRD_EXPORT int nrrdArithGamma(Nrrd *nout, const Nrrd *nin,
                               const NrrdRange *range, double gamma);
NRRD_EXPORT int nrrdArithUnaryOp(Nrrd *nout, int op, const Nrrd *nin);
NRRD_EXPORT int nrrdArithBinaryOp(Nrrd *nout, int op,
                                  const Nrrd *ninA, const Nrrd *ninB);
NRRD_EXPORT int nrrdArithTernaryOp(Nrrd *nout, int op,
                                   const Nrrd *ninA, const Nrrd *ninB,
                                   const Nrrd *ninC);
NRRD_EXPORT int nrrdArithAffine(Nrrd *nout, double minIn,
                                const Nrrd *nin, double maxIn,
                                double minOut, double maxOut,
                                int clamp);
NRRD_EXPORT int nrrdArithIterBinaryOp(Nrrd *nout, int op,
                                      NrrdIter *inA, NrrdIter *inB);
NRRD_EXPORT int nrrdArithIterBinaryOpSelect(Nrrd *nout, int op,
                                            NrrdIter *inA, NrrdIter *inB,
                                            unsigned int which);
NRRD_EXPORT int nrrdArithIterTernaryOp(Nrrd *nout, int op,
                                       NrrdIter *inA, NrrdIter *inB,
                                       NrrdIter *inC);
NRRD_EXPORT int nrrdArithIterTernaryOpSelect(Nrrd *nout, int op,
                                             NrrdIter *inA, NrrdIter *inB,
                                             NrrdIter *inC,
                                             unsigned int which);
NRRD_EXPORT int nrrdArithIterAffine(Nrrd *nout, NrrdIter *minIn,
                                    NrrdIter *in, NrrdIter *maxIn,
                                    NrrdIter *minOut, NrrdIter *maxOut,
                                    int clamp);

/******** filtering and re-sampling */
/* filt.c */
NRRD_EXPORT int nrrdCheapMedian(Nrrd *nout, const Nrrd *nin,
                                int pad, int mode,
                                unsigned int radius, float wght,
                                unsigned int bins);
NRRD_EXPORT int nrrdDistanceL2(Nrrd *nout, const Nrrd *nin,
                               int typeOut, const int *axisDo,
                               double thresh, int insideHigher);
NRRD_EXPORT int nrrdDistanceL2Biased(Nrrd *nout, const Nrrd *nin,
                                     int typeOut, const int *axisDo,
                                     double thresh, double bias,
                                     int insideHigher);
NRRD_EXPORT int nrrdDistanceL2Signed(Nrrd *nout, const Nrrd *nin,
                                     int typeOut, const int *axisDo,
                                     double thresh, int insideHigher);

/******** deringNrrd.c: deringing CT */
typedef struct {
  /* -------- INPUT */
  int verbose,                 /* blah blah blah */
    linearInterp,              /* instead of nearest neighbor in polar txf */
    verticalSeam;              /* dering left and right sides of image 
                                  separately, asserting that there are no
                                  rings along vertical line through center */
  const Nrrd *nin;             /* array to dering */
  double center[2],            /* location of recon center in index space
                                  of fastest two axes */
    clampPerc[2],              /* percentiles above 0.0 and below 1.0 at which
                                  to clamp values (for ring estimation) from
                                  below and above, respectively. Setting both
                                  to zero means no such clamping */
    radiusScale;               /* radius scaling to polar txf */
  unsigned int thetaNum,       /* number of samples in theta in polar txf */
    clampHistoBins;            /* number of bins in histogram for computing
                                  clamping in terms of percentiles */
  const NrrdKernel *rkernel;   /* kernel for radial high-pass filtering */
  double rkparm[NRRD_KERNEL_PARMS_NUM];
  const NrrdKernel *tkernel;   /* kernel for blurring along theta */
  double tkparm[NRRD_KERNEL_PARMS_NUM];
  /* -------- INTERNAL */
  const char *cdataIn;         /* nin->data as char* */
  char *cdataOut;              /* nout->data as char* */
  size_t sliceSize;            /* sizeof slice */
  int clampDo;                 /* is there really is clamping to be done */
  double clamp[2];             /* clamping values implied by clampPerc */
  /* -------- OUTPUT */
  double ringMagnitude;        /* L2 norm of ring map; may be useful for
                                  optimizing an (unknown) center location */
} NrrdDeringContext;
NRRD_EXPORT NrrdDeringContext *nrrdDeringContextNew(void);
NRRD_EXPORT NrrdDeringContext *nrrdDeringContextNix(NrrdDeringContext *drc);
NRRD_EXPORT int nrrdDeringVerboseSet(NrrdDeringContext *drc, int verbose);
NRRD_EXPORT int nrrdDeringLinearInterpSet(NrrdDeringContext *drc,
                                          int linterp);
NRRD_EXPORT int nrrdDeringVerticalSeamSet(NrrdDeringContext *drc,
                                          int vertSeam);
NRRD_EXPORT int nrrdDeringInputSet(NrrdDeringContext *drc, const Nrrd *nin);
NRRD_EXPORT int nrrdDeringCenterSet(NrrdDeringContext *drc,
                                    double cx, double cy);
NRRD_EXPORT int nrrdDeringClampPercSet(NrrdDeringContext *drc,
                                       double lo, double hi);
NRRD_EXPORT int nrrdDeringClampHistoBinsSet(NrrdDeringContext *drc,
                                            unsigned int bins);
NRRD_EXPORT int nrrdDeringRadiusScaleSet(NrrdDeringContext *drc, double rsc);
NRRD_EXPORT int nrrdDeringThetaNumSet(NrrdDeringContext *drc,
                                      unsigned int thetaNum);
NRRD_EXPORT int nrrdDeringRadialKernelSet(NrrdDeringContext *drc,
                                   const NrrdKernel *rkernel,
                                   const double rkparm[NRRD_KERNEL_PARMS_NUM]);
NRRD_EXPORT int nrrdDeringThetaKernelSet(NrrdDeringContext *drc,
                                   const NrrdKernel *tkernel,
                                   const double tkparm[NRRD_KERNEL_PARMS_NUM]);
NRRD_EXPORT int nrrdDeringExecute(NrrdDeringContext *drc, Nrrd *nout);

/*
******** nrrdResample_t typedef
**
** type used to hold filter sample locations and weights in
** nrrdSpatialResample(), and to hold the intermediate sampling
** results.  Not as good as templating, but better than hard-coding
** float versus double.  Actually, the difference between float and
** double is not exposed in any functions or objects declared in this
** header; it is entirely internal to the operation of
** nrrdSpatialResample().
**
** Choose by setting "#if" arg to 1 (for float) or 0 (for double)
*/
#if 0
typedef float nrrdResample_t;
#  define nrrdResample_nt nrrdTypeFloat
#  define NRRD_RESAMPLE_FLOAT 1
#else
typedef double nrrdResample_t;
#  define nrrdResample_nt nrrdTypeDouble
#  define NRRD_RESAMPLE_FLOAT 0
#endif

/* resampleContext.c */
NRRD_EXPORT NrrdResampleContext *nrrdResampleContextNew();
NRRD_EXPORT NrrdResampleContext *nrrdResampleContextNix(NrrdResampleContext *);
NRRD_EXPORT int nrrdResampleDefaultCenterSet(NrrdResampleContext *rsmc,
                                             int center);
NRRD_EXPORT int nrrdResampleNonExistentSet(NrrdResampleContext *rsmc,
                                           int nonExistent);
NRRD_EXPORT int nrrdResampleNrrdSet(NrrdResampleContext *rsmc,
                                    const Nrrd *nin);
NRRD_EXPORT int nrrdResampleInputSet(NrrdResampleContext *rsmc,
                                     const Nrrd *nin);
NRRD_EXPORT int nrrdResampleKernelSet(NrrdResampleContext *rsmc,
                                      unsigned int axIdx, 
                                      const NrrdKernel *kernel,
                                      double kparm[NRRD_KERNEL_PARMS_NUM]);
NRRD_EXPORT int nrrdResampleSamplesSet(NrrdResampleContext *rsmc,
                                       unsigned int axIdx,
                                       size_t samples);
NRRD_EXPORT int nrrdResampleRangeSet(NrrdResampleContext *rsmc,
                                     unsigned int axIdx,
                                     double min, double max);
NRRD_EXPORT int nrrdResampleOverrideCenterSet(NrrdResampleContext *rsmc,
                                              unsigned int axIdx,
                                              int center);
NRRD_EXPORT int nrrdResampleRangeFullSet(NrrdResampleContext *rsmc,
                                         unsigned int axIdx);
NRRD_EXPORT int nrrdResampleBoundarySet(NrrdResampleContext *rsmc,
                                        int boundary);
NRRD_EXPORT int nrrdResamplePadValueSet(NrrdResampleContext *rsmc,
                                        double padValue);
NRRD_EXPORT int nrrdResampleTypeOutSet(NrrdResampleContext *rsmc,
                                       int typeOut);
NRRD_EXPORT int nrrdResampleRenormalizeSet(NrrdResampleContext *rsmc,
                                           int renormalize);
NRRD_EXPORT int nrrdResampleRoundSet(NrrdResampleContext *rsmc,
                                     int round);
NRRD_EXPORT int nrrdResampleClampSet(NrrdResampleContext *rsmc,
                                     int clamp);
NRRD_EXPORT int nrrdResampleExecute(NrrdResampleContext *rsmc, Nrrd *nout);

/* resampleNrrd.c */
NRRD_EXPORT int nrrdSpatialResample(Nrrd *nout, const Nrrd *nin,
                                    const NrrdResampleInfo *info);
NRRD_EXPORT int nrrdSimpleResample(Nrrd *nout, const Nrrd *nin,
                                   const NrrdKernel *kernel,
                                   const double *parm,
                                   const size_t *samples,
                                   const double *scalings);

/******** connected component extraction and manipulation */
/* ccmethods.c */
NRRD_EXPORT int nrrdCCValid(const Nrrd *nin);
NRRD_EXPORT unsigned int nrrdCCSize(Nrrd *nout, const Nrrd *nin);
NRRD_EXPORT unsigned int nrrdCCMax(const Nrrd *nin);
NRRD_EXPORT unsigned int nrrdCCNum(const Nrrd *nin);

/* cc.c */
NRRD_EXPORT int nrrdCCFind(Nrrd *nout, Nrrd **nvalP, const Nrrd *nin,
                           int type, unsigned int conny);
NRRD_EXPORT int nrrdCCAdjacency(Nrrd *nout, const Nrrd *nin,
                                unsigned int conny);
NRRD_EXPORT int nrrdCCMerge(Nrrd *nout, const Nrrd *nin, Nrrd *nval,
                            int dir, unsigned int maxSize,
                            unsigned int maxNeighbor, unsigned int conny);
NRRD_EXPORT int nrrdCCRevalue (Nrrd *nout, const Nrrd *nin, const Nrrd *nval);
NRRD_EXPORT int nrrdCCSettle(Nrrd *nout, Nrrd **nvalP, const Nrrd *nin);

/******** FFT */
/* fftNrrd.c */
NRRD_EXPORT const int nrrdFFTWEnabled;
NRRD_EXPORT int nrrdFFTWWisdomRead(FILE *file);
NRRD_EXPORT int nrrdFFT(Nrrd *nout, const Nrrd *nin,
                        unsigned int *axes, unsigned int axesLen,
                        int sign, int rescale, int preCompLevel);
NRRD_EXPORT int nrrdFFTWWisdomWrite(FILE *file);
  
/******** kernels (interpolation, 1st and 2nd derivatives) */
/* tmfKernel.c
   nrrdKernelTMF[D+1][C+1][A] is d<D>_c<C>_<A>ef:
   Dth-derivative, C-order continuous ("smooth"), A-order accurate
   (for D and C, index 0 accesses the function for -1) */
NRRD_EXPORT NrrdKernel *const nrrdKernelTMF[4][5][5];
NRRD_EXPORT const unsigned int nrrdKernelTMF_maxD;
NRRD_EXPORT const unsigned int nrrdKernelTMF_maxC;
NRRD_EXPORT const unsigned int nrrdKernelTMF_maxA;
/* winKernel.c : various kinds of windowed sincs */
NRRD_EXPORT NrrdKernel
  *const nrrdKernelHann,         /* Hann (cosine-bell) windowed sinc */
  *const nrrdKernelHannD,        /* 1st derivative of Hann windowed since */
  *const nrrdKernelHannDD,       /* 2nd derivative */
  *const nrrdKernelBlackman,     /* Blackman windowed sinc */
  *const nrrdKernelBlackmanD,    /* 1st derivative of Blackman windowed sinc */
  *const nrrdKernelBlackmanDD;   /* 2nd derivative */
/* bsplKernel.c : b-splines of various orders; these do not interpolate */
NRRD_EXPORT NrrdKernel
  *const nrrdKernelBSpline3,     /* 3rd order (cubic) B-spline */
  *const nrrdKernelBSpline3D,
  *const nrrdKernelBSpline3DD,
  *const nrrdKernelBSpline3ApproxInverse,
  *const nrrdKernelBSpline5,     /* 5th order B-spline */
  *const nrrdKernelBSpline5D,
  *const nrrdKernelBSpline5DD,
  *const nrrdKernelBSpline5ApproxInverse;
/* kernel.c */
NRRD_EXPORT NrrdKernel
  *const nrrdKernelZero,         /* zero everywhere */
  *const nrrdKernelBox,          /* box filter (nearest neighbor) */
  *const nrrdKernelCheap,        /* like box, but every Nth on downsampling */
  *const nrrdKernelHermiteFlag,  /* NOT a kernel, a flag for gage behavior */
  *const nrrdKernelTent,         /* tent filter (linear interpolation) */
  *const nrrdKernelForwDiff,     /* forward-difference-ish 1st deriv. */
  *const nrrdKernelCentDiff,     /* central-difference-ish 1st deriv. */
  *const nrrdKernelBCCubic,      /* BC family of cubic polynomial splines */
  *const nrrdKernelBCCubicD,     /* 1st deriv. of BC cubic family */
  *const nrrdKernelBCCubicDD,    /* 2nd deriv. of BC cubic family */
  *const nrrdKernelAQuartic,     /* A family of quartic C2 interp. splines */
  *const nrrdKernelAQuarticD,    /* 1st deriv. of A quartic family */
  *const nrrdKernelAQuarticDD,   /* 2nd deriv. of A quartic family */
  *const nrrdKernelC3Quintic,    /* 0-parm C3 quintic, support [-2,2] */
  *const nrrdKernelC3QuinticD,   /* 1st deriv of C3Quintic */
  *const nrrdKernelC3QuinticDD,  /* 2nd deriv of C3Quintic */
  *const nrrdKernelC4Hexic,      /* 0-parm C4 hex, support [-3,3] */
  *const nrrdKernelC4HexicD,     /* 1st deriv of C4Hexic */
  *const nrrdKernelC4HexicDD,    /* 2nd deriv of C4Hexic */
  *const nrrdKernelC4HexicApproxInverse,
  *const nrrdKernelGaussian,     /* Gaussian */
  *const nrrdKernelGaussianD,    /* 1st derivative of Gaussian */
  *const nrrdKernelGaussianDD,   /* 2nd derivative of Gaussian */
  *const nrrdKernelDiscreteGaussian; /* Discrete Gaussian-like kernel for 
                                        scale-space analysis */
NRRD_EXPORT int nrrdKernelParse(const NrrdKernel **kernelP,
                                double *parm,
                                const char *str);
NRRD_EXPORT int nrrdKernelSpecParse(NrrdKernelSpec *ksp, const char *str);
NRRD_EXPORT int nrrdKernelSpecSprint(char str[AIR_STRLEN_LARGE],
                                     const NrrdKernelSpec *ksp);
NRRD_EXPORT int nrrdKernelSprint(char str[AIR_STRLEN_LARGE],
                                 const NrrdKernel *kernel,
                                 const double *kparm);

/* ---- END non-NrrdIO */

#ifdef __cplusplus
}
#endif

#endif /* NRRD_HAS_BEEN_INCLUDED */