Skip to content
Merged
13 changes: 13 additions & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extraction:
python:
index:
filters:
- exclude: "mne/externals/*.py"
- exclude: "mne/externals/*/*.py"
javascript:
index:
filters:
- exclude: "**/*.js"
queries:
- exclude: py/missing-equals
- exclude: py/import-and-import-from
1 change: 1 addition & 0 deletions examples/visualization/plot_evoked_topomap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
========================================
Plotting topographic maps of evoked data
Expand Down
1 change: 0 additions & 1 deletion logo/generate_mne_logos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from matplotlib.text import TextPath
from matplotlib.patches import PathPatch
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.transforms import Bbox

# manually set values
dpi = 72.
Expand Down
4 changes: 1 addition & 3 deletions mne/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import re
from copy import deepcopy
from itertools import takewhile
from collections import OrderedDict
import collections

import numpy as np
Expand Down Expand Up @@ -223,7 +222,7 @@ def __getitem__(self, key):
out_keys = ('onset', 'duration', 'description', 'orig_time')
out_vals = (self.onset[key], self.duration[key],
self.description[key], self.orig_time)
return OrderedDict(zip(out_keys, out_vals))
return collections.OrderedDict(zip(out_keys, out_vals))
else:
key = list(key) if isinstance(key, tuple) else key
return Annotations(onset=self.onset[key],
Expand Down Expand Up @@ -673,7 +672,6 @@ def get_duration_from_times(t):


def _is_iso8601(candidate_str):
import re
ISO8601 = r'^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}\.\d{6}$'
return re.compile(ISO8601).match(candidate_str) is not None

Expand Down
2 changes: 0 additions & 2 deletions mne/beamformer/_dics.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,6 @@ def tf_dics(epochs, forward, noise_csds, tmin, tmax, tstep, win_lengths,
'window %d to %d ms, in frequency range %d to %d Hz' %
(win_tmin * 1e3, win_tmax * 1e3, fmin, fmax)
)
win_tmin = win_tmin
win_tmax = win_tmax

# Calculating data CSD in current time window
if mode == 'fourier':
Expand Down
1 change: 0 additions & 1 deletion mne/bem.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ def _surfaces_to_bem(surfs, ids, sigmas, ico=None, rescale=True,
len(sigmas)):
raise ValueError('surfs, ids, and sigmas must all have the same '
'number of elements (1 or 3)')
surf = list(surfs)
for si, surf in enumerate(surfs):
if isinstance(surf, str):
surfs[si] = read_surface(surf, return_dict=True)[-1]
Expand Down
25 changes: 13 additions & 12 deletions mne/coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from functools import reduce

import numpy as np
from numpy import dot

from .io import read_fiducials, write_fiducials, read_info
from .io.constants import FIFF
Expand Down Expand Up @@ -288,7 +287,7 @@ def _trans_from_params(param_info, params):
x, y, z = params[i:i + 3]
trans.append(scaling(x, y, z))

trans = reduce(dot, trans)
trans = reduce(np.dot, trans)
return trans


Expand Down Expand Up @@ -362,7 +361,7 @@ def fit_matched_points(src_pts, tgt_pts, rotate=True, translate=True,
def error(x):
rx, ry, rz = x
trans = rotation3d(rx, ry, rz)
est = dot(src_pts, trans.T)
est = np.dot(src_pts, trans.T)
d = tgt_pts - est
if weights is not None:
d *= weights
Expand All @@ -372,8 +371,8 @@ def error(x):
elif param_info == (True, True, 0):
def error(x):
rx, ry, rz, tx, ty, tz = x
trans = dot(translation(tx, ty, tz), rotation(rx, ry, rz))
est = dot(src_pts, trans.T)[:, :3]
trans = np.dot(translation(tx, ty, tz), rotation(rx, ry, rz))
est = np.dot(src_pts, trans.T)[:, :3]
d = tgt_pts - est
if weights is not None:
d *= weights
Expand All @@ -383,9 +382,10 @@ def error(x):
elif param_info == (True, True, 1):
def error(x):
rx, ry, rz, tx, ty, tz, s = x
trans = reduce(dot, (translation(tx, ty, tz), rotation(rx, ry, rz),
scaling(s, s, s)))
est = dot(src_pts, trans.T)[:, :3]
trans = reduce(np.dot, (translation(tx, ty, tz),
rotation(rx, ry, rz),
scaling(s, s, s)))
est = np.dot(src_pts, trans.T)[:, :3]
d = tgt_pts - est
if weights is not None:
d *= weights
Expand All @@ -395,9 +395,10 @@ def error(x):
elif param_info == (True, True, 3):
def error(x):
rx, ry, rz, tx, ty, tz, sx, sy, sz = x
trans = reduce(dot, (translation(tx, ty, tz), rotation(rx, ry, rz),
scaling(sx, sy, sz)))
est = dot(src_pts, trans.T)[:, :3]
trans = reduce(np.dot, (translation(tx, ty, tz),
rotation(rx, ry, rz),
scaling(sx, sy, sz)))
est = np.dot(src_pts, trans.T)[:, :3]
d = tgt_pts - est
if weights is not None:
d *= weights
Expand All @@ -419,7 +420,7 @@ def error(x):
if tol is not None:
if not translate:
src_pts = np.hstack((src_pts, np.ones((len(src_pts), 1))))
est_pts = dot(src_pts, trans.T)[:, :3]
est_pts = np.dot(src_pts, trans.T)[:, :3]
err = np.sqrt(np.sum((est_pts - tgt_pts) ** 2, axis=1))
if np.any(err > tol):
raise RuntimeError("Error exceeds tolerance. Error = %r" % err)
Expand Down
3 changes: 0 additions & 3 deletions mne/cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,9 +1095,6 @@ def _compute_covariance_auto(data, method, info, method_params, cv,
name = method_.__name__ if callable(method_) else method_
out[name] = dict(loglik=loglik, data=cov, estimator=estimator)
out[name].update(runtime_info)
# undo scaling
if eigvec is not None:
data = np.dot(data, eigvec)

return out

Expand Down
2 changes: 1 addition & 1 deletion mne/datasets/hf_sef/hf_sef.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ def data_path(dataset='evoked', path=None, force_update=False,

os.remove(archive)

path = _do_path_update(path, update_path, key, name)
_do_path_update(path, update_path, key, name)
return destdir
2 changes: 1 addition & 1 deletion mne/datasets/megsim/megsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def data_path(url, path=None, force_update=False, update_path=None,
z.close()
destinations = [op.join(decomp_dir, f) for f in files]

path = _do_path_update(path, update_path, key, name)
_do_path_update(path, update_path, key, name)
return destinations


Expand Down
5 changes: 3 additions & 2 deletions mne/datasets/sleep_physionet/_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Joan Massich <mailsik@gmail.com>
#
# License: BSD Style.

import os
from os import path as op
import os.path as op
import numpy as np

from ...utils import _fetch_file, verbose, _TempDir, _check_pandas_installed
Expand Down Expand Up @@ -108,7 +109,7 @@ def _update_sleep_temazepam_records(fname=TEMAZEPAM_SLEEP_RECORDS):
data.columns.names = [None, None]
data = (data.set_index([('Subject - age - sex', 'Age'),
('Subject - age - sex', 'M1/F2')], append=True)
.stack(level=0).reset_index())
.stack(level=0).reset_index())

data = data.rename(columns={('Subject - age - sex', 'Age'): 'age',
('Subject - age - sex', 'M1/F2'): 'sex',
Expand Down
1 change: 1 addition & 0 deletions mne/datasets/sleep_physionet/age.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Joan Massich <mailsik@gmail.com>
#
Expand Down
1 change: 1 addition & 0 deletions mne/datasets/sleep_physionet/temazepam.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Joan Massich <mailsik@gmail.com>
#
Expand Down
12 changes: 9 additions & 3 deletions mne/decoding/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ def fit_transform(self, X, y=None, **fit_params):
class EstimatorMixin(object):
"""Mixin class for estimators."""

def get_params(self):
"""Get the estimator params."""
pass
def get_params(self, deep=True):
"""Get the estimator params.

Parameters
----------
deep : bool
Deep.
"""
return

def set_params(self, **params):
"""Set parameters (mimics sklearn API)."""
Expand Down
7 changes: 4 additions & 3 deletions mne/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,10 @@ def iter_evoked(self):
self._current = 0

while True:
out = self.next(True)
if out is None:
return # properly signal the end of iteration
try:
out = self.__next__(True)
except StopIteration:
break
data, event_id = out
tmin = self.times[0]
info = deepcopy(self.info)
Expand Down
6 changes: 3 additions & 3 deletions mne/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
str(FIFF.FIFFV_ASPECT_STD_ERR): 'standard_error'}


class Evoked(ProjMixin, ContainsMixin, UpdateChannelsMixin,
SetChannelsMixin, InterpolationMixin, FilterMixin,
ToDataFrameMixin, TimeMixin, SizeMixin):
class Evoked(ProjMixin, ContainsMixin, UpdateChannelsMixin, SetChannelsMixin,
InterpolationMixin, FilterMixin, ToDataFrameMixin, TimeMixin,
SizeMixin):
"""Evoked data.

Parameters
Expand Down
6 changes: 1 addition & 5 deletions mne/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,6 @@ class BaseEstimator(object):
@classmethod
def _get_param_names(cls):
"""Get parameter names for the estimator"""
try:
from inspect import signature
except ImportError:
from .externals.funcsigs import signature
# fetch the constructor or the original constructor before
# deprecation wrapping if any
init = getattr(cls.__init__, 'deprecated_original', cls.__init__)
Expand All @@ -651,7 +647,7 @@ def _get_param_names(cls):

# introspect the constructor arguments to find the model parameters
# to represent
init_signature = signature(init)
init_signature = inspect.signature(init)
# Consider the constructor parameters excluding 'self'
parameters = [p for p in init_signature.parameters.values()
if p.name != 'self' and p.kind != p.VAR_KEYWORD]
Expand Down
13 changes: 6 additions & 7 deletions mne/forward/_lead_dots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# License: BSD (3-clause)

import os
from os import path as op
import os.path as op

import numpy as np
from numpy.polynomial import legendre
Expand All @@ -21,12 +21,11 @@
def _next_legen_der(n, x, p0, p01, p0d, p0dd):
"""Compute the next Legendre polynomial and its derivatives."""
# only good for n > 1 !
help_ = p0
helpd = p0d
p0 = ((2 * n - 1) * x * help_ - (n - 1) * p01) / n
p0d = n * help_ + x * helpd
p0dd = (n + 1) * helpd + x * p0dd
p01 = help_
old_p0 = p0
old_p0d = p0d
p0 = ((2 * n - 1) * x * old_p0 - (n - 1) * p01) / n
p0d = n * old_p0 + x * old_p0d
p0dd = (n + 1) * old_p0d + x * p0dd
return p0, p0d, p0dd


Expand Down
2 changes: 1 addition & 1 deletion mne/forward/_make_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from copy import deepcopy
import contextlib
import os
from os import path as op
import os.path as op

import numpy as np

Expand Down
28 changes: 9 additions & 19 deletions mne/gui/_coreg_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,37 +391,27 @@ def _get_head_mri_t(self):

@cached_property
def _get_processed_high_res_mri_points(self):
if self.grow_hair:
if len(self.mri.bem_high_res.surf.nn):
scaled_hair_dist = (1e-3 * self.grow_hair /
np.array(self.parameters[6:9]))
points = self.mri.bem_high_res.surf.rr.copy()
hair = points[:, 2] > points[:, 1]
points[hair] += (self.mri.bem_high_res.surf.nn[hair] *
scaled_hair_dist)
return points
else:
error(None, "Norms missing from bem, can't grow hair")
self.grow_hair = 0
else:
return self.mri.bem_high_res.surf.rr
return self._get_processed_mri_points('high')

@cached_property
def _get_processed_low_res_mri_points(self):
return self._get_processed_mri_points('low')

def _get_processed_mri_points(self, res):
bem = self.mri.bem_low_res if res == 'low' else self.mri.bem_high_res
if self.grow_hair:
if len(self.mri.bem_low_res.surf.nn):
if len(bem.surf.nn):
scaled_hair_dist = (1e-3 * self.grow_hair /
np.array(self.parameters[6:9]))
points = self.mri.bem_low_res.surf.rr.copy()
points = bem.surf.rr.copy()
hair = points[:, 2] > points[:, 1]
points[hair] += (self.mri.bem_low_res.surf.nn[hair] *
scaled_hair_dist)
points[hair] += bem.surf.nn[hair] * scaled_hair_dist
return points
else:
error(None, "Norms missing from bem, can't grow hair")
self.grow_hair = 0
else:
return self.mri.bem_low_res.surf.rr
return bem.surf.rr

@cached_property
def _get_mri_trans(self):
Expand Down
2 changes: 1 addition & 1 deletion mne/gui/_fiducials_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def round_(x):
elif i in idxs:
line += " (<- also MRI mesh)"
msg.append(line)
logger.debug(os.linesep.join(msg))
logger.debug('\n'.join(msg))

if self.set == 'Nasion':
self.nasion = pt
Expand Down
3 changes: 1 addition & 2 deletions mne/inverse_sparse/mxne_optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ def _mixed_norm_solver_cd(M, G, alpha, lipschitz_constant, maxit=10000,
"""Solve L21 inverse problem with coordinate descent."""
from sklearn.linear_model.coordinate_descent import MultiTaskLasso

n_sensors, n_times = M.shape
n_sensors, n_sources = G.shape
assert M.ndim == G.ndim and M.shape[0] == G.shape[0]

clf = MultiTaskLasso(alpha=alpha / len(M), tol=tol / sum_squared(M),
normalize=False, fit_intercept=False, max_iter=maxit,
Expand Down
Loading