Skip to content

Commit 1eb88d1

Browse files
committed
RF - use arrayproxy object for Analyze, MGH format
Arrayproxy is now capable of supporting Analyze / Nifti types and MGH types.
1 parent 3f783a6 commit 1eb88d1

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

nibabel/analyze.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -899,18 +899,7 @@ class AnalyzeImage(SpatialImage):
899899
files_types = (('image','.img'), ('header','.hdr'))
900900
_compressed_exts = ('.gz', '.bz2')
901901

902-
class ImageArrayProxy(ArrayProxy):
903-
''' Analyze-type implemention of array proxy protocol
904-
905-
The array proxy allows us to freeze the passed fileobj and
906-
header such that it returns the expected data array.
907-
'''
908-
def _read_data(self):
909-
fileobj = allopen(self.file_like)
910-
data = self.header.data_from_fileobj(fileobj)
911-
if isinstance(self.file_like, basestring): # filename
912-
fileobj.close()
913-
return data
902+
ImageArrayProxy = ArrayProxy
914903

915904
def get_header(self):
916905
''' Return header

nibabel/freesurfer/mghformat.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,18 +429,7 @@ class MGHImage(SpatialImage):
429429
files_types = (('image', '.mgh'),)
430430
_compressed_exts = ('.mgz',)
431431

432-
class ImageArrayProxy(ArrayProxy):
433-
''' Analyze-type implemention of array proxy protocol
434-
435-
The array proxy allows us to freeze the passed fileobj and
436-
header such that it returns the expected data array.
437-
'''
438-
def _read_data(self):
439-
fileobj = allopen(self.file_like)
440-
data = self.header.data_from_fileobj(fileobj)
441-
if isinstance(self.file_like, basestring): # filename
442-
fileobj.close()
443-
return data
432+
ImageArrayProxy = ArrayProxy
444433

445434
def get_header(self):
446435
''' Return the MGH header given the MGHImage'''

0 commit comments

Comments
 (0)