This is an automated email from the git hooks/post-receive script. yoh pushed a commit to annotated tag v0.1 in repository python-mne.
commit 5e8cb91950391d5f4f7e7ba114c8412ad95d6cc5 Author: Alexandre Gramfort <[email protected]> Date: Wed Jan 5 16:38:24 2011 -0500 fix in raw + test raw write --- examples/read_write_raw.py | 12 ++---------- fiff/raw.py | 2 +- fiff/tests/test_raw.py | 45 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/examples/read_write_raw.py b/examples/read_write_raw.py index 328c74a..7e5df88 100644 --- a/examples/read_write_raw.py +++ b/examples/read_write_raw.py @@ -5,7 +5,6 @@ Read and write raw data in 60-sec blocks print __doc__ from math import ceil -from fiff.constants import FIFF import fiff @@ -19,6 +18,7 @@ want_meg = True want_eeg = False want_stim = False include = ['STI 014'] +# include = [] # include = ['STI101', 'STI201', 'STI301'] picks = fiff.pick_types(raw['info'], meg=want_meg, eeg=want_eeg, @@ -38,7 +38,7 @@ quantum = int(ceil(quantum_sec * raw['info']['sfreq'])) # # To read the whole file at once set # -# quantum = to - from + 1; +# quantum = to - from_ + 1; # # # Read and write all the data @@ -54,14 +54,6 @@ for first in range(from_, to, quantum): raw['fid'].close() outfid.close() print inst - # # - # # You can add your own miracle here - # # - # print 'Writing...' - # if first_buffer: - # if first > 0: - # fiff.write.write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, first) - # first_buffer = False fiff.write_raw_buffer(outfid, data, cals) print '[done]' diff --git a/fiff/raw.py b/fiff/raw.py index d9ac315..81174bd 100644 --- a/fiff/raw.py +++ b/fiff/raw.py @@ -473,7 +473,7 @@ def start_writing_raw(name, info, sel=None): # # Scan numbers may have been messed up # - chs[k].scanno = k + chs[k].scanno = k + 1 # scanno starts at 1 in FIF format chs[k].range = 1.0 cals.append(chs[k]['cal']) write_ch_info(fid, chs[k]) diff --git a/fiff/tests/test_raw.py b/fiff/tests/test_raw.py index df98397..4643fe2 100644 --- a/fiff/tests/test_raw.py +++ b/fiff/tests/test_raw.py @@ -1,9 +1,9 @@ import os import os.path as op -import numpy as np from numpy.testing import assert_array_almost_equal, assert_equal +from math import ceil import fiff MNE_SAMPLE_DATASET_PATH = os.getenv('MNE_SAMPLE_DATASET_PATH') @@ -23,3 +23,46 @@ def test_io_raw(): data, times = fiff.read_raw_segment_times(raw, from_=100, to=115, sel=meg_channels_idx) + # Writing + + # Set up pick list: MEG + STI 014 - bad channels + want_meg = True + want_eeg = False + want_stim = False + include = ['STI 014'] + + picks = fiff.pick_types(raw['info'], meg=want_meg, eeg=want_eeg, + stim=want_stim, include=include, + exclude=raw['info']['bads']) + + print "Number of picked channels : %d" % len(picks) + + outfid, cals = fiff.start_writing_raw('raw.fif', raw['info'], picks) + # + # Set up the reading parameters + # + from_ = raw['first_samp'] + to = raw['last_samp'] + quantum_sec = 10 + quantum = int(ceil(quantum_sec * raw['info']['sfreq'])) + # + # Read and write all the data + # + first_buffer = True + for first in range(from_, to, quantum): + last = first + quantum + if last > to: + last = to + try: + data, times = fiff.read_raw_segment(raw, first, last, picks) + except Exception as inst: + raw['fid'].close() + outfid.close() + print inst + + fiff.write_raw_buffer(outfid, data, cals) + print '[done]' + + fiff.finish_writing_raw(outfid) + raw['fid'].close() + -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
