nifti1_io
nifti1_io.h
Go to the documentation of this file.
1
6#ifndef _NIFTI_IO_HEADER_
7#define _NIFTI_IO_HEADER_
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <math.h>
13#include <ctype.h>
14
15#ifndef DONT_INCLUDE_ANALYZE_STRUCT
16#define DONT_INCLUDE_ANALYZE_STRUCT /*** not needed herein ***/
17#endif
18#include "nifti1.h" /*** NIFTI-1 header specification ***/
19
20#include <znzlib.h>
21
22/*=================*/
23#ifdef __cplusplus
24extern "C" {
25#endif
26/*=================*/
27
28/*****===================================================================*****/
29/***** File nifti1_io.h == Declarations for nifti1_io.c *****/
30/*****...................................................................*****/
31/***** This code is released to the public domain. *****/
32/*****...................................................................*****/
33/***** Author: Robert W Cox, SSCC/DIRP/NIMH/NIH/DHHS/USA/EARTH *****/
34/***** Date: August 2003 *****/
35/*****...................................................................*****/
36/***** Neither the National Institutes of Health (NIH), nor any of its *****/
37/***** employees imply any warranty of usefulness of this software for *****/
38/***** any purpose, and do not assume any liability for damages, *****/
39/***** incidental or otherwise, caused by any use of this document. *****/
40/*****===================================================================*****/
41
42/*
43 Modified by: Mark Jenkinson (FMRIB Centre, University of Oxford, UK)
44 Date: July/August 2004
45
46 Mainly adding low-level IO and changing things to allow gzipped files
47 to be read and written
48 Full backwards compatability should have been maintained
49
50 Modified by: Rick Reynolds (SSCC/DIRP/NIMH, National Institutes of Health)
51 Date: December 2004
52
53 Modified and added many routines for I/O.
54*/
55
56/********************** Some sample data structures **************************/
57
58typedef struct {
59 float m[4][4] ;
60} mat44 ;
61
62typedef struct {
63 float m[3][3] ;
64} mat33 ;
65
66/*...........................................................................*/
67
72typedef enum _analyze75_orient_code {
73 a75_transverse_unflipped = 0,
74 a75_coronal_unflipped = 1,
75 a75_sagittal_unflipped = 2,
76 a75_transverse_flipped = 3,
77 a75_coronal_flipped = 4,
78 a75_sagittal_flipped = 5,
79 a75_orient_unknown = 6
80} analyze_75_orient_code;
81
88typedef struct {
90 int ndim ;
91 int nx ;
92 int ny ;
93 int nz ;
94 int nt ;
95 int nu ;
96 int nv ;
97 int nw ;
98 int dim[8] ;
99 size_t nvox ;
100 int nbyper ;
101 int datatype ;
103 float dx ;
104 float dy ;
105 float dz ;
106 float dt ;
107 float du ;
108 float dv ;
109 float dw ;
110 float pixdim[8] ;
112 float scl_slope ;
113 float scl_inter ;
115 float cal_min ;
116 float cal_max ;
121 int freq_dim ;
132 float quatern_b , quatern_c , quatern_d ,
133 qoffset_x , qoffset_y , qoffset_z ,
134 qfac ;
135
142 float toffset ;
151 float intent_p1 ;
152 float intent_p2 ;
153 float intent_p3 ;
154 char intent_name[16] ;
156 char descrip[80] ;
157 char aux_file[24] ;
159 char *fname ;
160 char *iname ;
162 int swapsize ;
164 void *data ;
166 int num_ext ;
168 analyze_75_orient_code analyze75_orient;
170} nifti_image ;
171
172
173
174/* struct for return from nifti_image_read_bricks() */
175typedef struct {
176 int nbricks; /* the number of allocated pointers in 'bricks' */
177 size_t bsize; /* the length of each data block, in bytes */
178 void ** bricks; /* array of pointers to data blocks */
180
181
182/*****************************************************************************/
183/*------------------ NIfTI version of ANALYZE 7.5 structure -----------------*/
184
185/* (based on fsliolib/dbh.h, but updated for version 7.5) */
186
187typedef struct {
188 /* header info fields - describes the header overlap with NIfTI */
189 /* ------------------ */
190 int sizeof_hdr; /* 0 + 4 same */
191 char data_type[10]; /* 4 + 10 same */
192 char db_name[18]; /* 14 + 18 same */
193 int extents; /* 32 + 4 same */
194 short int session_error; /* 36 + 2 same */
195 char regular; /* 38 + 1 same */
196 char hkey_un0; /* 39 + 1 40 bytes */
197
198 /* image dimension fields - describes image sizes */
199 short int dim[8]; /* 0 + 16 same */
200 short int unused8; /* 16 + 2 intent_p1... */
201 short int unused9; /* 18 + 2 ... */
202 short int unused10; /* 20 + 2 intent_p2... */
203 short int unused11; /* 22 + 2 ... */
204 short int unused12; /* 24 + 2 intent_p3... */
205 short int unused13; /* 26 + 2 ... */
206 short int unused14; /* 28 + 2 intent_code */
207 short int datatype; /* 30 + 2 same */
208 short int bitpix; /* 32 + 2 same */
209 short int dim_un0; /* 34 + 2 slice_start */
210 float pixdim[8]; /* 36 + 32 same */
211
212 float vox_offset; /* 68 + 4 same */
213 float funused1; /* 72 + 4 scl_slope */
214 float funused2; /* 76 + 4 scl_inter */
215 float funused3; /* 80 + 4 slice_end, */
216 /* slice_code, */
217 /* xyzt_units */
218 float cal_max; /* 84 + 4 same */
219 float cal_min; /* 88 + 4 same */
220 float compressed; /* 92 + 4 slice_duration */
221 float verified; /* 96 + 4 toffset */
222 int glmax,glmin; /* 100 + 8 108 bytes */
223
224 /* data history fields - optional */
225 char descrip[80]; /* 0 + 80 same */
226 char aux_file[24]; /* 80 + 24 same */
227 char orient; /* 104 + 1 NO GOOD OVERLAP */
228 char originator[10]; /* 105 + 10 FROM HERE DOWN... */
229 char generated[10]; /* 115 + 10 */
230 char scannum[10]; /* 125 + 10 */
231 char patient_id[10]; /* 135 + 10 */
232 char exp_date[10]; /* 145 + 10 */
233 char exp_time[10]; /* 155 + 10 */
234 char hist_un0[3]; /* 165 + 3 */
235 int views; /* 168 + 4 */
236 int vols_added; /* 172 + 4 */
237 int start_field; /* 176 + 4 */
238 int field_skip; /* 180 + 4 */
239 int omax, omin; /* 184 + 8 */
240 int smax, smin; /* 192 + 8 200 bytes */
241} nifti_analyze75; /* total: 348 bytes */
242
243
244/*****************************************************************************/
245/*--------------- Prototypes of functions defined in this file --------------*/
246
247char *nifti_datatype_string ( int dt ) ;
248char *nifti_units_string ( int uu ) ;
249char *nifti_intent_string ( int ii ) ;
250char *nifti_xform_string ( int xx ) ;
251char *nifti_slice_string ( int ss ) ;
252char *nifti_orientation_string( int ii ) ;
253
254int nifti_is_inttype( int dt ) ;
255
257
260float nifti_mat33_rownorm( mat33 A ) ;
261float nifti_mat33_colnorm( mat33 A ) ;
262float nifti_mat33_determ ( mat33 R ) ;
264
265void nifti_swap_2bytes ( size_t n , void *ar ) ;
266void nifti_swap_4bytes ( size_t n , void *ar ) ;
267void nifti_swap_8bytes ( size_t n , void *ar ) ;
268void nifti_swap_16bytes( size_t n , void *ar ) ;
269void nifti_swap_Nbytes ( size_t n , int siz , void *ar ) ;
270
271int nifti_datatype_is_valid (int dtype, int for_nifti);
272int nifti_datatype_from_string(const char * name);
273char * nifti_datatype_to_string (int dtype);
274
275int nifti_get_filesize( const char *pathname ) ;
276void swap_nifti_header ( struct nifti_1_header *h , int is_nifti ) ;
277void old_swap_nifti_header( struct nifti_1_header *h , int is_nifti );
279
280
281/* main read/write routines */
282
283nifti_image *nifti_image_read_bricks(const char *hname , int nbricks,
284 const int *blist, nifti_brick_list * NBL);
285int nifti_image_load_bricks(nifti_image *nim , int nbricks,
286 const int *blist, nifti_brick_list * NBL);
287void nifti_free_NBL( nifti_brick_list * NBL );
288
289nifti_image *nifti_image_read ( const char *hname , int read_data ) ;
290int nifti_image_load ( nifti_image *nim ) ;
291void nifti_image_unload ( nifti_image *nim ) ;
292void nifti_image_free ( nifti_image *nim ) ;
293
294int nifti_read_collapsed_image( nifti_image * nim, const int dims [8],
295 void ** data );
296
298 int *start_index, int *region_size,
299 void ** data );
300
301void nifti_image_write ( nifti_image * nim ) ;
303 const nifti_brick_list * NBL);
304void nifti_image_infodump( const nifti_image * nim ) ;
305
306void nifti_disp_lib_hist( void ) ; /* to display library history */
307void nifti_disp_lib_version( void ) ; /* to display library version */
308int nifti_disp_matrix_orient( const char * mesg, mat44 mat );
309int nifti_disp_type_list( int which );
310
311
312char * nifti_image_to_ascii ( const nifti_image * nim ) ;
313nifti_image *nifti_image_from_ascii( const char * str, int * bytes_read ) ;
314
315size_t nifti_get_volsize(const nifti_image *nim) ;
316
317/* basic file operations */
318int nifti_set_filenames(nifti_image * nim, const char * prefix, int check,
319 int set_byte_order);
320char * nifti_makehdrname (const char * prefix, int nifti_type, int check,
321 int comp);
322char * nifti_makeimgname (const char * prefix, int nifti_type, int check,
323 int comp);
324int is_nifti_file (const char *hname);
325char * nifti_find_file_extension(const char * name);
326int nifti_is_complete_filename(const char* fname);
327int nifti_validfilename(const char* fname);
328
329int disp_nifti_1_header(const char * info, const nifti_1_header * hp ) ;
330void nifti_set_debug_level( int level ) ;
331void nifti_set_skip_blank_ext( int skip ) ;
332void nifti_set_allow_upper_fext( int allow ) ;
333
334int valid_nifti_brick_list(nifti_image * nim , int nbricks,
335 const int * blist, int disp_error);
336
337/* znzFile operations */
338znzFile nifti_image_open(const char * hname, char * opts, nifti_image ** nim);
340 const char* opts);
341znzFile nifti_image_write_hdr_img2( nifti_image *nim , int write_opts ,
342 const char* opts, znzFile imgfile, const nifti_brick_list * NBL);
343size_t nifti_read_buffer(znzFile fp, void* datatptr, size_t ntot,
344 nifti_image *nim);
346 const nifti_brick_list * NBL);
347size_t nifti_write_buffer(znzFile fp, const void * buffer, size_t numbytes);
348nifti_image *nifti_read_ascii_image(znzFile fp, char *fname, int flen,
349 int read_data);
351 const char * opts, int write_data, int leave_open);
352
353
354void nifti_datatype_sizes( int datatype , int *nbyper, int *swapsize ) ;
355
357 float *qb, float *qc, float *qd,
358 float *qx, float *qy, float *qz,
359 float *dx, float *dy, float *dz, float *qfac ) ;
360
361mat44 nifti_quatern_to_mat44( float qb, float qc, float qd,
362 float qx, float qy, float qz,
363 float dx, float dy, float dz, float qfac );
364
365mat44 nifti_make_orthog_mat44( float r11, float r12, float r13 ,
366 float r21, float r22, float r23 ,
367 float r31, float r32, float r33 ) ;
368
369int nifti_short_order(void) ; /* CPU byte order */
370
371
372/* Orientation codes that might be returned from nifti_mat44_to_orientation().*/
373
374#define NIFTI_L2R 1 /* Left to Right */
375#define NIFTI_R2L 2 /* Right to Left */
376#define NIFTI_P2A 3 /* Posterior to Anterior */
377#define NIFTI_A2P 4 /* Anterior to Posterior */
378#define NIFTI_I2S 5 /* Inferior to Superior */
379#define NIFTI_S2I 6 /* Superior to Inferior */
380
381void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod ) ;
382
383/*--------------------- Low level IO routines ------------------------------*/
384
385char * nifti_findhdrname (const char* fname);
386char * nifti_findimgname (const char* fname , int nifti_type);
387int nifti_is_gzfile (const char* fname);
388
389char * nifti_makebasename(const char* fname);
390
391
392/* other routines */
394nifti_1_header * nifti_make_new_header(const int arg_dims[], int arg_dtype);
395nifti_1_header * nifti_read_header(const char *hname, int *swapped, int check);
397nifti_image * nifti_make_new_nim(const int dims[], int datatype,
398 int data_fill);
401 const char * fname);
402
403int nifti_hdr_looks_good (const nifti_1_header * hdr);
404int nifti_is_valid_datatype (int dtype);
405int nifti_is_valid_ecode (int ecode);
406int nifti_nim_is_valid (nifti_image * nim, int complain);
407int nifti_nim_has_valid_dims (nifti_image * nim, int complain);
408int is_valid_nifti_type (int nifti_type);
409int nifti_test_datatype_sizes (int verb);
410int nifti_type_and_names_match (nifti_image * nim, int show_warn);
414int nifti_add_extension(nifti_image * nim, const char * data, int len,
415 int ecode );
416int nifti_compiled_with_zlib (void);
417int nifti_copy_extensions (nifti_image *nim_dest,const nifti_image *nim_src);
419int * nifti_get_intlist (int nvals , const char *str);
420char * nifti_strdup (const char *str);
421int valid_nifti_extensions(const nifti_image *nim);
422
423
424/*-------------------- Some C convenience macros ----------------------------*/
425
426/* NIfTI-1.1 extension codes:
427 see http://nifti.nimh.nih.gov/nifti-1/documentation/faq#Q21 */
428
429#define NIFTI_ECODE_IGNORE 0 /* changed from UNKNOWN, 29 June 2005 */
430
431#define NIFTI_ECODE_DICOM 2 /* intended for raw DICOM attributes */
432
433#define NIFTI_ECODE_AFNI 4 /* Robert W Cox: rwcox@nih.gov
434 http://afni.nimh.nih.gov/afni */
435
436#define NIFTI_ECODE_COMMENT 6 /* plain ASCII text only */
437
438#define NIFTI_ECODE_XCEDE 8 /* David B Keator: dbkeator@uci.edu
439 http://www.nbirn.net/Resources
440 /Users/Applications/
441 /xcede/index.htm */
442
443#define NIFTI_ECODE_JIMDIMINFO 10 /* Mark A Horsfield:
444 mah5@leicester.ac.uk
445 http://someplace/something */
446
447#define NIFTI_ECODE_WORKFLOW_FWDS 12 /* Kate Fissell: fissell@pitt.edu
448 http://kraepelin.wpic.pitt.edu
449 /~fissell/NIFTI_ECODE_WORKFLOW_FWDS
450 /NIFTI_ECODE_WORKFLOW_FWDS.html */
451
452#define NIFTI_ECODE_FREESURFER 14 /* http://surfer.nmr.mgh.harvard.edu */
453
454#define NIFTI_ECODE_PYPICKLE 16 /* embedded Python objects
455 http://niftilib.sourceforge.net
456 /pynifti */
457
458 /* LONI MiND codes: http://www.loni.ucla.edu/twiki/bin/view/Main/MiND */
459#define NIFTI_ECODE_MIND_IDENT 18 /* Vishal Patel: vishal.patel@ucla.edu*/
460#define NIFTI_ECODE_B_VALUE 20
461#define NIFTI_ECODE_SPHERICAL_DIRECTION 22
462#define NIFTI_ECODE_DT_COMPONENT 24
463#define NIFTI_ECODE_SHC_DEGREEORDER 26 /* end LONI MiND codes */
464
465#define NIFTI_ECODE_VOXBO 28 /* Dan Kimberg: www.voxbo.org */
466
467#define NIFTI_ECODE_CARET 30 /* John Harwell: john@brainvis.wustl.edu
468 http://brainvis.wustl.edu/wiki
469 /index.php/Caret:Documentation
470 :CaretNiftiExtension */
471
472#define NIFTI_MAX_ECODE 30 /******* maximum extension code *******/
474/* nifti_type file codes */
475#define NIFTI_FTYPE_ANALYZE 0
476#define NIFTI_FTYPE_NIFTI1_1 1
477#define NIFTI_FTYPE_NIFTI1_2 2
478#define NIFTI_FTYPE_ASCII 3
479#define NIFTI_MAX_FTYPE 3 /* this should match the maximum code */
480
481/*------------------------------------------------------------------------*/
482/*-- the rest of these apply only to nifti1_io.c, check for _NIFTI1_IO_C_ */
483/* Feb 9, 2005 [rickr] */
484#ifdef _NIFTI1_IO_C_
485
486typedef struct {
487 int debug;
488 int skip_blank_ext;
489 int allow_upper_fext;
491
492typedef struct {
493 int type; /* should match the NIFTI_TYPE_ #define */
494 int nbyper; /* bytes per value, matches nifti_image */
495 int swapsize; /* bytes per swap piece, matches nifti_image */
496 char * name; /* text string to match #define */
498
499#undef LNI_FERR /* local nifti file error, to be compact and repetative */
500#define LNI_FERR(func,msg,file) \
501 fprintf(stderr,"** ERROR (%s): %s '%s'\n",func,msg,file)
502
503#undef swap_2
504#undef swap_4
505#define swap_2(s) nifti_swap_2bytes(1,&(s)) /* s: 2-byte short; swap in place */
506#define swap_4(v) nifti_swap_4bytes(1,&(v)) /* v: 4-byte value; swap in place */
507
508 /***** isfinite() is a C99 macro, which is
509 present in many C implementations already *****/
510
511#undef IS_GOOD_FLOAT
512#undef FIXED_FLOAT
513
514#ifdef isfinite /* use isfinite() to check floats/doubles for goodness */
515# define IS_GOOD_FLOAT(x) isfinite(x) /* check if x is a "good" float */
516# define FIXED_FLOAT(x) (isfinite(x) ? (x) : 0) /* fixed if bad */
517#else
518# define IS_GOOD_FLOAT(x) 1 /* don't check it */
519# define FIXED_FLOAT(x) (x) /* don't fix it */
520#endif
521
522#undef ASSIF /* assign v to *p, if possible */
523#define ASSIF(p,v) if( (p)!=NULL ) *(p) = (v)
524
525#undef MSB_FIRST
526#undef LSB_FIRST
527#undef REVERSE_ORDER
528#define LSB_FIRST 1
529#define MSB_FIRST 2
530#define REVERSE_ORDER(x) (3-(x)) /* convert MSB_FIRST <--> LSB_FIRST */
531
532#define LNI_MAX_NIA_EXT_LEN 100000 /* consider a longer extension invalid */
533
534#endif /* _NIFTI1_IO_C_ section */
535/*------------------------------------------------------------------------*/
536
537/*=================*/
538#ifdef __cplusplus
539}
540#endif
541/*=================*/
542
543#endif /* _NIFTI_IO_HEADER_ */
short datatype
Definition: nifti1.h:165
Official definition of the nifti1 header. Written by Bob Cox, SSCC, NIMH.
nifti_1_header * nifti_make_new_header(const int arg_dims[], int arg_dtype)
Definition: nifti1_io.c:5284
nifti_image * nifti_copy_nim_info(const nifti_image *src)
Definition: nifti1_io.c:5882
znzFile nifti_image_write_hdr_img(nifti_image *nim, int write_data, const char *opts)
Definition: nifti1_io.c:5657
size_t nifti_get_volsize(const nifti_image *nim)
Definition: nifti1_io.c:2464
int nifti_swap_as_analyze(nifti_analyze75 *h)
Definition: nifti1_io.c:2327
int nifti_read_collapsed_image(nifti_image *nim, const int dims[8], void **data)
Definition: nifti1_io.c:6742
int * nifti_get_intlist(int nvals, const char *str)
Definition: nifti1_io.c:7207
char * nifti_strdup(const char *str)
Definition: nifti1_io.c:1157
void nifti_set_skip_blank_ext(int skip)
Definition: nifti1_io.c:2709
nifti_image * nifti_simple_init_nim(void)
Definition: nifti1_io.c:5241
znzFile nifti_image_write_hdr_img2(nifti_image *nim, int write_opts, const char *opts, znzFile imgfile, const nifti_brick_list *NBL)
Definition: nifti1_io.c:5695
int is_nifti_file(const char *hname)
Definition: nifti1_io.c:3438
int nifti_set_filenames(nifti_image *nim, const char *prefix, int check, int set_byte_order)
Definition: nifti1_io.c:3054
int nifti_read_subregion_image(nifti_image *nim, int *start_index, int *region_size, void **data)
Definition: nifti1_io.c:6847
char * nifti_find_file_extension(const char *name)
Definition: nifti1_io.c:2583
int nifti_is_inttype(int dt)
Definition: nifti1_io.c:1218
int nifti_image_load(nifti_image *nim)
Load the image blob into a previously initialized nifti_image.
Definition: nifti1_io.c:4866
void nifti_image_free(nifti_image *nim)
Definition: nifti1_io.c:5028
int nifti_disp_matrix_orient(const char *mesg, mat44 mat)
Definition: nifti1_io.c:1132
mat33 nifti_mat33_polar(mat33 A)
Definition: nifti1_io.c:1891
size_t nifti_read_buffer(znzFile fp, void *datatptr, size_t ntot, nifti_image *nim)
Definition: nifti1_io.c:4928
nifti_image * nifti_read_ascii_image(znzFile fp, char *fname, int flen, int read_data)
Definition: nifti1_io.c:4292
int valid_nifti_brick_list(nifti_image *nim, int nbricks, const int *blist, int disp_error)
Definition: nifti1_io.c:1025
mat33 nifti_mat33_mul(mat33 A, mat33 B)
Definition: nifti1_io.c:1872
int nifti_type_and_names_match(nifti_image *nim, int show_warn)
Definition: nifti1_io.c:3106
mat44 nifti_quatern_to_mat44(float qb, float qc, float qd, float qx, float qy, float qz, float dx, float dy, float dz, float qfac)
Definition: nifti1_io.c:1466
float nifti_mat33_colnorm(mat33 A)
Definition: nifti1_io.c:1857
void swap_nifti_header(struct nifti_1_header *h, int is_nifti)
Definition: nifti1_io.c:2266
char * nifti_units_string(int uu)
Definition: nifti1_io.c:1255
void nifti_swap_4bytes(size_t n, void *ar)
Definition: nifti1_io.c:2156
nifti_image * nifti_image_read_bricks(const char *hname, int nbricks, const int *blist, nifti_brick_list *NBL)
Definition: nifti1_io.c:531
int nifti_datatype_is_valid(int dtype, int for_nifti)
Definition: nifti1_io.c:7421
int is_valid_nifti_type(int nifti_type)
Definition: nifti1_io.c:3329
int nifti_set_type_from_names(nifti_image *nim)
Definition: nifti1_io.c:3379
void nifti_swap_16bytes(size_t n, void *ar)
Definition: nifti1_io.c:2198
void nifti_swap_8bytes(size_t n, void *ar)
Definition: nifti1_io.c:2177
int nifti_compiled_with_zlib(void)
Definition: nifti1_io.c:2666
void old_swap_nifti_header(struct nifti_1_header *h, int is_nifti)
Definition: nifti1_io.c:2385
int nifti_is_gzfile(const char *fname)
Definition: nifti1_io.c:2648
char * nifti_datatype_to_string(int dtype)
Definition: nifti1_io.c:7400
int nifti_image_load_bricks(nifti_image *nim, int nbricks, const int *blist, nifti_brick_list *NBL)
Definition: nifti1_io.c:719
int nifti_validfilename(const char *fname)
Definition: nifti1_io.c:2550
void nifti_mat44_to_quatern(mat44 R, float *qb, float *qc, float *qd, float *qx, float *qy, float *qz, float *dx, float *dy, float *dz, float *qfac)
Definition: nifti1_io.c:1537
void nifti_set_allow_upper_fext(int allow)
Definition: nifti1_io.c:2719
void nifti_image_write_bricks(nifti_image *nim, const nifti_brick_list *NBL)
Definition: nifti1_io.c:5865
mat44 nifti_make_orthog_mat44(float r11, float r12, float r13, float r21, float r22, float r23, float r31, float r32, float r33)
Definition: nifti1_io.c:1737
int nifti_nim_is_valid(nifti_image *nim, int complain)
Definition: nifti1_io.c:6559
nifti_image * nifti_image_read(const char *hname, int read_data)
Read a nifti header and optionally the data, creating a nifti_image.
Definition: nifti1_io.c:4150
char * nifti_intent_string(int ii)
Definition: nifti1_io.c:1306
int nifti_hdr_looks_good(const nifti_1_header *hdr)
Definition: nifti1_io.c:4030
void nifti_image_unload(nifti_image *nim)
Definition: nifti1_io.c:5010
float nifti_mat33_rownorm(mat33 A)
Definition: nifti1_io.c:1842
void nifti_swap_2bytes(size_t n, void *ar)
Definition: nifti1_io.c:2139
float nifti_mat33_determ(mat33 R)
Definition: nifti1_io.c:1827
znzFile nifti_image_open(const char *hname, char *opts, nifti_image **nim)
Read in NIFTI-1 or ANALYZE-7.5 file (pair) header information into a nifti_image struct.
Definition: nifti1_io.c:3904
void nifti_disp_lib_version(void)
Definition: nifti1_io.c:462
void nifti_swap_Nbytes(size_t n, int siz, void *ar)
Definition: nifti1_io.c:2245
void nifti_image_infodump(const nifti_image *nim)
Definition: nifti1_io.c:5077
char * nifti_slice_string(int ss)
Definition: nifti1_io.c:1362
int nifti_disp_type_list(int which)
Definition: nifti1_io.c:7483
void nifti_image_write(nifti_image *nim)
Definition: nifti1_io.c:5849
int nifti_is_valid_datatype(int dtype)
Definition: nifti1_io.c:3347
void nifti_free_NBL(nifti_brick_list *NBL)
Definition: nifti1_io.c:783
nifti_image * nifti_convert_nhdr2nim(struct nifti_1_header nhdr, const char *fname)
Definition: nifti1_io.c:3599
char * nifti_xform_string(int xx)
Definition: nifti1_io.c:1283
char * nifti_image_to_ascii(const nifti_image *nim)
Definition: nifti1_io.c:6082
void nifti_disp_lib_hist(void)
Definition: nifti1_io.c:452
int nifti_write_all_data(znzFile fp, nifti_image *nim, const nifti_brick_list *NBL)
Definition: nifti1_io.c:5129
mat44 nifti_mat44_inverse(mat44 R)
Definition: nifti1_io.c:1668
char * nifti_findhdrname(const char *fname)
Definition: nifti1_io.c:2735
char * nifti_datatype_string(int dt)
Definition: nifti1_io.c:1186
mat33 nifti_mat33_inverse(mat33 R)
Definition: nifti1_io.c:1795
nifti_image * nifti_make_new_nim(const int dims[], int datatype, int data_fill)
Definition: nifti1_io.c:5363
char * nifti_orientation_string(int ii)
Definition: nifti1_io.c:1387
nifti_1_header * nifti_read_header(const char *hname, int *swapped, int check)
Definition: nifti1_io.c:3937
struct nifti_1_header nifti_convert_nim2nhdr(const nifti_image *nim)
Definition: nifti1_io.c:5407
int nifti_is_complete_filename(const char *fname)
Definition: nifti1_io.c:2506
int nifti_datatype_from_string(const char *name)
Definition: nifti1_io.c:7380
znzFile nifti_write_ascii_image(nifti_image *nim, const nifti_brick_list *NBL, const char *opts, int write_data, int leave_open)
Definition: nifti1_io.c:5798
void nifti_set_debug_level(int level)
Definition: nifti1_io.c:2699
int nifti_get_filesize(const char *pathname)
Definition: nifti1_io.c:2435
void nifti_mat44_to_orientation(mat44 R, int *icod, int *jcod, int *kcod)
Definition: nifti1_io.c:1966
int nifti_nim_has_valid_dims(nifti_image *nim, int complain)
Definition: nifti1_io.c:6592
char * nifti_makeimgname(const char *prefix, int nifti_type, int check, int comp)
Definition: nifti1_io.c:2985
char * nifti_makebasename(const char *fname)
Definition: nifti1_io.c:2680
int nifti_short_order(void)
Definition: nifti1_io.c:6321
int valid_nifti_extensions(const nifti_image *nim)
Definition: nifti1_io.c:4662
char * nifti_findimgname(const char *fname, int nifti_type)
Definition: nifti1_io.c:2833
void nifti_datatype_sizes(int datatype, int *nbyper, int *swapsize)
Definition: nifti1_io.c:1413
char * nifti_makehdrname(const char *prefix, int nifti_type, int check, int comp)
Definition: nifti1_io.c:2918
int nifti_add_extension(nifti_image *nim, const char *data, int len, int ecode)
Definition: nifti1_io.c:4470
int nifti_test_datatype_sizes(int verb)
Definition: nifti1_io.c:7444
void nifti_set_iname_offset(nifti_image *nim)
Definition: nifti1_io.c:5613
int nifti_update_dims_from_array(nifti_image *nim)
Definition: nifti1_io.c:615
int disp_nifti_1_header(const char *info, const nifti_1_header *hp)
Definition: nifti1_io.c:3505
nifti_image * nifti_image_from_ascii(const char *str, int *bytes_read)
Definition: nifti1_io.c:6361
int nifti_free_extensions(nifti_image *nim)
Definition: nifti1_io.c:5050
int nifti_is_valid_ecode(int ecode)
Definition: nifti1_io.c:4718
Definition: nifti1_io.h:62
Definition: nifti1_io.h:58
Data structure defining the fields of a header extension.
Definition: nifti1.h:293
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition: nifti1.h:144
Definition: nifti1_io.h:187
Definition: nifti1_io.h:175
Definition: nifti1_io.h:472
High level data structure for open nifti datasets in the nifti1_io API. Note that this structure is n...
Definition: nifti1_io.h:88
int slice_code
Definition: nifti1_io.h:125
nifti1_extension * ext_list
Definition: nifti1_io.h:167
float slice_duration
Definition: nifti1_io.h:128
mat44 qto_xyz
Definition: nifti1_io.h:136
float intent_p1
Definition: nifti1_io.h:151
mat44 sto_ijk
Definition: nifti1_io.h:140
float quatern_b
Definition: nifti1_io.h:132
int num_ext
Definition: nifti1_io.h:166
char * fname
Definition: nifti1_io.h:159
int time_units
Definition: nifti1_io.h:145
size_t nvox
Definition: nifti1_io.h:99
float intent_p3
Definition: nifti1_io.h:153
int freq_dim
Definition: nifti1_io.h:121
int datatype
Definition: nifti1_io.h:101
int intent_code
Definition: nifti1_io.h:150
int byteorder
Definition: nifti1_io.h:163
int ny
Definition: nifti1_io.h:92
int xyz_units
Definition: nifti1_io.h:144
float dv
Definition: nifti1_io.h:108
mat44 sto_xyz
Definition: nifti1_io.h:139
int phase_dim
Definition: nifti1_io.h:122
float cal_max
Definition: nifti1_io.h:116
mat44 qto_ijk
Definition: nifti1_io.h:137
int nbyper
Definition: nifti1_io.h:100
float scl_inter
Definition: nifti1_io.h:113
float cal_min
Definition: nifti1_io.h:115
int nv
Definition: nifti1_io.h:96
int iname_offset
Definition: nifti1_io.h:161
int nz
Definition: nifti1_io.h:93
float dx
Definition: nifti1_io.h:103
void * data
Definition: nifti1_io.h:164
int sform_code
Definition: nifti1_io.h:119
char * iname
Definition: nifti1_io.h:160
float intent_p2
Definition: nifti1_io.h:152
float du
Definition: nifti1_io.h:107
int nt
Definition: nifti1_io.h:94
int nu
Definition: nifti1_io.h:95
float dt
Definition: nifti1_io.h:106
float dw
Definition: nifti1_io.h:109
int nx
Definition: nifti1_io.h:91
float dz
Definition: nifti1_io.h:105
int nifti_type
Definition: nifti1_io.h:147
int slice_end
Definition: nifti1_io.h:127
int swapsize
Definition: nifti1_io.h:162
int ndim
Definition: nifti1_io.h:90
int slice_start
Definition: nifti1_io.h:126
int qform_code
Definition: nifti1_io.h:118
int nw
Definition: nifti1_io.h:97
analyze_75_orient_code analyze75_orient
Definition: nifti1_io.h:168
float toffset
Definition: nifti1_io.h:142
int slice_dim
Definition: nifti1_io.h:123
float scl_slope
Definition: nifti1_io.h:112
float dy
Definition: nifti1_io.h:104
Definition: nifti1_io.h:478
Definition: znzlib.h:67