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 00a3aad7bf8df30a6ccea827508ed51b41c6181a Author: Alexandre Gramfort <[email protected]> Date: Fri Apr 22 13:45:47 2011 -0400 renaming bem_surfaces.py to surface.py + merge surfer.py and surface.py --- mne/__init__.py | 2 +- mne/source_estimate.py | 3 +- mne/{bem_surfaces.py => surface.py} | 43 +++++++++++++++++++ mne/surfer.py | 48 ---------------------- mne/tests/test_source_space.py | 2 - .../{test_bem_surfaces.py => test_surface.py} | 0 6 files changed, 45 insertions(+), 53 deletions(-) diff --git a/mne/__init__.py b/mne/__init__.py index 5326d54..e81addc 100755 --- a/mne/__init__.py +++ b/mne/__init__.py @@ -5,7 +5,7 @@ from .cov import read_cov, write_cov, write_cov_file, Covariance, \ from .event import read_events, write_events, find_events from .forward import read_forward_solution from .source_estimate import read_stc, write_stc, SourceEstimate, morph_data -from .bem_surfaces import read_bem_surfaces +from .surface import read_bem_surfaces from .source_space import read_source_spaces from .epochs import Epochs from .label import label_time_courses, read_label diff --git a/mne/source_estimate.py b/mne/source_estimate.py index 71a620a..453b318 100755 --- a/mne/source_estimate.py +++ b/mne/source_estimate.py @@ -163,8 +163,7 @@ from .fiff.constants import FIFF from .fiff.tag import find_tag from .fiff.open import fiff_open from .fiff.tree import dir_tree_find -from .bem_surfaces import read_bem_surfaces -from .surfer import read_surface +from .surface import read_bem_surfaces, read_surface def read_morph_map(subject_from, subject_to, subjects_dir=None): diff --git a/mne/bem_surfaces.py b/mne/surface.py similarity index 79% rename from mne/bem_surfaces.py rename to mne/surface.py index eb2c18a..fed41f5 100755 --- a/mne/bem_surfaces.py +++ b/mne/surface.py @@ -205,3 +205,46 @@ def _complete_surface_info(this): print '[done]' return this + + +############################################################################### +# Handle freesurfer + +def fread3(fobj): + """Docstring""" + b1, b2, b3 = np.fromfile(fobj, ">u1", 3) + return (b1 << 16) + (b2 << 8) + b3 + + +def read_curvature(filepath): + """Load in curavature values from the ?h.curv file.""" + with open(filepath, "rb") as fobj: + magic = fread3(fobj) + if magic == 16777215: + vnum = np.fromfile(fobj, ">i4", 3)[0] + curv = np.fromfile(fobj, ">f4", vnum) + else: + vnum = magic + fread3(fobj) + curv = np.fromfile(fobj, ">i2", vnum) / 100 + bin_curv = 1 - np.array(curv != 0, np.int) + return bin_curv + + +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: + raise NotImplementedError("Quadrangle surface format reading not " + "implemented") + elif magic != 16777214: + raise ValueError("File does not appear to be a Freesurfer surface") + create_stamp = fobj.readline() + blankline = fobj.readline() + del blankline + vnum = np.fromfile(fobj, ">i4", 1)[0] + fnum = np.fromfile(fobj, ">i4", 1)[0] + vertex_coords = np.fromfile(fobj, ">f4", vnum * 3).reshape(vnum, 3) + faces = np.fromfile(fobj, ">i4", fnum * 3).reshape(fnum, 3) + return vertex_coords, faces diff --git a/mne/surfer.py b/mne/surfer.py deleted file mode 100644 index 21f77de..0000000 --- a/mne/surfer.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Set of tools to interact with Freesurfer data -""" - -# Authors: Alexandre Gramfort <[email protected]> -# -# License: BSD (3-clause) - -import numpy as np - - -def fread3(fobj): - """Docstring""" - b1, b2, b3 = np.fromfile(fobj, ">u1", 3) - return (b1 << 16) + (b2 << 8) + b3 - - -def read_curvature(filepath): - """Load in curavature values from the ?h.curv file.""" - with open(filepath, "rb") as fobj: - magic = fread3(fobj) - if magic == 16777215: - vnum = np.fromfile(fobj, ">i4", 3)[0] - curv = np.fromfile(fobj, ">f4", vnum) - else: - vnum = magic - fread3(fobj) - curv = np.fromfile(fobj, ">i2", vnum) / 100 - bin_curv = 1 - np.array(curv != 0, np.int) - return bin_curv - - -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: - raise NotImplementedError("Quadrangle surface format reading not " - "implemented") - elif magic != 16777214: - raise ValueError("File does not appear to be a Freesurfer surface") - create_stamp = fobj.readline() - blankline = fobj.readline() - del blankline - vnum = np.fromfile(fobj, ">i4", 1)[0] - fnum = np.fromfile(fobj, ">i4", 1)[0] - vertex_coords = np.fromfile(fobj, ">f4", vnum * 3).reshape(vnum, 3) - faces = np.fromfile(fobj, ">i4", fnum * 3).reshape(fnum, 3) - return vertex_coords, faces diff --git a/mne/tests/test_source_space.py b/mne/tests/test_source_space.py index dedfdca..693e3b7 100755 --- a/mne/tests/test_source_space.py +++ b/mne/tests/test_source_space.py @@ -31,5 +31,3 @@ def test_read_source_spaces(): assert rh_faces.max() == rh_points.shape[0] - 1 assert rh_use_faces.min() >= 0 assert rh_use_faces.max() <= lh_points.shape[0] - 1 - -def test_morph_data(): \ No newline at end of file diff --git a/mne/tests/test_bem_surfaces.py b/mne/tests/test_surface.py similarity index 100% rename from mne/tests/test_bem_surfaces.py rename to mne/tests/test_surface.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
