[med-svn] [python-mne] 289/376: ENH : adding option for nb smoothing iter in morphing

Yaroslav Halchenko debian at onerussian.com
Fri Nov 27 17:23:07 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 49b5fe94b367827896ec537b1edfa3e1f6637fdb
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date:   Mon Jun 6 09:51:09 2011 -0400

    ENH : adding option for nb smoothing iter in morphing
---
 mne/source_estimate.py            | 20 ++++++++++++++------
 mne/tests/test_source_estimate.py |  3 ++-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/mne/source_estimate.py b/mne/source_estimate.py
index ef52ccd..02e61ad 100644
--- a/mne/source_estimate.py
+++ b/mne/source_estimate.py
@@ -274,7 +274,7 @@ def mesh_edges(tris):
     return edges
 
 
-def morph_data(subject_from, subject_to, stc_from, grade=5,
+def morph_data(subject_from, subject_to, stc_from, grade=5, smooth=None,
                subjects_dir=None):
     """Morph a source estimate from one subject to another
 
@@ -290,6 +290,10 @@ def morph_data(subject_from, subject_to, stc_from, grade=5,
         Source estimates for subject "from" to morph
     grade : int
         Resolution of the icosahedral mesh (typically 5)
+    smooth : int or None
+        Number of iterations for the smoothing of the surface data.
+        If None, smooth is automatically defined to fill the surface
+        with non-zero values.
     subjects_dir : string
         Path to SUBJECTS_DIR is not set in the environment
 
@@ -336,13 +340,17 @@ def morph_data(subject_from, subject_to, stc_from, grade=5,
             data1 = e_use * np.ones(len(idx_use))
             data[hemi] = e_use * data[hemi]
             idx_use = np.where(data1)[0]
-            if (k == (n_iter - 1)) or (len(idx_use) >= n_vertices):
-                data[hemi][idx_use, :] /= data1[idx_use][:, None]
+            if smooth is None:
+                if ((k == (n_iter - 1)) or (len(idx_use) >= n_vertices)):
+                    # stop when source space in filled with non-zeros
+                    break
+            elif k == (smooth - 1):
                 break
-            else:
-                data[hemi] = data[hemi][idx_use, :] / data1[idx_use][:, None]
+            data[hemi] = data[hemi][idx_use, :] / data1[idx_use][:, None]
 
-        print '\t%d smooth iterations done.' % k
+        data[hemi][idx_use, :] /= data1[idx_use][:, None]
+
+        print '\t%d smooth iterations done.' % (k + 1)
         dmap[hemi] = maps[hemi] * data[hemi]
 
     ico_file_name = os.path.join(os.environ['MNE_ROOT'], 'share', 'mne',
diff --git a/mne/tests/test_source_estimate.py b/mne/tests/test_source_estimate.py
index 586f04b..a84eb30 100644
--- a/mne/tests/test_source_estimate.py
+++ b/mne/tests/test_source_estimate.py
@@ -34,7 +34,8 @@ def test_morph_data():
     subject_to = 'morph'
     fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-meg')
     stc_from = mne.SourceEstimate(fname)
-    stc_to = mne.morph_data(subject_from, subject_to, stc_from, 3)
+    stc_to = mne.morph_data(subject_from, subject_to, stc_from,
+                            grade=3, smooth=12)
 
     stc_to.save('%s_audvis-meg' % subject_to)
 

-- 
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