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 839aa4959457505d61bb20a82e33101a88274688 Author: Alexandre Gramfort <[email protected]> Date: Thu Jan 27 11:00:58 2011 -0500 adding preprocessing.py (WIP) --- mne/fiff/__init__.py | 2 +- mne/{ => fiff}/compensator.py | 0 mne/preprocessing.py | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/mne/fiff/__init__.py b/mne/fiff/__init__.py index dffac30..e490312 100644 --- a/mne/fiff/__init__.py +++ b/mne/fiff/__init__.py @@ -11,5 +11,5 @@ from .evoked import read_evoked, write_evoked from .raw import setup_read_raw, read_raw_segment, read_raw_segment_times, \ start_writing_raw, write_raw_buffer, finish_writing_raw from .pick import pick_types -from .meas_info import get_current_comp +from .compensator import get_current_comp diff --git a/mne/compensator.py b/mne/fiff/compensator.py similarity index 100% rename from mne/compensator.py rename to mne/fiff/compensator.py diff --git a/mne/preprocessing.py b/mne/preprocessing.py new file mode 100644 index 0000000..0472571 --- /dev/null +++ b/mne/preprocessing.py @@ -0,0 +1,57 @@ +import numpy as np + +from .proj import make_projector_info +from .fiff.compensator import get_current_comp, compensate_to, make_compensator + + +def cancel_noise(data, dest_comp=0): + """Do projection and compensation as needed + + Return the appropriate operators + + [res,proj,comp] = mne_ex_cancel_noise(data,dest_comp) + + res - Data after noise cancellation + proj - The projection operator applied + comp - The compensator which brings uncompensated data to the + desired compensation grade (will be useful in forward + calculations) + + """ + # + # Compensate the data and make a compensator for forward modelling + # + comp = [] + proj = [] + comp_now = get_current_comp(data['info']) + if comp_now == dest_comp: + res = data + else: + res = compensate_to(data, dest_comp) + print 'The data are now compensated to grade %d.' % dest_comp + + if dest_comp > 0: + comp = make_compensator(res['info'], 0, dest_comp) + print 'Appropriate forward operator compensator created.' + else: + print 'No forward operator compensator needed.' + + # Do the projection + if data['info']['projs'] is None: + print 'No projector included with these data.' + else: + # Activate the projection items + for k in range(len(res['info']['projs'])): + res['info']['projs'][k]['active'] = True; + + # Create the projector + proj, nproj = make_projector_info(res['info']) + if nproj == 0: + print 'The projection vectors do not apply to these channels' + proj = [] + else: + print 'Created an SSP operator (subspace dimension = %d)' % nproj + res['evoked']['epochs'] = np.dot(proj, res['evoked']['epochs']) + print 'Projector applied to the data' + + return res, proj, comp -- 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
