@@ -13,7 +13,7 @@ Output a summary table for neuroimaging files (resolution, dimensionality, etc.)
1313from __future__ import division , print_function , absolute_import
1414
1515__author__ = 'Yaroslav Halchenko'
16- __copyright__ = 'Copyright (c) 2011-2012 Yaroslav Halchenko ' \
16+ __copyright__ = 'Copyright (c) 2011-2015 Yaroslav Halchenko ' \
1717 'and NiBabel contributors'
1818__license__ = 'MIT'
1919
@@ -141,6 +141,10 @@ def get_opt_parser():
141141 dest = "verbose" , default = 0 ,
142142 help = "Make more noise. Could be specified multiple times" ),
143143
144+ Option ("-H" , "--header-fields" ,
145+ dest = "header_fields" , default = '' ,
146+ help = "Header fields (comma separated) to be printed as well (if present)" ),
147+
144148 Option ("-s" , "--stats" ,
145149 action = "store_true" , dest = 'stats' , default = False ,
146150 help = "Output basic data statistics" ),
@@ -180,6 +184,22 @@ def proc_file(f, opts):
180184 else :
181185 row += [ '' ]
182186
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+
183203 try :
184204 if (hasattr (h , 'get_qform' ) and hasattr (h , 'get_sform' )
185205 and (h .get_qform () != h .get_sform ()).any ()):
0 commit comments