error when initiating a raw object

Dear MNE community,

I am experiencing an error that I don't understand when trying to create
a raw object in Python. The traceback is below, and I only get this
with the raw files from one subject. I initially thought that it could
be due to the abnormally large file sizes of this subject's raw data
(~700 Mb), but I have one other subject whose raw data were comparable
and I can create raw objects from those data without issue.

Has anyone experienced this?

Cheers,
Andy

error Traceback (most recent call last)
/home/andrew/Experiments/Awareness_wo_Attention/<ipython-input-8-5fbcd28d6772>
in <module>()
----> 1
runfile(r'/home/andrew/Experiments/Awareness_wo_Attention/py_tmp_check_dataset_channels.py',
wdir=r'/home/andrew/Experiments/Awareness_wo_Attention')

/usr/local/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.pyc
in runfile(filename, args, wdir, namespace)
     485 pass
     486 os.chdir(wdir)
--> 487 execfile(filename, namespace)
     488 sys.argv = ['']
     489 namespace.pop('__file__')

/home/andrew/Experiments/Awareness_wo_Attention/py_tmp_check_dataset_channels.py
in <module>()
      48 for block in range(2):
      49 fname.append(data_path + '/' + subject + '/meg/' +
subject + '_block' + str(block+1) + '_cleaned_raw.fif')
---> 50 raw.append(mne.fiff.Raw(fname[block]))
      51 chan.append(raw[block].ch_names)
      52 chan.append([x for x in chan[0] if x not in set(chan[1])])

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/utils.pyc
in dec(*args, **kwargs)
     263 return ret
     264 else:
--> 265 return function(*args, **kwargs)
     266
     267 # set __wrapped__ attribute so ?? in IPython gets the right
source

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/fiff/raw.pyc
in __init__(self, fnames, allow_maxshield, preload, verbose, proj_active)
      83
      84 raws = [self._read_raw_file(fname, allow_maxshield,
preload)
---> 85 for fname in fnames]
      86
      87 _check_raw_compatibility(raws)

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/utils.pyc
in dec(*args, **kwargs)
     263 return ret
     264 else:
--> 265 return function(*args, **kwargs)
     266
     267 # set __wrapped__ attribute so ?? in IPython gets the right
source

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/fiff/raw.pyc
in _read_raw_file(self, fname, allow_maxshield, preload, verbose)
     137 ext = os.path.splitext(fname)[1].lower()
     138 whole_file = preload if '.gz' in ext else False
--> 139 fid, tree, _ = fiff_open(fname, preload=whole_file)
     140
     141 # Read the measurement info

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/utils.pyc
in dec(*args, **kwargs)
     263 return ret
     264 else:
--> 265 return function(*args, **kwargs)
     266
     267 # set __wrapped__ attribute so ?? in IPython gets the right
source

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/fiff/open.pyc
in fiff_open(fname, preload, verbose)
      83 while tag.next >= 0:
      84 pos = fid.tell()
---> 85 tag = read_tag_info(fid)
      86 tag.pos = pos
      87 directory.append(tag)

/usr/local/lib/python2.7/dist-packages/mne-0.6.git-py2.7.egg/mne/fiff/tag.pyc
in read_tag_info(fid)
      67 """
      68 s = fid.read(4 * 4)
---> 69 tag = Tag(*struct.unpack(">iiii", s))
      70 if tag.next == 0:
      71 fid.seek(tag.size, 1)

error: unpack requires a string argument of length 16

hi Andy,

can you read this file otherwise with mne_browse_raw or mne_process_raw?

if yes can you share the file via dropbox or any other service?

thanks
Alex

Hi Alex,

Yes, I can open the file with mne_browse_raw and can create evoked
responses from it via mne_process_raw which themselves can be read via
mne.fiff.read_evoked.

An additional piece of information I just discovered: I can open the
raw file straight from the acquisition. The file that I can cannot open
was written via a modified version of fiff_write_raw_segment.m (buffer
adjusted from 30 to 0.5 seconds) after some preprocessing in MATLAB. I
haven't run into this issue with other subjects processed using the
exact same stream. There are links to three files below. The first two
are from the troublesome subject. The last is a raw file, after MATLAB
preprocessing, that can be opened with mne.fiff.Raw.

http://ubuntuone.com/69KPvr8lU4Goz7Hkm7MPJH

http://ubuntuone.com/3QiiHgl7Oxr5astCIFwv6K

http://ubuntuone.com/2kcJZjdCZJg2xpdAymGcI3

Thanks for the help,
Andy

p.s. happy to learn that ICA has now been incorporated into the python
package. This closes my data analysis loop to keep me in shell/python.
Thanks Alex/Denis.

hi Andy,

for whatever reason you have an empty Tag in your fiff file.

this patch should fix the problem:

https://github.com/mne-tools/mne-python/pull/356

let me know if it does so we can accept this patch.

Best,
Alex