[med-svn] [python-mne] 03/376: first working version of read_evoked

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:21:54 UTC 2015


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 c3d0c6dce169e24a19ac64f314eba1d699f8e5b4
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Mon Dec 27 18:41:22 2010 -0500

    first working version of read_evoked
---
 examples/{read_ave.py => read_evoked.py} |  5 ++++-
 fiff/evoked.py                           | 14 +++++++-------
 fiff/tag.py                              | 18 +++++++++---------
 3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/examples/read_ave.py b/examples/read_evoked.py
similarity index 81%
rename from examples/read_ave.py
rename to examples/read_evoked.py
index ae3e243..6c2c402 100644
--- a/examples/read_ave.py
+++ b/examples/read_evoked.py
@@ -18,5 +18,8 @@ fname = 'sm02a1-ave.fif'
 # is_tree(meas)
 # meas_info = fiff.tree.dir_tree_find(meas, fiff.FIFF.FIFFB_MEAS_INFO)
 
-data = fiff.read_evoked(fname, setno=0)
+data = fiff.read_evoked(fname)
 
+# import pylab as pl
+# pl.plot(data['evoked']['times'], data['evoked']['epochs'][:306,:].T)
+# pl.show()
diff --git a/fiff/evoked.py b/fiff/evoked.py
index 9aba2ce..81f7dca 100644
--- a/fiff/evoked.py
+++ b/fiff/evoked.py
@@ -25,7 +25,7 @@ def read_proj(fid, node):
 
     tag = find_tag(fid, nodes[0], FIFF.FIFF_NCHAN)
     if tag is not None:
-        global_nchan = tag.data;
+        global_nchan = tag.data
 
     items = dir_tree_find(nodes[0], FIFF.FIFFB_PROJ_ITEM)
     for i in range(len(items)):
@@ -72,13 +72,13 @@ def read_proj(fid, node):
         else:
             raise ValueError, 'Projection item channel list missing'
 
-        tag = find_tag(fid, item,FIFF.FIFF_PROJ_ITEM_VECTORS);
+        tag = find_tag(fid, item, FIFF.FIFF_PROJ_ITEM_VECTORS);
         if tag is not None:
             data = tag.data;
         else:
             raise ValueError, 'Projection item data missing'
 
-        tag = find_tag(fid, item,FIFF.FIFF_MNE_PROJ_ITEM_ACTIVE);
+        tag = find_tag(fid, item, FIFF.FIFF_MNE_PROJ_ITEM_ACTIVE);
         if tag is not None:
             active = tag.data;
         else:
@@ -289,7 +289,7 @@ def read_meas_info(source, tree=None):
             kind = acqpars.directory[k].kind
             pos  = acqpars.directory[k].pos
             if kind == FIFF.FIFF_DACQ_PARS:
-                tag = read_tag(fid,pos)
+                tag = read_tag(fid, pos)
                 acq_pars = tag.data
             elif kind == FIFF.FIFF_DACQ_STIM:
                tag = read_tag(fid, pos)
@@ -299,7 +299,7 @@ def read_meas_info(source, tree=None):
     projs = read_proj(fid, meas_info)
 
     #   Load the CTF compensation data
-    comps = read_ctf_comp(fid, meas_info,chs)
+    comps = read_ctf_comp(fid, meas_info, chs)
 
     #   Load the bad channel list
     bads = read_bad_channels(fid, meas_info)
@@ -368,7 +368,7 @@ def read_meas_info(source, tree=None):
     return info, meas
 
 
-def read_evoked(fname, setno=1):
+def read_evoked(fname, setno=0):
     """
     [data] = fiff_read_evoked(fname,setno)
 
@@ -558,7 +558,7 @@ def read_evoked(fname, setno=1):
                                    is_smsh=is_smsh[setno],
                                    nave=nave, first=first,
                                    last=last, comment=comment,
-                                   times=np.arange(first, last,
+                                   times=np.arange(first, last+1,
                                             dtype=np.float) / info['sfreq'],
                                    epochs=all_data))
 
diff --git a/fiff/tag.py b/fiff/tag.py
index 693bbd0..e0144bd 100644
--- a/fiff/tag.py
+++ b/fiff/tag.py
@@ -63,7 +63,7 @@ def read_tag(fid, pos=None):
                 fid.seek(tag.size - 4, 1)
                 ndim = np.fromfile(fid, dtype='>i', count=1)
                 fid.seek(-(ndim + 1) * 4, 1)
-                dims = np.fromfile(fid, dtype='>i', count=ndim)
+                dims = np.fromfile(fid, dtype='>i', count=ndim)[::-1]
                 #
                 # Back to where the data start
                 #
@@ -75,21 +75,21 @@ def read_tag(fid, pos=None):
                 matrix_type = data_type & tag.type
 
                 if matrix_type == FIFF.FIFFT_INT:
-                    tag.data = np.fromfile(fid, dtype='>i', count=dims.prod()).reshape(dims).T
+                    tag.data = np.fromfile(fid, dtype='>i', count=dims.prod()).reshape(dims)
                 elif matrix_type == FIFF.FIFFT_JULIAN:
-                    tag.data = np.fromfile(fid, dtype='>i', count=dims.prod()).reshape(dims).T
+                    tag.data = np.fromfile(fid, dtype='>i', count=dims.prod()).reshape(dims)
                 elif matrix_type == FIFF.FIFFT_FLOAT:
-                    tag.data = np.fromfile(fid, dtype='>f4', count=dims.prod()).reshape(dims).T
+                    tag.data = np.fromfile(fid, dtype='>f4', count=dims.prod()).reshape(dims)
                 elif matrix_type == FIFF.FIFFT_DOUBLE:
-                    tag.data = np.fromfile(fid, dtype='>f8', count=dims.prod()).reshape(dims).T
+                    tag.data = np.fromfile(fid, dtype='>f8', count=dims.prod()).reshape(dims)
                 elif matrix_type == FIFF.FIFFT_COMPLEX_FLOAT:
                     data = np.fromfile(fid, dtype='>f4', count=2*dims.prod())
                     # Note: we need the non-conjugate transpose here
-                    tag.data = (data[::2] + 1j * data[1::2]).reshape(dims).T
+                    tag.data = (data[::2] + 1j * data[1::2]).reshape(dims)
                 elif matrix_type == FIFF.FIFFT_COMPLEX_DOUBLE:
                     data = np.fromfile(fid, dtype='>f8', count=2*dims.prod())
                     # Note: we need the non-conjugate transpose here
-                    tag.data = (data[::2] + 1j * data[1::2]).reshape(dims).T
+                    tag.data = (data[::2] + 1j * data[1::2]).reshape(dims)
                 else:
                     raise ValueError, 'Cannot handle matrix of type %d yet' % matrix_type
 
@@ -189,8 +189,8 @@ def read_tag(fid, pos=None):
                 tag.data['scanno'] = np.fromfile(fid, dtype=">i4", count=1)
                 tag.data['logno'] = np.fromfile(fid, dtype=">i4", count=1)
                 tag.data['kind'] = np.fromfile(fid, dtype=">i4", count=1)
-                tag.data['range'] = np.fromfile(fid, dtype=">i4", count=1)
-                tag.data['cal'] = np.fromfile(fid, dtype=">i4", count=1)
+                tag.data['range'] = np.fromfile(fid, dtype=">f4", count=1)
+                tag.data['cal'] = np.fromfile(fid, dtype=">f4", count=1)
                 tag.data['coil_type'] = np.fromfile(fid, dtype=">i4", count=1)
                 #
                 #   Read the coil coordinate system definition

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git



More information about the debian-med-commit mailing list