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 7962858a133cabdd37caa169e94da24206740ac7 Author: Martin Luessi <[email protected]> Date: Fri Jun 29 12:03:04 2012 -0400 proj idle/active handling --- .../plot_compute_raw_data_spectrum.py | 2 +- mne/epochs.py | 6 +++--- mne/fiff/evoked.py | 6 +++--- mne/fiff/proj.py | 21 +++++++++++++-------- mne/fiff/raw.py | 11 ++--------- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/examples/time_frequency/plot_compute_raw_data_spectrum.py b/examples/time_frequency/plot_compute_raw_data_spectrum.py index 804869b..4453d17 100644 --- a/examples/time_frequency/plot_compute_raw_data_spectrum.py +++ b/examples/time_frequency/plot_compute_raw_data_spectrum.py @@ -31,7 +31,7 @@ exclude = raw.info['bads'] + ['MEG 2443', 'EEG 053'] # bads + 2 more # Add SSP projection vectors to reduce EOG and ECG artifacts projs = read_proj(proj_fname) -raw.add_proj(projs, activate=True, remove_existing=True) +raw.add_proj(projs, remove_existing=True) # Pick MEG magnetometers in the Left-temporal region selection = read_selection('Left-temporal') diff --git a/mne/epochs.py b/mne/epochs.py index 5d922b3..00e247f 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -142,9 +142,6 @@ class Epochs(object): print 'No projector specified for these data' self.proj = None else: - # Activate the projection items - self.info['projs'] = activate_proj(self.info['projs'], copy=False) - # Add EEG ref reference proj eeg_sel = pick_types(self.info, meg=False, eeg=True) if len(eeg_sel) > 0: @@ -161,6 +158,9 @@ class Epochs(object): % nproj) self.proj = proj + # The projection items have been activated + self.info['projs'] = activate_proj(self.info['projs'], copy=False) + # Set up the CTF compensator current_comp = fiff.get_current_comp(self.info) if current_comp > 0: diff --git a/mne/fiff/evoked.py b/mne/fiff/evoked.py index 5ea12f0..0977f35 100644 --- a/mne/fiff/evoked.py +++ b/mne/fiff/evoked.py @@ -218,9 +218,6 @@ class Evoked(object): print 'No projector specified for these data' self.proj = None else: - # Activate the projection items - info['projs'] = activate_proj(info['projs'], copy=False) - # Create the projector proj, nproj = make_projector_info(info) if nproj == 0: @@ -231,6 +228,9 @@ class Evoked(object): % nproj) self.proj = proj + # The projection items have been activated + info['projs'] = activate_proj(info['projs'], copy=False) + if self.proj is not None: print "SSP projectors applied..." all_data = np.dot(self.proj, all_data) diff --git a/mne/fiff/proj.py b/mne/fiff/proj.py index 0b0ca9c..2cc10de 100644 --- a/mne/fiff/proj.py +++ b/mne/fiff/proj.py @@ -195,7 +195,7 @@ def write_proj(fid, projs): ############################################################################### # Utils -def make_projector(projs, ch_names, bads=[]): +def make_projector(projs, ch_names, bads=[], idle_only=False): """Create an SSP operator from SSP projection vectors Parameters @@ -206,6 +206,9 @@ def make_projector(projs, ch_names, bads=[]): List of channels to include in the projection matrix bads : list of strings Some bad channels to exclude + idle_only : bool + Only include projectors that are currently idle. By default all + projectors are included. Returns ------- @@ -228,14 +231,13 @@ def make_projector(projs, ch_names, bads=[]): if projs is None: return proj, nproj, U - nactive = 0 nvec = 0 for p in projs: - if p['active']: - nactive += 1 + if (not p['active'] and idle_only) or not idle_only: + nproj += 1 nvec += p['data']['nrow'] - if nactive == 0: + if nproj == 0: return proj, nproj, U # Pick the appropriate entries @@ -243,7 +245,7 @@ def make_projector(projs, ch_names, bads=[]): nvec = 0 nonzero = 0 for k, p in enumerate(projs): - if p['active']: + if (not p['active'] and idle_only) or not idle_only: if len(p['data']['col_names']) != \ len(np.unique(p['data']['col_names'])): raise ValueError('Channel name list in projection item %d' @@ -289,7 +291,7 @@ def make_projector(projs, ch_names, bads=[]): return proj, nproj, U -def make_projector_info(info): +def make_projector_info(info, idle_only=False): """Make an SSP operator using the measurement info Calls make_projector on good channels. @@ -298,6 +300,9 @@ def make_projector_info(info): ---------- info : dict Measurement info + idle_only : bool + Only include projectors that are currently idle. By default all + projectors are included. Returns ------- @@ -307,7 +312,7 @@ def make_projector_info(info): How many items in the projector """ proj, nproj, _ = make_projector(info['projs'], info['ch_names'], - info['bads']) + info['bads'], idle_only) return proj, nproj diff --git a/mne/fiff/raw.py b/mne/fiff/raw.py index 7be18ca..4b73eb3 100644 --- a/mne/fiff/raw.py +++ b/mne/fiff/raw.py @@ -17,7 +17,6 @@ from .meas_info import read_meas_info, write_meas_info from .tree import dir_tree_find from .tag import read_tag from .pick import pick_types -from .proj import activate_proj from ..filter import low_pass_filter, high_pass_filter, band_pass_filter from ..parallel import parallel_func @@ -536,7 +535,7 @@ class Raw(object): self.filter(None, freq, picks, n_jobs=n_jobs, verbose=verbose, filter_length=filter_length) - def add_proj(self, projs, activate=True, remove_existing=False): + def add_proj(self, projs, remove_existing=False): """Add SSP projection vectors Parameters @@ -544,16 +543,10 @@ class Raw(object): projs : list List with projection vectors - activate : bool - Activate the projection vectors being added - remove_existing : bool Remove the projection vectors currently in the file """ - if activate: - projs = activate_proj(projs, copy=True) - else: - projs = copy.deepcopy(projs) + projs = copy.deepcopy(projs) if remove_existing: self.info['projs'] = projs -- 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
