nifti1_io
Toggle main menu visibility
Loading...
Searching...
No Matches
nifti1_tool.h
1
#ifndef _NIFTI_TOOL_H_
2
#define _NIFTI_TOOL_H_
3
4
#define NT_CMD_LEN 2048
5
6
typedef
struct
{
7
int
len;
8
const
char
** list;
9
}
str_list
;
10
11
typedef
struct
{
12
int
len;
13
int
* list;
14
}
int_list
;
15
16
typedef
struct
{
17
/* action options (flags) */
18
int
check_hdr, check_nim;
19
int
diff_hdr, diff_nim;
20
int
disp_hdr, disp_nim, disp_ana;
21
int
disp_exts, add_exts, rm_exts;
22
int
mod_hdr, mod_nim;
23
int
swap_hdr, swap_ana, swap_old;
24
25
int
strip;
/* strip extras from dataset(s) */
26
int
cbl, cci;
/* -copy_XXX option flags */
27
int
dts, dci, dci_lines;
/* display collapsed img flags */
28
int
make_im;
/* create a new image on the fly */
29
int
ci_dims[8];
/* user dims list (last 7 valid) */
30
int
new_dim[8];
/* user dim list for new image */
31
int
new_datatype;
/* datatype for new image */
32
int
debug, keep_hist;
/* debug level and history flag */
33
int
overwrite;
/* overwrite flag */
34
char
* prefix;
/* for output file */
35
str_list
elist;
/* extension strings */
36
int_list
etypes;
/* extension type list */
37
str_list
flist;
/* fields (to display or modify) */
38
str_list
vlist;
/* values (to set fields to) */
39
str_list
infiles;
/* input files */
40
char
command[NT_CMD_LEN];
/* for inserting the command */
41
}
nt_opts
;
42
43
#define USE_SHORT 1
44
#define USE_FULL 2
45
#define USE_HIST 3
46
#define USE_FIELD_HDR 4
47
#define USE_FIELD_NIM 5
48
#define USE_FIELD_ANA 6
49
#define USE_DTYPES 7
50
#define USE_VERSION 8
51
52
#define CHECK_NEXT_OPT(n,m,str) \
53
do { if ( (n) >= (m) ) { \
54
fprintf(stderr,"** option '%s': missing parameter\n",str); \
55
fprintf(stderr," consider: 'nifti_tool -help'\n"); \
56
return 1; } \
57
} while(0)
58
59
#define CHECK_NEXT_OPT_MSG(n,m,str,msg) \
60
do { if ( (n) >= (m) ) { \
61
fprintf(stderr,"** option '%s': %s\n",str,msg); \
62
fprintf(stderr," consider: 'nifti_tool -help'\n"); \
63
return 1; } \
64
} while(0)
65
66
/*----------------------------------------------------------------------
67
* this structure and definitions will be used to process the nifti_1_header
68
* and nifti_image structure fields (actions disp, diff, mod)
69
*----------------------------------------------------------------------*/
70
71
#define NT_FIELD_NAME_LEN 20
/* more than length of longest name */
72
#define NT_HDR_NUM_FIELDS 43
/* in the nifti_1_header struct */
73
#define NT_ANA_NUM_FIELDS 47
/* in the nifti_analyze75 struct */
74
#define NT_NIM_NUM_FIELDS 63
/* in the nifti_image struct */
75
#define NT_DT_STRING -0xfff
/* some strange number to abuse... */
76
#define NT_DT_POINTER -0xfef
/* some strange number to abuse... */
77
#define NT_DT_CHAR_PTR -0xfee
/* another... */
78
#define NT_DT_EXT_PTR -0xfed
/* and another... */
79
80
typedef
struct
{
81
int
type;
/* one of the DT_* types from nifti1.h */
82
int
offset;
/* bytes from the start of the struct */
83
int
size;
/* size of one element type */
84
int
len;
/* number of elements */
85
char
name[NT_FIELD_NAME_LEN];
/* actual structure name used */
86
}
field_s
;
87
88
/* for computing the offset from the start of the struct */
89
#define NT_OFF(str,field) ((int)( ((char *)&str.field) - ((char *)&str) ))
90
91
/* call fill_field() for a single type, name and number of elements */
92
/* nstr is the base struct, and fldp is a field pointer */
93
#define NT_SFILL(nstr,fldp,type,name,num,rv) do{ \
94
rv=fill_field(fldp,type,NT_OFF(nstr,name),num,#name); \
95
fldp++; } while (0)
96
97
#define NT_MAKE_IM_NAME "MAKE_IM"
98
99
/*----------------------------------------------------------------------*/
100
/*----- prototypes ---------------------------------------------------*/
101
/*----------------------------------------------------------------------*/
102
int
act_add_exts (
nt_opts
* opts );
103
int
act_cbl (
nt_opts
* opts );
/* copy brick list */
104
int
act_cci (
nt_opts
* opts );
/* copy collapsed dimensions */
105
int
act_check_hdrs (
nt_opts
* opts );
/* check for valid hdr or nim */
106
int
act_diff_hdrs (
nt_opts
* opts );
107
int
act_diff_nims (
nt_opts
* opts );
108
int
act_disp_ci (
nt_opts
* opts );
/* display general collapsed data */
109
int
act_disp_exts (
nt_opts
* opts );
110
int
act_disp_hdrs (
nt_opts
* opts );
111
int
act_disp_nims (
nt_opts
* opts );
112
int
act_disp_anas (
nt_opts
* opts );
113
int
act_disp_ts (
nt_opts
* opts );
/* display time series */
114
int
act_mod_hdrs (
nt_opts
* opts );
115
int
act_mod_nims (
nt_opts
* opts );
116
int
act_swap_hdrs (
nt_opts
* opts );
117
int
act_rm_ext (
nt_opts
* opts );
118
int
act_strip (
nt_opts
* opts );
/* strip extras from datasets */
119
120
121
field_s
* get_hdr_field(
const
char
* fname,
int
show_fail );
122
field_s
* get_nim_field(
const
char
* fname,
int
show_fail );
123
const
char
* field_type_str (
int
type);
124
125
int
diff_hdrs (
nifti_1_header
*s0,
nifti_1_header
*s1,
int
display);
126
int
diff_hdrs_list(
nifti_1_header
*s0,
nifti_1_header
*s1,
str_list
*slist,
127
int
display);
128
int
diff_nims (
nifti_image
*s0,
nifti_image
*s1,
int
display);
129
int
diff_nims_list(
nifti_image
*s0,
nifti_image
*s1,
str_list
*slist,
int
display);
130
131
int
add_int (
int_list
* ilist,
int
val);
132
int
add_string (
str_list
* slist,
const
char
* str);
133
int
check_total_size (
const
char
*mesg,
field_s
*fields,
int
nfields,
int
tot_size);
134
int
clear_float_zeros(
char
* str );
135
int
diff_field (
field_s
*fieldp,
void
* str0,
void
* str1,
int
nfields);
136
int
disp_nifti1_extension(
const
char
*mesg,
nifti1_extension
* ext,
int
maxlen);
137
int
disp_field (
const
char
*mesg,
field_s
*fieldp,
void
*str,
int
nfields,
int
header);
138
int
disp_field_s_list(
const
char
*mesg,
field_s
*,
int
nfields);
139
int
disp_nt_opts (
const
char
*mesg,
nt_opts
* opts);
140
int
disp_raw_data (
void
* data,
int
type,
int
nvals,
char
space,
int
newline);
141
int
fill_cmd_string (
nt_opts
* opts,
int
argc,
char
* argv[]);
142
int
fill_field (
field_s
*fp,
int
type,
int
offset,
int
num,
const
char
*name);
143
int
fill_hdr_field_array(
field_s
* nh_fields);
144
int
fill_nim_field_array(
field_s
* nim_fields);
145
int
fill_ana_field_array(
field_s
* ah_fields);
146
int
modify_all_fields(
void
*basep,
nt_opts
*opts,
field_s
*fields,
int
flen);
147
int
modify_field (
void
* basep,
field_s
* field,
const
char
* data);
148
int
process_opts (
int
argc,
char
* argv[],
nt_opts
* opts);
149
int
remove_ext_list (
nifti_image
* nim,
const
char
** elist,
int
len);
150
int
usage (
const
char
* prog,
int
level);
151
int
use_full (
const
char
* prog);
152
int
verify_opts (
nt_opts
* opts,
char
* prog);
153
int
write_hdr_to_file(
nifti_1_header
* nhdr,
const
char
* fname);
154
155
/* wrappers for nifti reading functions (allow MAKE_IM) */
156
nifti_image
* nt_image_read (
nt_opts
* opts,
const
char
* fname,
int
doread);
157
nifti_image
* nt_read_bricks(
nt_opts
* opts,
const
char
* fname,
int
len,
158
int
* list,
nifti_brick_list
* NBL);
159
nifti_1_header
* nt_read_header(
nt_opts
* opts,
const
char
* fname,
int
* swapped,
160
int
check);
161
162
163
#endif
/* _NIFTI_TOOL_H_ */
field_s
Definition
nifti1_tool.h:80
int_list
Definition
nifti1_tool.h:11
nifti1_extension
Data structure defining the fields of a header extension.
Definition
nifti1.h:297
nifti_1_header
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition
nifti1.h:148
nifti_brick_list
Definition
nifti1_io.h:175
nifti_image
High level data structure for open nifti datasets in the nifti1_io API. Note that this structure is n...
Definition
nifti1_io.h:88
nt_opts
Definition
nifti1_tool.h:16
str_list
Definition
nifti1_tool.h:6
niftilib
nifti1_tool.h
Generated by
1.17.0