Compare commits

...

10 Commits

Author SHA1 Message Date
Alexandre Gramfort b61b87d017 bump version to 0.13.1 2016-11-21 08:49:17 +01:00
Christian Brodbeck 8f87050533 FIX KIT reader in Maint/0.13 (#3777)
* FIX:  KIT reference channels (#3721)

* FIX:  KIT (system 52) channel ID 0 are reference channels

* FIX RawKIT:  stim=list with stim_code='channel' (#3737)

Need to coerce list to array
2016-11-19 09:13:39 +01:00
Eric Larson cb8707f43e FIX: Bump tempita (#3766)
* FIX: Bump tempita version
2016-11-18 09:12:50 +01:00
Alexandre Gramfort bdbbb84a46 misc to rebuild doc 2016-11-13 20:37:22 +01:00
jaeilepp 0d42601eb8 Fixed a test to work with old numpy. 2016-10-12 09:49:25 +02:00
jaeilepp 028f2eec28 Fixes to circle and examples. 2016-10-11 11:15:04 +02:00
jaeilepp b4525bb67d Added misc channels to evoked.plot. 2016-10-10 07:41:47 +02:00
jaeilepp bdecd41932 Fix example. 2016-10-07 09:05:07 +02:00
Eric Larson 8cd0835b62 FIX: Fix sklearn 2016-10-03 14:44:28 +09:00
Alexandre Gramfort 2322a2bff5 update circle for 0.13 2016-09-28 10:20:37 +02:00
19 changed files with 1261 additions and 1370 deletions
+5 -1
View File
@@ -80,6 +80,10 @@ dependencies:
if [[ $(cat $FNAME | grep -x ".*brainstorm.*bst_phantom_elekta.*" | wc -l) -gt 0 ]]; then
python -c "import mne; print(mne.datasets.brainstorm.bst_phantom_elekta.data_path())" --accept-brainstorm-license;
fi;
if [[ $(cat $FNAME | grep -x ".*datasets.*megsim.*" | wc -l) -gt 0 ]]; then
python -c "import mne; print(mne.datasets.megsim.load_data(condition='visual', data_format='single-trial', data_type='simulation', update_path=True))";
python -c "import mne; print(mne.datasets.megsim.load_data(condition='visual', data_format='raw', data_type='experimental', update_path=True))";
fi;
fi;
done;
echo PATTERN="$PATTERN";
@@ -128,7 +132,7 @@ deployment:
- cd doc/_build/html && cp -rf * ~/mne-tools.github.io/dev
- cd ../mne-tools.github.io && git add -A && git commit -m 'Automated update of dev docs.' && git push origin master
stable:
branch: maint/0.12
branch: maint/0.13
commands:
- git config --global user.email "circle@mne.com"
- git config --global user.name "Circle Ci"
@@ -15,7 +15,7 @@ Gilliam K, Donahue CH, Montano R, Bryant JE, Scott A, Stephen JM
Realistic Simulated and Empirical Data. Neuroinformatics 10:141-158
"""
from mne import read_evokeds
from mne import read_evokeds, combine_evoked
from mne.datasets.megsim import load_data
print(__doc__)
@@ -30,7 +30,7 @@ epochs_fnames = load_data(condition=condition, data_format='single-trial',
epochs_fnames = [f for f in epochs_fnames if 'sim6_trial_' in f][:10]
evokeds = [read_evokeds(f)[0] for f in epochs_fnames]
mean_evoked = sum(evokeds[1:], evokeds[0])
mean_evoked = combine_evoked(evokeds, weights='nave')
# Visualize the average
mean_evoked.plot()
+4 -5
View File
@@ -25,7 +25,7 @@ import matplotlib.pyplot as plt
import mne
from mne.datasets import spm_face
from mne.preprocessing import ICA, create_eog_epochs
from mne import io
from mne import io, combine_evoked
from mne.minimum_norm import make_inverse_operator, apply_inverse
print(__doc__)
@@ -74,7 +74,7 @@ ica.apply(epochs) # clean data, default in place
evoked = [epochs[k].average() for k in event_ids]
contrast = evoked[1] - evoked[0]
contrast = combine_evoked(evoked, weights=[-1, 1]) # Faces - scrambled
evoked.append(contrast)
@@ -128,7 +128,6 @@ stc = apply_inverse(contrast, inverse_operator, lambda2, method, pick_ori=None)
# stc.save('spm_%s_dSPM_inverse' % constrast.comment)
# Plot contrast in 3D with PySurfer if available
brain = stc.plot(hemi='both', subjects_dir=subjects_dir)
brain.set_time(170.0) # milliseconds
brain.show_view('ventral')
brain = stc.plot(hemi='both', subjects_dir=subjects_dir, initial_time=0.170,
views=['ven'])
# brain.save_image('dSPM_map.png')
@@ -148,5 +148,5 @@ stc_feat = mne.SourceEstimate(feature_weights, vertices=vertices,
tmin=stc.tmin, tstep=stc.tstep,
subject='sample')
brain = stc_feat.plot(hemi='split', views=['lat', 'med'], transparent=True,
brain = stc_feat.plot(views=['lat'], transparent=True,
initial_time=0.1, time_unit='s')
@@ -35,6 +35,7 @@ raw = mne.io.read_raw_fif(fname_raw)
inverse_operator = read_inverse_operator(fname_inv)
label = mne.read_label(fname_label)
raw.set_eeg_reference() # set average reference.
start, stop = raw.time_as_index([0, 15]) # read the first 15s of data
# Compute inverse solution
+1 -1
View File
@@ -74,7 +74,7 @@ with FieldTripClient(host='localhost', port=1972,
if ii == 0:
evoked = ev
else:
evoked += ev
evoked = mne.combine_evoked([evoked, ev], weights='nave')
ax[0].cla()
ax[1].cla() # clear axis
+1 -1
View File
@@ -55,7 +55,7 @@ for ii, ev in enumerate(rt_epochs.iter_evoked()):
if ii == 0:
evoked = ev
else:
evoked += ev
evoked = mne.combine_evoked([evoked, ev], weights='nave')
plt.clf() # clear canvas
evoked.plot(axes=plt.gca()) # plot on current figure
plt.pause(0.05)
+1 -1
View File
@@ -17,7 +17,7 @@
# Dev branch marker is: 'X.Y.devN' where N is an integer.
#
__version__ = '0.13'
__version__ = '0.13.1'
# have to import verbose first since it's needed by many things
from .utils import (set_log_level, set_log_file, verbose, set_config,
+1 -1
View File
@@ -79,7 +79,7 @@ def test_ems():
assert_equal(ems.__repr__(), '<EMS: not fitted.>')
# manual leave-one-out to avoid sklearn version problem
for test in range(len(y)):
train = np.setdiff1d(range(len(y)), test)
train = np.setdiff1d(range(len(y)), np.atleast_1d(test))
ems.fit(X[train], y[train])
coefs.append(ems.filters_)
Xt.append(ems.transform(X[[test]]))
+3 -3
View File
@@ -60,13 +60,13 @@ def test_generalization_across_time():
y_4classes = np.hstack((epochs.events[:7, 2], epochs.events[7:, 2] + 1))
if check_version('sklearn', '0.18'):
from sklearn.model_selection import (KFold, StratifiedKFold,
ShuffleSplit, LeaveOneLabelOut)
ShuffleSplit, LeaveOneGroupOut)
cv_shuffle = ShuffleSplit()
cv = LeaveOneLabelOut()
cv = LeaveOneGroupOut()
# XXX we cannot pass any other parameters than X and y to cv.split
# so we have to build it before hand
cv_lolo = [(train, test) for train, test in cv.split(
X=y_4classes, y=y_4classes, labels=y_4classes)]
y_4classes, y_4classes, y_4classes)]
# With sklearn >= 0.17, `clf` can be identified as a regressor, and
# the scoring metrics can therefore be automatically assigned.
+3 -1302
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -7,9 +7,9 @@ These can be awkward to manage in a normal Python loop, but using the
looper you can get a better sense of the context. Use like::
>>> for loop, item in looper(['a', 'b', 'c']):
... print("%d %s" % (loop.number, item))
... print loop.number, item
... if not loop.last:
... print('---')
... print '---'
1 a
---
2 b
+1182
View File
File diff suppressed because it is too large Load Diff
+11 -9
View File
@@ -1,12 +1,11 @@
import sys
__all__ = ['PY3', 'b', 'basestring_', 'bytes', 'next', 'is_unicode']
__all__ = ['b', 'basestring_', 'bytes', 'unicode_', 'next', 'is_unicode']
PY3 = True if sys.version_info[0] == 3 else False
if sys.version_info[0] < 3:
if sys.version < "3":
b = bytes = str
basestring_ = basestring
unicode_ = unicode
else:
def b(s):
@@ -15,26 +14,29 @@ else:
return bytes(s)
basestring_ = (bytes, str)
bytes = bytes
unicode_ = str
text = str
if sys.version_info[0] < 3:
if sys.version < "3":
def next(obj):
return obj.next()
else:
next = next
if sys.version < "3":
def is_unicode(obj):
if sys.version_info[0] < 3:
def is_unicode(obj):
return isinstance(obj, unicode)
else:
else:
def is_unicode(obj):
return isinstance(obj, str)
def coerce_text(v):
if not isinstance(v, basestring_):
if sys.version_info[0] < 3:
if sys.version < "3":
attr = '__unicode__'
else:
attr = '__str__'
+34 -37
View File
@@ -187,11 +187,13 @@ class RawKIT(_BaseRaw):
else:
raise ValueError("stim needs to be list of int, '>' or "
"'<', not %r" % str(stim))
elif np.max(stim) >= self._raw_extras[0]['nchan']:
raise ValueError('Tried to set stim channel %i, but sqd file '
'only has %i channels'
% (np.max(stim),
self._raw_extras[0]['nchan']))
else:
stim = np.asarray(stim, int)
if stim.max() >= self._raw_extras[0]['nchan']:
raise ValueError(
'Got stim=%s, but sqd file only has %i channels' %
(stim, self._raw_extras[0]['nchan']))
# modify info
nchan = self._raw_extras[0]['nchan'] + 1
ch_name = 'STI 014'
@@ -603,11 +605,15 @@ def get_kit_info(rawfile):
# planargradiometer
# x,y,z,theta,phi,btheta,bphi,baseline,coilsize
sensors.append(np.fromfile(fid, dtype='d', count=9))
elif sens_type == 257:
elif sens_type in (257, 0):
# reference channels
sensors.append(np.zeros(7))
sqd['i'] = sens_type
else:
raise IOError("Unknown KIT channel type: %i" % sens_type)
sqd['sensor_locs'] = np.array(sensors)
if len(sqd['sensor_locs']) != KIT_SYS.N_SENS:
raise IOError("An error occurred while reading %s" % rawfile)
# amplifier gain
fid.seek(KIT_SYS.AMPLIFIER_INFO)
@@ -678,27 +684,19 @@ def get_kit_info(rawfile):
# Creates a list of dicts of meg channels for raw.info
logger.info('Setting channel info structure...')
ch_names = {}
ch_names['MEG'] = ['MEG %03d' % ch for ch
in range(1, sqd['n_sens'] + 1)]
ch_names['MISC'] = ['MISC %03d' % ch for ch
in range(1, sqd['nmiscchan'] + 1)]
locs = sqd['sensor_locs']
chan_locs = apply_trans(als_ras_trans, locs[:, :3])
chan_angles = locs[:, 3:]
info['chs'] = []
for idx, ch_info in enumerate(zip(ch_names['MEG'], chan_locs,
chan_angles), 1):
ch_name, ch_loc, ch_angles = ch_info
chan_info = {}
chan_info['cal'] = KIT.CALIB_FACTOR
chan_info['logno'] = idx
chan_info['scanno'] = idx
chan_info['range'] = KIT.RANGE
chan_info['unit_mul'] = KIT.UNIT_MUL
chan_info['ch_name'] = ch_name
chan_info['unit'] = FIFF.FIFF_UNIT_T
chan_info['coord_frame'] = FIFF.FIFFV_COORD_DEVICE
for idx, (ch_loc, ch_angles) in enumerate(zip(chan_locs, chan_angles),
1):
chan_info = {'cal': KIT.CALIB_FACTOR,
'logno': idx,
'scanno': idx,
'range': KIT.RANGE,
'unit_mul': KIT.UNIT_MUL,
'ch_name': 'MEG %03d' % idx,
'unit': FIFF.FIFF_UNIT_T,
'coord_frame': FIFF.FIFFV_COORD_DEVICE}
if idx <= sqd['nmegchan']:
chan_info['coil_type'] = FIFF.FIFFV_COIL_KIT_GRAD
chan_info['kind'] = FIFF.FIFFV_MEG_CH
@@ -736,19 +734,18 @@ def get_kit_info(rawfile):
info['chs'].append(chan_info)
# label trigger and misc channels
for idy, ch_name in enumerate(ch_names['MISC'],
sqd['n_sens'] + 1):
chan_info = {}
chan_info['cal'] = KIT.CALIB_FACTOR
chan_info['logno'] = idy
chan_info['scanno'] = idy
chan_info['range'] = 1.0
chan_info['unit'] = FIFF.FIFF_UNIT_V
chan_info['unit_mul'] = 0
chan_info['ch_name'] = ch_name
chan_info['coil_type'] = FIFF.FIFFV_COIL_NONE
chan_info['loc'] = np.zeros(12)
chan_info['kind'] = FIFF.FIFFV_MISC_CH
for idx in range(1, sqd['nmiscchan'] + 1):
ch_idx = idx + KIT_SYS.N_SENS
chan_info = {'cal': KIT.CALIB_FACTOR,
'logno': ch_idx,
'scanno': ch_idx,
'range': 1.0,
'unit': FIFF.FIFF_UNIT_V,
'unit_mul': 0,
'ch_name': 'MISC %03d' % idx,
'coil_type': FIFF.FIFFV_COIL_NONE,
'loc': np.zeros(12),
'kind': FIFF.FIFFV_MISC_CH}
info['chs'].append(chan_info)
info._update_redundant()
return info, sqd
+5
View File
@@ -131,6 +131,11 @@ def test_raw_events():
assert_array_equal(find_events(raw, output='step', consecutive=True),
evts(0, 160, 0, 160, 0))
raw = read_raw_kit(sqd_path, stim=range(160, 162), slope='+',
stim_code='channel')
assert_array_equal(find_events(raw, output='step', consecutive=True),
evts(0, 160, 0, 160, 0))
def test_ch_loc():
"""Test raw kit loc."""
+2 -1
View File
@@ -200,7 +200,8 @@ def _plot_evoked(evoked, picks, exclude, unit, show,
units = _handle_default('units', units)
# Valid data types ordered for consistency
valid_channel_types = ['eeg', 'grad', 'mag', 'seeg', 'eog', 'ecg', 'emg',
'dipole', 'gof', 'bio', 'ecog', 'hbo', 'hbr']
'dipole', 'gof', 'bio', 'ecog', 'hbo', 'hbr',
'misc']
if picks is None:
picks = list(range(info['nchan']))
+2 -2
View File
@@ -19,7 +19,7 @@ doc-files = doc
# cover-html = 1
# cover-html-dir = coverage
cover-package = mne
ignore-files = (?:^\.|^_,|^conf\.py$)
ignore-files = (?:^\.|^_,|^conf\.py|_tempita\.py|^_looper\.py$)
detailed-errors = 1
with-doctest = 1
@@ -30,4 +30,4 @@ doctest-fixtures = _fixture
[flake8]
exclude = __init__.py,*externals*,constants.py,fixes.py
ignore = E241
ignore = E241,E305
-1
View File
@@ -1,5 +1,4 @@
#! /usr/bin/env python
#
# Copyright (C) 2011-2014 Alexandre Gramfort
# <alexandre.gramfort@telecom-paristech.fr>