nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
656 stars 259 forks source link

PAR/REC failure to load ('BinOpener' object is not iterable) #237

Closed effigies closed 10 years ago

effigies commented 10 years ago

I understand the PAR/REC is not super-well supported, but I'm now getting a strange error. Running from HEAD:

>>> from nibabel import parrec
>>> test = parrec.load(par_fname)

/usr/lib/pymodules/python2.7/nibabel/spatialimages.py in load(klass, filename)
    675     @classmethod
    676     def load(klass, filename):
--> 677         return klass.from_filename(filename)
    678
    679     @classmethod

/usr/lib/pymodules/python2.7/nibabel/spatialimages.py in from_filename(klass, filename)
    565     def from_filename(klass, filename):
    566         file_map = klass.filespec_to_file_map(filename)
--> 567         return klass.from_file_map(file_map)
    568
    569     @classmethod

/usr/lib/pymodules/python2.7/nibabel/parrec.pyc in from_file_map(klass, file_map)
    587     def from_file_map(klass, file_map):
    588         with file_map['header'].get_prepare_fileobj() as hdr_fobj:
--> 589             hdr = PARRECHeader.from_fileobj(hdr_fobj)
    590         rec_fobj = file_map['image'].get_prepare_fileobj()
    591         data = klass.ImageArrayProxy(rec_fobj, hdr)

/usr/lib/pymodules/python2.7/nibabel/parrec.pyc in from_fileobj(klass, fileobj)
    263     @classmethod
    264     def from_fileobj(klass, fileobj):
--> 265         info, image_defs = parse_PAR_header(fileobj)
    266         return klass(info, image_defs)
    267

/usr/lib/pymodules/python2.7/nibabel/parrec.pyc in parse_PAR_header(fobj)
    151
    152     # single pass through the header
--> 153     for line in fobj:
    154         # no junk
    155         line = line.strip()

TypeError: 'BinOpener' object is not iterable

I don't have a ton of free time at the moment, so hopefully this error makes the problem immediately obvious to someone on here. If not, I'll figure it out and submit a pull request.

matthew-brett commented 10 years ago

Could you give this branch a try? https://github.com/matthew-brett/nibabel/tree/fixing-parrec

It's in a current pull request : https://github.com/nipy/nibabel/pull/227

effigies commented 10 years ago

Works perfectly. Thanks!