This is an automated email from the git hooks/post-receive script. yoh pushed a commit to tag 0.4 in repository python-mne.
commit 5f33313ef77c781eae08cb93e6a91c2b3986eb5d Author: Alexandre Gramfort <[email protected]> Date: Fri Mar 2 11:16:15 2012 +0100 ENH : new mne_surf2bem.py that mimics mne_surf2bem without crashing when surface is not clean --- bin/mne_surf2bem.py | 34 ++++++++++++++++++++++++++++++++++ mne/surface.py | 5 +++-- setup.py | 3 ++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/bin/mne_surf2bem.py b/bin/mne_surf2bem.py new file mode 100755 index 0000000..368b9f4 --- /dev/null +++ b/bin/mne_surf2bem.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +"""Example usage + +mne_surf2bem.py --surf ${SUBJECTS_DIR}/${SUBJECT}/surf/lh.seghead --fif \ + ${SUBJECTS_DIR}/${SUBJECT}/bem/${SUBJECT}-head.fif --id=4 + +""" +# Authors: Alexandre Gramfort <[email protected]> +# +# License: BSD (3-clause) + +import mne + +if __name__ == '__main__': + + from optparse import OptionParser + + parser = OptionParser() + parser.add_option("-s", "--surf", dest="surf", + help="Surface in Freesurfer format", metavar="FILE") + parser.add_option("-f", "--fif", dest="fif", + help="FIF file produced", metavar="FILE") + parser.add_option("-i", "--id", dest="id", default=4, + help=("Surface Id (e.g. 4 sur head surface)")) + + (options, args) = parser.parse_args() + + print "Converting %s to BEM FIF file." % options.surf + + points, tris = mne.read_surface(options.surf) + points *= 1e-3 + surf = dict(coord_frame=5, id=int(options.id), nn=None, np=len(points), + ntri=len(tris), rr=points, sigma=1, tris=tris) + mne.write_bem_surface(options.fif, surf) diff --git a/mne/surface.py b/mne/surface.py index b99b6c7..9ea7b8a 100644 --- a/mne/surface.py +++ b/mne/surface.py @@ -245,7 +245,7 @@ def read_surface(filepath): """Load in a Freesurfer surface mesh in triangular format.""" with open(filepath, "rb") as fobj: magic = _fread3(fobj) - if magic == 16777215: # Quad file + if (magic == 16777215) or (magic == 16777213): # Quad file or new quad nvert = _fread3(fobj) nquad = _fread3(fobj) coords = np.fromfile(fobj, ">i2", nvert * 3).astype(np.float) @@ -277,7 +277,8 @@ def read_surface(filepath): coords = np.fromfile(fobj, ">f4", vnum * 3).reshape(vnum, 3) faces = np.fromfile(fobj, ">i4", fnum * 3).reshape(fnum, 3) else: - raise ValueError("File does not appear to be a Freesurfer surface") + raise ValueError("%s does not appear to be a Freesurfer surface" + % filepath) coords = coords.astype(np.float) # XXX: due to mayavi bug on mac 32bits return coords, faces diff --git a/setup.py b/setup.py index 398d104..e1f513b 100755 --- a/setup.py +++ b/setup.py @@ -59,4 +59,5 @@ if __name__ == "__main__": 'mne.minimum_norm', 'mne.minimum_norm.tests', 'mne.layouts', 'mne.time_frequency', 'mne.time_frequency.tests'], - scripts=['bin/mne_clean_eog_ecg.py', 'bin/mne_flash_bem_model.py']) + scripts=['bin/mne_clean_eog_ecg.py', 'bin/mne_flash_bem_model.py', + 'bin/mne_surf2bem.py']) -- 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
