[med-svn] [python-mne] 183/353: opt. to use dif. file for event det.
Yaroslav Halchenko
debian at onerussian.com
Fri Nov 27 17:24:55 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 c1893aa1787271f9e93a17c794a3f5e5dd1778de
Author: Martin Luessi <mluessi at nmr.mgh.harvard.edu>
Date: Wed May 16 16:34:01 2012 -0400
opt. to use dif. file for event det.
---
bin/mne_compute_proj_ecg.py | 18 +++++++++++++++---
bin/mne_compute_proj_eog.py | 18 +++++++++++++++---
mne/preprocessing/ssp.py | 34 +++++++++++++++++++++++-----------
3 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/bin/mne_compute_proj_ecg.py b/bin/mne_compute_proj_ecg.py
index 8468379..acdc104 100755
--- a/bin/mne_compute_proj_ecg.py
+++ b/bin/mne_compute_proj_ecg.py
@@ -83,6 +83,8 @@ if __name__ == '__main__':
default=None)
parser.add_option("--event-id", dest="event_id", type="int",
help="ID to use for events", default=999)
+ parser.add_option("--event-raw", dest="raw_event_fname",
+ help="raw file to use for event detection", default=None)
options, args = parser.parse_args()
@@ -113,6 +115,7 @@ if __name__ == '__main__':
bad_fname = options.bad_fname
event_id = options.event_id
proj_fname = options.proj
+ raw_event_fname = options.raw_event_fname
if bad_fname is not None:
bads = [w.rstrip().split()[0] for w in open(bad_fname).readlines()]
@@ -134,13 +137,22 @@ if __name__ == '__main__':
raw = mne.fiff.Raw(raw_in, preload=preload)
- projs, events = mne.preprocessing.compute_proj_ecg(raw, tmin, tmax,
- n_grad, n_mag, n_eeg, l_freq, h_freq, average,
- filter_length, n_jobs, ch_name, reject,
+ if raw_event_fname is not None:
+ raw_event = mne.fiff.Raw(raw_event_fname)
+ else:
+ raw_event = raw
+
+ projs, events = mne.preprocessing.compute_proj_ecg(raw, raw_event,
+ tmin, tmax, n_grad, n_mag, n_eeg,
+ l_freq, h_freq, average, filter_length,
+ n_jobs, ch_name, reject,
bads, avg_ref, no_proj, event_id)
raw.close()
+ if raw_event_fname is not None:
+ raw_event.close()
+
if proj_fname is not None:
print 'Including SSP projections from : %s' % proj_fname
# append the ecg projs, so they are last in the list
diff --git a/bin/mne_compute_proj_eog.py b/bin/mne_compute_proj_eog.py
index 1320fb3..08c4968 100755
--- a/bin/mne_compute_proj_eog.py
+++ b/bin/mne_compute_proj_eog.py
@@ -86,6 +86,8 @@ if __name__ == '__main__':
default=None)
parser.add_option("--event-id", dest="event_id", type="int",
help="ID to use for events", default=998)
+ parser.add_option("--event-raw", dest="raw_event_fname",
+ help="raw file to use for event detection", default=None)
options, args = parser.parse_args()
@@ -115,6 +117,7 @@ if __name__ == '__main__':
bad_fname = options.bad_fname
event_id = options.event_id
proj_fname = options.proj
+ raw_event_fname = options.raw_event_fname
if bad_fname is not None:
bads = [w.rstrip().split()[0] for w in open(bad_fname).readlines()]
@@ -136,13 +139,22 @@ if __name__ == '__main__':
raw = mne.fiff.Raw(raw_in, preload=preload)
- 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,
+ if raw_event_fname is not None:
+ raw_event = mne.fiff.Raw(raw_event_fname)
+ else:
+ raw_event = raw
+
+ projs, events = mne.preprocessing.compute_proj_eog(raw, raw_event,
+ tmin, tmax, n_grad, n_mag, n_eeg,
+ l_freq, h_freq, average, filter_length,
+ n_jobs, reject, bads,
avg_ref, no_proj, event_id)
raw.close()
+ if raw_event_fname is not None:
+ raw_event.close()
+
if proj_fname is not None:
print 'Including SSP projections from : %s' % proj_fname
# append the eog projs, so they are last in the list
diff --git a/mne/preprocessing/ssp.py b/mne/preprocessing/ssp.py
index d851d29..711df3f 100644
--- a/mne/preprocessing/ssp.py
+++ b/mne/preprocessing/ssp.py
@@ -4,16 +4,14 @@
#
# License: BSD (3-clause)
-import os
-
import numpy as np
from .. import Epochs, compute_proj_evoked, compute_proj_epochs
-from ..fiff import Raw, pick_types, make_eeg_average_ref_proj
+from ..fiff import pick_types, make_eeg_average_ref_proj
from ..artifacts import find_ecg_events, find_eog_events
-def _compute_exg_proj(mode, raw, tmin, tmax,
+def _compute_exg_proj(mode, raw, raw_event, tmin, tmax,
n_grad, n_mag, n_eeg, l_freq, h_freq,
average, filter_length, n_jobs, ch_name,
reject, bads, avg_ref, no_proj, event_id):
@@ -30,6 +28,9 @@ def _compute_exg_proj(mode, raw, tmin, tmax,
raw: mne.fiff.Raw
Raw input file
+ raw_event: mne.fiff.Raw or None
+ Raw file to use for event detection (if None, raw is used)
+
tmin: float
Time before event in second
@@ -87,7 +88,8 @@ def _compute_exg_proj(mode, raw, tmin, tmax,
Detected events
"""
if not raw._preloaded:
- raise ValueError('raw needs to be preloaded, use preload=True in constructor')
+ raise ValueError('raw needs to be preloaded, '
+ 'use preload=True in constructor')
if no_proj:
projs = []
@@ -100,12 +102,16 @@ def _compute_exg_proj(mode, raw, tmin, tmax,
eeg_proj = make_eeg_average_ref_proj(raw.info)
projs.append(eeg_proj)
+ if raw_event is None:
+ raw_event = raw
+
if mode == 'ECG':
print 'Running ECG SSP computation'
- events, _, _ = find_ecg_events(raw, ch_name=ch_name, event_id=event_id)
+ events, _, _ = find_ecg_events(raw_event, ch_name=ch_name,
+ event_id=event_id)
elif mode == 'EOG':
print 'Running EOG SSP computation'
- events = find_eog_events(raw, event_id=event_id)
+ events = find_eog_events(raw_event, event_id=event_id)
else:
ValueError("mode must be 'ECG' or 'EOG'")
@@ -151,7 +157,7 @@ def _compute_exg_proj(mode, raw, tmin, tmax,
return projs, events
-def compute_proj_ecg(raw, tmin=-0.2, tmax=0.4,
+def compute_proj_ecg(raw, raw_event=None, tmin=-0.2, tmax=0.4,
n_grad=2, n_mag=2, n_eeg=2, l_freq=1.0, h_freq=35.0,
average=False, filter_length=2048, n_jobs=1, ch_name=None,
reject=dict(grad=2000e-13, mag=3000e-15, eeg=50e-6,
@@ -167,6 +173,9 @@ def compute_proj_ecg(raw, tmin=-0.2, tmax=0.4,
raw: mne.fiff.Raw
Raw input file
+ raw_event: mne.fiff.Raw or None
+ Raw file to use for event detection (if None, raw is used)
+
tmin: float
Time before event in second
@@ -224,7 +233,7 @@ def compute_proj_ecg(raw, tmin=-0.2, tmax=0.4,
Detected ECG events
"""
- projs, ecg_events = _compute_exg_proj('ECG', raw, tmin, tmax,
+ projs, ecg_events = _compute_exg_proj('ECG', raw, raw_event, tmin, tmax,
n_grad, n_mag, n_eeg, l_freq, h_freq,
average, filter_length, n_jobs, ch_name,
reject, bads, avg_ref, no_proj, event_id)
@@ -232,7 +241,7 @@ def compute_proj_ecg(raw, tmin=-0.2, tmax=0.4,
return projs, ecg_events
-def compute_proj_eog(raw, tmin=-0.2, tmax=0.2,
+def compute_proj_eog(raw, raw_event=None, tmin=-0.2, tmax=0.2,
n_grad=2, n_mag=2, n_eeg=2, l_freq=1.0, h_freq=35.0,
average=False, filter_length=2048, n_jobs=1,
reject=dict(grad=2000e-13, mag=3000e-15, eeg=500e-6,
@@ -248,6 +257,9 @@ def compute_proj_eog(raw, tmin=-0.2, tmax=0.2,
raw: mne.fiff.Raw
Raw input file
+ raw_event: mne.fiff.Raw or None
+ Raw file to use for event detection (if None, raw is used)
+
tmin: float
Time before event in second
@@ -305,7 +317,7 @@ def compute_proj_eog(raw, tmin=-0.2, tmax=0.2,
Detected ECG events
"""
- projs, eog_events = _compute_exg_proj('EOG', raw, tmin, tmax,
+ projs, eog_events = _compute_exg_proj('EOG', raw, raw_event, tmin, tmax,
n_grad, n_mag, n_eeg, l_freq, h_freq,
average, filter_length, n_jobs, None,
reject, bads, avg_ref, no_proj, event_id)
--
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