NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.volumeutils.shape_zoom_affine

Next topic

nibabel.volumeutils.Recoder

Reggie -- the one

nibabel.volumeutils.DtypeMapper

digraph inheritanceae909a725f { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "DtypeMapper" [shape=ellipse,URL="#nibabel.volumeutils.DtypeMapper",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; }

class nibabel.volumeutils.DtypeMapper

Specialized mapper for numpy dtypes

We pass this mapper into the Recoder class to deal with numpy dtype hashing.

The hashing problem is that dtypes that compare equal may not have the same hash. This is true for numpys up to the current at time of writing (1.6.0). For numpy 1.2.1 at least, even dtypes that look exactly the same in terms of fields don’t always have the same hash. This makes dtypes difficult to use as keys in a dictionary.

This class wraps a dictionary in order to implement a __getitem__ to deal with dtype hashing. If the key doesn’t appear to be in the mapping, and it is a dtype, we compare (using ==) all known dtype keys to the input key, and return any matching values for the matching key.

keys()
values()