[med-svn] [python-mne] 177/353: Added mne_maxfilter.py, proj argument in proj_ecg script, setup.py
Yaroslav Halchenko
debian at onerussian.com
Fri Nov 27 17:24:54 UTC 2015
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 7d8f88ca38f5ac745ece20e3251df4e9b1f883dc
Author: Martin Luessi <mluessi at nmr.mgh.harvard.edu>
Date: Thu May 10 13:47:48 2012 -0400
Added mne_maxfilter.py, proj argument in proj_ecg script, setup.py
---
bin/mne_compute_proj_ecg.py | 8 +++
bin/mne_compute_proj_eog.py | 8 +--
bin/mne_maxfilter.py | 143 +++++++++++++++++++++++++++++++++++++++++
mne/preprocessing/maxfilter.py | 6 +-
setup.py | 6 +-
5 files changed, 163 insertions(+), 8 deletions(-)
diff --git a/bin/mne_compute_proj_ecg.py b/bin/mne_compute_proj_ecg.py
index 350b2d6..eb62cbd 100755
--- a/bin/mne_compute_proj_ecg.py
+++ b/bin/mne_compute_proj_ecg.py
@@ -48,6 +48,9 @@ if __name__ == '__main__':
parser.add_option("-a", "--average", dest="average", action="store_true",
help="Compute SSP after averaging",
default=False)
+ parser.add_option("--proj", dest="proj",
+ help="Use SSP projections from a fif file.",
+ default=None)
parser.add_option("--filtersize", dest="filter_length",
help="Number of taps to use for filtering",
default=2048)
@@ -109,6 +112,7 @@ if __name__ == '__main__':
no_proj = options.no_proj
bad_fname = options.bad_fname
event_id = options.event_id
+ proj_fname = options.proj
if bad_fname is not None:
bads = [w.rstrip().split()[0] for w in open(bad_fname).readlines()]
@@ -137,6 +141,10 @@ if __name__ == '__main__':
raw.close()
+ if proj_fname is not None:
+ print 'Including SSP projections from : %s' % proj_fname
+ projs = mne.read_proj(proj_fname) + projs
+
if isinstance(preload, basestring) and os.path.exists(preload):
os.remove(preload)
diff --git a/bin/mne_compute_proj_eog.py b/bin/mne_compute_proj_eog.py
index 9fd2cfa..504a40f 100755
--- a/bin/mne_compute_proj_eog.py
+++ b/bin/mne_compute_proj_eog.py
@@ -136,10 +136,6 @@ if __name__ == '__main__':
raw = mne.fiff.Raw(raw_in, preload=preload)
- if proj_fname is not None:
- print 'Including SSP projections from : %s' % proj_fname
- raw.info['projs'] += mne.read_proj(proj_fname)
-
projs, events = mne.preprocessing.compute_proj_eog(raw, tmin, tmax,
n_grad, n_mag, n_eeg, l_freq, h_freq, average,
filter_length, n_jobs, reject, bads,
@@ -147,6 +143,10 @@ if __name__ == '__main__':
raw.close()
+ if proj_fname is not None:
+ print 'Including SSP projections from : %s' % proj_fname
+ projs = mne.read_proj(proj_fname) + projs
+
if isinstance(preload, basestring) and os.path.exists(preload):
os.remove(preload)
diff --git a/bin/mne_maxfilter.py b/bin/mne_maxfilter.py
new file mode 100755
index 0000000..606dd70
--- /dev/null
+++ b/bin/mne_maxfilter.py
@@ -0,0 +1,143 @@
+#!/usr/bin/env python
+""" Apply MaxFilter
+
+Example usage:
+
+$mne_maxfilter.py -i sample_audvis_raw.fif --st
+
+This will apply MaxFilter with the MaxSt extension. The origin used
+by MaxFilter is computed by mne-python by fitting a sphere to the
+headshape points.
+"""
+
+# Authors : Martin Luessi <mluessi at nmr.mgh.harvard.edu>
+
+import sys
+import os
+import mne
+
+
+if __name__ == '__main__':
+
+ from optparse import OptionParser
+
+ parser = OptionParser()
+ parser.add_option("-i", "--in", dest="in_fname",
+ help="Input raw FIF file", metavar="FILE")
+ parser.add_option("-o", dest="out_fname",
+ help="Output FIF file (if not set, suffix '_sss' will be used)",
+ metavar="FILE", default=None)
+ parser.add_option("--origin", dest="origin",
+ help="Head origin in mm, or a filename to read the origin from. "
+ "If not set it will be estimated from headshape points",
+ default=None)
+ parser.add_option("--origin-out", dest="origin_out",
+ help="Filename to use for computed origin", default=None)
+ parser.add_option("--frame", dest="frame", type="string",
+ help="Coordinate frame for head center ('device' or 'head')",
+ default="device")
+ parser.add_option("--bad", dest="bad", type="string",
+ help="List of static bad channels",
+ default=None)
+ parser.add_option("--autobad", dest="autobad", type="string",
+ help="Set automated bad channel detection ('on', 'off', 'n')",
+ default="off")
+ parser.add_option("--skip", dest="skip",
+ help="Skips raw data sequences, time intervals pairs in sec, e.g.: 0 30 120 150",
+ default=None)
+ parser.add_option("--force", dest="force", action="store_true",
+ help="Ignore program warnings",
+ default=False)
+ parser.add_option("--st", dest="st", action="store_true",
+ help="Apply the time-domain MaxST extension",
+ default=False)
+ parser.add_option("--buflen", dest="st_buflen", type="float",
+ help="MaxSt buffer length in sec",
+ default=16.0)
+ parser.add_option("--corr", dest="st_corr", type="float",
+ help="MaxSt subspace correlation",
+ default=0.96)
+ parser.add_option("--trans", dest="mv_trans",
+ help="Transforms the data into the coil definitions of in_fname, or into the default frame",
+ default=None)
+ parser.add_option("--movecomp", dest="mv_comp",
+ help="Estimates and compensates head movements in continuous raw data",
+ default=False)
+ parser.add_option("--headpos", dest="mv_headpos", action="store_true",
+ help="Estimates and stores head position parameters, but does not compensate movements",
+ default=False)
+ parser.add_option("--hp", dest="mv_hp", type="string",
+ help="Stores head position data in an ascii file",
+ default=None)
+ parser.add_option("--hpistep", dest="mv_hpistep", type="float",
+ help="Sets head position update interval in ms",
+ default=None)
+ parser.add_option("--hpisubt", dest="mv_hpisubt", type="string",
+ help="Subtracts hpi signals: sine amplitudes, amp + baseline, or switch off",
+ default=None)
+ parser.add_option("--nohpicons", dest="mv_hpicons", action="store_false",
+ help="Do not check initial consistency isotrak vs hpifit",
+ default=True)
+ parser.add_option("--linefreq", dest="linefreq", type="float",
+ help="Sets the basic line interference frequency (50 or 60 Hz)",
+ default=None)
+ parser.add_option("--nooverwrite", dest="overwrite", action="store_false",
+ help="Do not overwrite output file if it already exists",
+ default=True)
+ parser.add_option("--args", dest="mx_args", type="string",
+ help="Additional command line arguments to pass to MaxFilter",
+ default="")
+
+ options, args = parser.parse_args()
+
+ in_fname = options.in_fname
+
+ if in_fname is None:
+ parser.print_help()
+ sys.exit(-1)
+
+ out_fname = options.out_fname
+ origin = options.origin
+ origin_out = options.origin_out
+ frame = options.frame
+ bad = options.bad
+ autobad = options.autobad
+ skip = options.skip
+ force = options.force
+ st = options.st
+ st_buflen = options.st_buflen
+ st_corr = options.st_corr
+ mv_trans = options.mv_trans
+ mv_comp = options.mv_comp
+ mv_headpos = options.mv_headpos
+ mv_hp = options.mv_hp
+ mv_hpistep = options.mv_hpistep
+ mv_hpisubt = options.mv_hpisubt
+ mv_hpicons = options.mv_hpicons
+ linefreq = options.linefreq
+ overwrite = options.overwrite
+ mx_args = options.mx_args
+
+ if in_fname.endswith('_raw.fif') or in_fname.endswith('-raw.fif'):
+ prefix = in_fname[:-8]
+ else:
+ prefix = in_fname[:-4]
+
+ if out_fname is None:
+ if st:
+ out_fname = prefix + '_tsss.fif'
+ else:
+ out_fname = prefix + '_sss.fif'
+
+ if origin is not None and os.path.exists(origin):
+ origin = open(origin, 'r').readlines()[0].strip()
+
+ origin = mne.preprocessing.apply_maxfilter(in_fname, out_fname, origin, frame,
+ bad, autobad, skip, force, st, st_buflen, st_corr, mv_trans,
+ mv_comp, mv_headpos, mv_hp, mv_hpistep, mv_hpisubt, mv_hpicons,
+ linefreq, mx_args, overwrite)
+
+ if origin_out is not None:
+ fid = open(origin_out, 'w')
+ fid.write(origin + '\n')
+ fid.close()
diff --git a/mne/preprocessing/maxfilter.py b/mne/preprocessing/maxfilter.py
index 5c41233..e9bb121 100644
--- a/mne/preprocessing/maxfilter.py
+++ b/mne/preprocessing/maxfilter.py
@@ -171,8 +171,8 @@ def apply_maxfilter(in_fname, out_fname, origin=None, frame='device',
Returns
-------
- origin: ndarray
- Head origin in selected coordinate frame (mm)
+ origin: string
+ Head origin in selected coordinate frame
"""
# check for possible maxfilter bugs
@@ -266,3 +266,5 @@ def apply_maxfilter(in_fname, out_fname, origin=None, frame='device',
if st != 0:
raise RuntimeError('MaxFilter returned non-zero exit status %d' % st)
print '[done]'
+
+ return origin
diff --git a/setup.py b/setup.py
index b6bf6e4..d22bf16 100755
--- a/setup.py
+++ b/setup.py
@@ -58,6 +58,8 @@ if __name__ == "__main__":
'mne.artifacts', 'mne.artifacts.tests',
'mne.minimum_norm', 'mne.minimum_norm.tests',
'mne.layouts',
- 'mne.time_frequency', 'mne.time_frequency.tests'],
+ 'mne.time_frequency', 'mne.time_frequency.tests',
+ 'mne.preprocessing', 'mne.preprocessing.tests'],
scripts=['bin/mne_clean_eog_ecg.py', 'bin/mne_flash_bem_model.py',
- 'bin/mne_surf2bem.py', 'bin/mne_compute_proj_ecg.py'])
+ 'bin/mne_surf2bem.py', 'bin/mne_compute_proj_ecg.py',
+ 'bin/mne_compute_proj_eog.py', 'bin/mne_maxfilter.py'])
--
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