本文整理匯總了Python中nipy.core.api.Image.extra方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.extra方法的具體用法?Python Image.extra怎麽用?Python Image.extra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nipy.core.api.Image
的用法示例。
在下文中一共展示了Image.extra方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load_npz
# 需要導入模塊: from nipy.core.api import Image [as 別名]
# 或者: from nipy.core.api.Image import extra [as 別名]
def load_npz(filename):
"""
Load an .npz Image, this .npz file must have at least two arrays
* data: the data array
* dimnames: the dimension names of the corresponding grid
* affine: the affine transformation of grid
The remaining arrays of .npz file are stored as the 'extra' attribute of the Image.
"""
npzobj = np.load(filename)
im = Image(npzobj['data'], CoordinateMap.from_affine(Affine(npzobj['affine']),
list(npzobj['dimnames']),
npzobj['data'].shape))
im.extra = {}
for f in npzobj.files:
if f not in ['affine', 'dimnames', 'data']:
im.extra[f] = npzobj[f]
return im