@@ -13,7 +13,7 @@ Output a summary table for neuroimaging files (resolution, dimensionality, etc.)
13
13
from __future__ import division , print_function , absolute_import
14
14
15
15
__author__ = 'Yaroslav Halchenko'
16
- __copyright__ = 'Copyright (c) 2011-2012 Yaroslav Halchenko ' \
16
+ __copyright__ = 'Copyright (c) 2011-2015 Yaroslav Halchenko ' \
17
17
'and NiBabel contributors'
18
18
__license__ = 'MIT'
19
19
@@ -141,6 +141,10 @@ def get_opt_parser():
141
141
dest = "verbose" , default = 0 ,
142
142
help = "Make more noise. Could be specified multiple times" ),
143
143
144
+ Option ("-H" , "--header-fields" ,
145
+ dest = "header_fields" , default = '' ,
146
+ help = "Header fields (comma separated) to be printed as well (if present)" ),
147
+
144
148
Option ("-s" , "--stats" ,
145
149
action = "store_true" , dest = 'stats' , default = False ,
146
150
help = "Output basic data statistics" ),
@@ -180,6 +184,22 @@ def proc_file(f, opts):
180
184
else :
181
185
row += [ '' ]
182
186
187
+ if opts .header_fields :
188
+ # signals "all fields"
189
+ if opts .header_fields == '*' :
190
+ # TODO: might vary across file types, thus prior sensing would be needed
191
+ header_fields = h .keys ()
192
+ else :
193
+ header_fields = opts .header_fields .split (',' )
194
+
195
+ for f in header_fields :
196
+ if not f : # skip empty
197
+ continue
198
+ try :
199
+ row += [str (h [f ])]
200
+ except (KeyError , ValueError ):
201
+ row += [ '' ]
202
+
183
203
try :
184
204
if (hasattr (h , 'get_qform' ) and hasattr (h , 'get_sform' )
185
205
and (h .get_qform () != h .get_sform ()).any ()):
0 commit comments