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 26a5f9b6cb14fac9de6790de7e4b762edb0d2b94 Author: Alexandre Gramfort <[email protected]> Date: Tue Aug 16 21:22:26 2011 -0400 ENH: adding drop_small_buffer to Raw.save for maxfilter --- mne/fiff/raw.py | 20 +++++++++++++++----- mne/fiff/tests/test_raw.py | 9 +++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mne/fiff/raw.py b/mne/fiff/raw.py index 0e0ac0b..bd72cbe 100644 --- a/mne/fiff/raw.py +++ b/mne/fiff/raw.py @@ -188,7 +188,8 @@ class Raw(dict): else: return super(Raw, self).__getitem__(item) - def save(self, fname, picks=None, tmin=0, tmax=None, quantum_sec=10): + def save(self, fname, picks=None, tmin=0, tmax=None, buffer_size_sec=10, + drop_small_buffer=False): """Save raw data to file Parameters @@ -205,9 +206,13 @@ class Raw(dict): tmax : int Time in seconds of last sample to save - quantum_sec : float + buffer_size_sec : float Size of data chuncks in seconds. + drop_small_buffer: bool + Drop or not the last buffer. It is required by maxfilter (SSS) + that only accepts raw files with buffers of the same size. + """ outfid, cals = start_writing_raw(fname, self.info, picks) # @@ -222,13 +227,13 @@ class Raw(dict): else: stop = int(floor(tmax * self.info['sfreq'])) - quantum = int(ceil(quantum_sec * self.info['sfreq'])) + buffer_size = int(ceil(buffer_size_sec * self.info['sfreq'])) # # Read and write all the data # write_int(outfid, FIFF.FIFF_FIRST_SAMPLE, start) - for first in range(start, stop, quantum): - last = first + quantum + for first in range(start, stop, buffer_size): + last = first + buffer_size if last >= stop: last = stop + 1 @@ -237,6 +242,11 @@ class Raw(dict): else: data, times = self[picks, first:last] + if (drop_small_buffer and (first > start) + and (len(times) < buffer_size)): + print 'Skipping data chunk due to small buffer ... [done]\n' + break + print 'Writing ... ', write_raw_buffer(outfid, data, cals) print '[done]' diff --git a/mne/fiff/tests/test_raw.py b/mne/fiff/tests/test_raw.py index c4eedf7..42fcd7b 100644 --- a/mne/fiff/tests/test_raw.py +++ b/mne/fiff/tests/test_raw.py @@ -32,6 +32,15 @@ def test_io_raw(): exclude=raw.info['bads']) print "Number of picked channels : %d" % len(picks) + # Writing with drop_small_buffer True + raw.save('raw.fif', picks, tmin=0, tmax=4, buffer_size_sec=3, + drop_small_buffer=True) + raw2 = Raw('raw.fif') + + sel = pick_channels(raw2.ch_names, meg_ch_names) + data2, times2 = raw2[sel, :] + assert times2.max() <= 3 + # Writing raw.save('raw.fif', picks, tmin=0, tmax=5) -- 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
