NiBabel

Access a cacophony of neuro-imaging file formats

Table Of Contents

Next topic

data

Reggie -- the one

cmdline

Functionality to be exposed in the command line

Module: cmdline.dicomfs

DICOMFS(*args, **kwargs)
FileHandle(fno)
dummy_fuse Dummy fuse “module” so that nose does not blow during doctests
get_opt_parser()
main([args])

Module: cmdline.diff

Quick summary of the differences among a set of neuroimaging files

are_values_different(*values) Generically compare values, return True if different
diff(files[, header_fields, ...])
display_diff(files, diff) Format header differences into a nice string
get_data_diff(files[, max_abs, max_rel, dtype]) Get difference between data
get_data_hash_diff(files[, dtype]) Get difference between md5 values of data
get_headers_diff(file_headers[, names]) Get difference between headers
get_opt_parser()
main([args, out]) Getting the show on the road

Module: cmdline.ls

Output a summary table for neuroimaging files (resolution, dimensionality, etc.)

get_opt_parser()
main([args]) Show must go on
proc_file(f, opts)

Module: cmdline.nifti_dx

Print nifti diagnostics for header files

main([args]) Go go team

Module: cmdline.parrec2nii

Code for PAR/REC to NIfTI converter command

error(msg, exit_code)
get_opt_parser()
main()
proc_file(infile, opts)
verbose(msg[, indent])

Module: cmdline.tck2trk

Convert tractograms (TCK -> TRK).

main()
parse_args()

Module: cmdline.trk2tck

Convert tractograms (TRK -> TCK).

main()
parse_args()

Module: cmdline.utils

Helper utilities to be used in cmdline applications

ap(helplist, format_[, sep]) Little helper to enforce consistency
safe_get(obj, name) A getattr which would return ‘-‘ if getattr fails
table2string(table[, out]) Given list of lists figure out their common widths and print to out
verbose(thing, msg) Print s if thing is less than the verbose_level

DICOMFS

class nibabel.cmdline.dicomfs.DICOMFS(*args, **kwargs)

Bases: fuse.Fuse

__init__(*args, **kwargs)
get_paths()
getattr(path)
match_path(path)
open(path, flags)
read(path, size, offset, fh)
readdir(path, fh)
release(path, flags, fh)

FileHandle

class nibabel.cmdline.dicomfs.FileHandle(fno)
__init__(fno)

dummy_fuse

class nibabel.cmdline.dicomfs.dummy_fuse

Bases: object

Dummy fuse “module” so that nose does not blow during doctests

__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

Fuse

alias of object

get_opt_parser

nibabel.cmdline.dicomfs.get_opt_parser()

main

nibabel.cmdline.dicomfs.main(args=None)

are_values_different

nibabel.cmdline.diff.are_values_different(*values)

Generically compare values, return True if different

Note that comparison is targetting reporting of comparison of the headers so has following specifics: - even a difference in data types is considered a difference, i.e. 1 != 1.0 - nans are considered to be the “same”, although generally nan != nan

diff

nibabel.cmdline.diff.diff(files, header_fields='all', data_max_abs_diff=None, data_max_rel_diff=None, dtype=<type 'numpy.float64'>)

display_diff

nibabel.cmdline.diff.display_diff(files, diff)

Format header differences into a nice string

Parameters:

files: list of files that were compared so we can print their names :

diff: dict of different valued header fields :

Returns:

str :

string-formatted table of differences

get_data_diff

nibabel.cmdline.diff.get_data_diff(files, max_abs=0, max_rel=0, dtype=<type 'numpy.float64'>)

Get difference between data

Parameters:

files: list of (str or ndarray) :

If list of strings is provided – they must be existing file names

max_abs: float, optional :

Maximal absolute difference to tolerate.

max_rel: float, optional :

Maximal relative (abs(diff)/mean(diff)) difference to tolerate. If max_abs is specified, then those data points with lesser than that absolute difference, are not considered for relative difference testing

dtype: np, optional :

Datatype to be used when extracting data from files

Returns:

diffs: OrderedDict :

An ordered dict with a record per each file which has differences with other files subsequent detected. Each record is a list of difference records, one per each file pair. Each difference record is an Ordered Dict with possible keys ‘abs’ or ‘rel’ showing maximal absolute or relative differences in the file or the record (‘CMP’: ‘incompat’) if file shapes are incompatible.

get_data_hash_diff

nibabel.cmdline.diff.get_data_hash_diff(files, dtype=<type 'numpy.float64'>)

Get difference between md5 values of data

Parameters:

files: list of actual files :

Returns:

list :

np.array: md5 values of respective files

get_headers_diff

nibabel.cmdline.diff.get_headers_diff(file_headers, names=None)

Get difference between headers

Parameters:

file_headers: list of actual headers (dicts) from files :

names: list of header fields to test :

Returns:

dict :

str: list for each header field which differs, return list of values per each file

get_opt_parser

nibabel.cmdline.diff.get_opt_parser()

main

nibabel.cmdline.diff.main(args=None, out=None)

Getting the show on the road

get_opt_parser

nibabel.cmdline.ls.get_opt_parser()

main

nibabel.cmdline.ls.main(args=None)

Show must go on

proc_file

nibabel.cmdline.ls.proc_file(f, opts)

main

nibabel.cmdline.nifti_dx.main(args=None)

Go go team

error

nibabel.cmdline.parrec2nii.error(msg, exit_code)

get_opt_parser

nibabel.cmdline.parrec2nii.get_opt_parser()

main

nibabel.cmdline.parrec2nii.main()

proc_file

nibabel.cmdline.parrec2nii.proc_file(infile, opts)

verbose

nibabel.cmdline.parrec2nii.verbose(msg, indent=0)

main

nibabel.cmdline.tck2trk.main()

parse_args

nibabel.cmdline.tck2trk.parse_args()

main

nibabel.cmdline.trk2tck.main()

parse_args

nibabel.cmdline.trk2tck.parse_args()

ap

nibabel.cmdline.utils.ap(helplist, format_, sep=', ')

Little helper to enforce consistency

safe_get

nibabel.cmdline.utils.safe_get(obj, name)

A getattr which would return ‘-‘ if getattr fails

table2string

nibabel.cmdline.utils.table2string(table, out=None)

Given list of lists figure out their common widths and print to out

Parameters:

table : list of lists of strings

What is aimed to be printed

out : None or stream

Where to print. If None – will print and return string

Returns:

string if out was None :

verbose

nibabel.cmdline.utils.verbose(thing, msg)

Print s if thing is less than the verbose_level