Skip to content

Commit a34220a

Browse files
author
Ben Cipollini
committed
Remove any mention of affine or dataobj from FileBasedImage
1 parent 3ea27d1 commit a34220a

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

nibabel/filebasedimages.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ class FileBasedImage(object):
7676
properties:
7777
7878
* shape
79-
* affine
8079
* header
81-
* dataobj
8280
8381
methods:
8482
* .get_header() (deprecated, use header property instead)
@@ -213,9 +211,7 @@ def header(self):
213211
def __getitem__(self):
214212
''' No slicing or dictionary interface for images
215213
'''
216-
raise TypeError("Cannot slice image objects; consider slicing image "
217-
"array data with `img.dataobj[slice]` or "
218-
"`img.get_data()[slice]`")
214+
raise TypeError("Cannot slice image objects.")
219215

220216
def get_header(self):
221217
""" Get header from image
@@ -412,35 +408,14 @@ def instance_to_filename(klass, img, filename):
412408
413409
Parameters
414410
----------
415-
img : ``spatialimage`` instance
416-
In fact, an object with the API of ``spatialimage`` - specifically
417-
``dataobj``, ``affine``, ``header`` and ``extra``.
411+
img : ``any FileBasedImage`` instance
412+
418413
filename : str
419414
Filename, implying name to which to save image.
420415
'''
421416
img = klass.from_image(img)
422417
img.to_filename(filename)
423418

424-
@classmethod
425-
def from_image(klass, img):
426-
''' Class method to create new instance of own class from `img`
427-
428-
Parameters
429-
----------
430-
img : ``spatialimage`` instance
431-
In fact, an object with the API of ``spatialimage`` -
432-
specifically ``dataobj``, ``affine``, ``header`` and ``extra``.
433-
434-
Returns
435-
-------
436-
cimg : ``spatialimage`` instance
437-
Image, of our own class
438-
'''
439-
return klass(img.dataobj,
440-
img.affine,
441-
klass.header_class.from_header(img.header),
442-
extra=img.extra.copy())
443-
444419
@classmethod
445420
def is_valid_extension(klass, ext):
446421
valid = tuple(ft[1] for ft in klass.files_types) + klass.alternate_exts

nibabel/spatialimages.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,10 @@ def get_affine(self):
635635
deprecate this method in future versions of nibabel.
636636
"""
637637
return self.affine
638+
639+
def __getitem__(self):
640+
''' No slicing or dictionary interface for images
641+
'''
642+
raise TypeError("Cannot slice image objects; consider slicing image "
643+
"array data with `img.dataobj[slice]` or "
644+
"`img.get_data()[slice]`")

0 commit comments

Comments
 (0)