Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions doc/examples/resting_state_fmri.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#Import from other libraries:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.mlab import csv2rec

import nitime
#Import the time-series objects:
Expand All @@ -49,14 +48,12 @@

"""

We use csv2rec to read the data in from file to a recarray:
We use Numpy to read the data in from file to a recarray:

"""

data_path = os.path.join(nitime.__path__[0], 'data')

data_rec = csv2rec(os.path.join(data_path, 'fmri_timeseries.csv'))

data_rec = np.genfromtxt(os.path.join(data_path, 'fmri_timeseries.csv'),
names=True, delimiter=',')

Expand Down
2 changes: 1 addition & 1 deletion nitime/algorithms/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ def cache_fft(time_series, ij, lb=0, ub=None,

n_freqs = ub_idx - lb_idx
# Make the window:
if mlab.cbook.iterable(window):
if np.iterable(window):
assert(len(window) == NFFT)
window_vals = window
else:
Expand Down
6 changes: 3 additions & 3 deletions nitime/algorithms/event_related.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def fir(timeseries, design):
and Unbiased Approach. Human Brain Mapping, 11:249-260

"""
X = np.matrix(design)
y = np.matrix(timeseries)
h = np.array(linalg.pinv(X.T * X) * X.T * y.T)
X = np.array(design)
y = np.array(timeseries)
h = np.array(linalg.pinv(X.T @ X) @ X.T @ y.T)
return h


Expand Down
6 changes: 3 additions & 3 deletions nitime/algorithms/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_spectra(time_series, method=None):
Fs = method.get('Fs', 2 * np.pi)
detrend = method.get('detrend', mlab.detrend_none)
window = method.get('window', mlab.window_hanning)
n_overlap = method.get('n_overlap', int(np.ceil(NFFT / 2)))
n_overlap = method.get('n_overlap', int(np.ceil(NFFT // 2)))

# The length of the spectrum depends on how many sides are taken, which
# depends on whether or not this is a complex object:
Expand Down Expand Up @@ -587,7 +587,7 @@ def multi_taper_psd(
sdf_est /= Fs

if sides == 'onesided':
freqs = np.linspace(0, Fs / 2, NFFT / 2 + 1)
freqs = np.linspace(0, Fs / 2, NFFT // 2 + 1)
else:
freqs = np.linspace(0, Fs, NFFT, endpoint=False)

Expand Down Expand Up @@ -726,7 +726,7 @@ def multi_taper_csd(s, Fs=2 * np.pi, NW=None, BW=None, low_bias=True,
csdfs /= Fs

if sides == 'onesided':
freqs = np.linspace(0, Fs / 2, NFFT / 2 + 1)
freqs = np.linspace(0, Fs / 2, NFFT // 2 + 1)
else:
freqs = np.linspace(0, Fs, NFFT, endpoint=False)

Expand Down
2 changes: 0 additions & 2 deletions nitime/algorithms/tests/test_autoregressive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import numpy.testing as npt
import numpy.testing.decorators as dec

import nitime.algorithms as tsa
import nitime.utils as utils
Expand Down Expand Up @@ -87,7 +86,6 @@ def test_AR_LD():
npt.assert_almost_equal(avg_pwr, avg_pwr_est, decimal=0)


@dec.slow
def test_MAR_est_LWR():
"""

Expand Down
2 changes: 0 additions & 2 deletions nitime/algorithms/tests/test_spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import scipy
from scipy import fftpack
import numpy.testing as npt
import numpy.testing.decorators as dec
import pytest

import nitime.algorithms as tsa
Expand Down Expand Up @@ -320,7 +319,6 @@ def test_mtm_cross_spectrum():
tsa.mtm_cross_spectrum(tspectra, np.r_[tspectra, tspectra], (w, w))


@dec.slow
def test_multi_taper_psd_csd():
"""

Expand Down
4 changes: 2 additions & 2 deletions nitime/analysis/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from inspect import getargspec
from inspect import getfullargspec

from nitime import descriptors as desc

Expand All @@ -16,7 +16,7 @@ class BaseAnalyzer(desc.ResetMixin):

@desc.setattr_on_read
def parameterlist(self):
plist = getargspec(self.__init__).args
plist = getfullargspec(self.__init__).args
plist.remove('self')
plist.remove('input')
return plist
Expand Down
2 changes: 1 addition & 1 deletion nitime/analysis/snr.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, input=None, bandwidth=None, adaptive=False,
@desc.setattr_on_read
def mt_frequencies(self):
return np.linspace(0, self.input.sampling_rate / 2,
self.input.data.shape[-1] / 2 + 1)
self.input.data.shape[-1] // 2 + 1)

@desc.setattr_on_read
def mt_signal_psd(self):
Expand Down
3 changes: 1 addition & 2 deletions nitime/tests/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np
import numpy.testing as npt
import numpy.testing.decorators as dec

from scipy.signal import signaltools
from scipy import fftpack
Expand Down Expand Up @@ -161,7 +160,7 @@ def test_psd_matlab():

npt.assert_almost_equal(fxx_mlab, fxx_matlab, decimal=5)

@dec.slow

def test_long_dpss_win():
""" Test that very long dpss windows can be generated (using interpolation)"""

Expand Down
14 changes: 7 additions & 7 deletions nitime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def adaptive_weights(yk, eigvals, sides='onesided', max_iter=150):
""")
# we'll hope this is a correct length for L
N = yk.shape[-1]
L = N / 2 + 1 if sides == 'onesided' else N
L = N // 2 + 1 if sides == 'onesided' else N
return (np.multiply.outer(np.sqrt(eigvals), np.ones(L)), 2 * K)
rt_eig = np.sqrt(eigvals)

Expand Down Expand Up @@ -1161,8 +1161,8 @@ def fftconvolve(in1, in2, mode="full", axis=None):
"""
s1 = np.array(in1.shape)
s2 = np.array(in2.shape)
complex_result = (np.issubdtype(in1.dtype, np.complex) or
np.issubdtype(in2.dtype, np.complex))
complex_result = (np.issubdtype(in1.dtype, np.complex128) or
np.issubdtype(in2.dtype, np.complex128))

if axis is None:
size = s1 + s2 - 1
Expand Down Expand Up @@ -1206,10 +1206,10 @@ def fftconvolve(in1, in2, mode="full", axis=None):
# 'get' utils
#-----------------------------------------------------------------------------
def get_freqs(Fs, n):
"""Returns the center frequencies of the frequency decomposotion of a time
"""Returns the center frequencies of the frequency decomposition of a time
series of length n, sampled at Fs Hz"""

return np.linspace(0, float(Fs) / 2, float(n) / 2 + 1)
return np.linspace(0, Fs / 2, int(n / 2 + 1))


def circle_to_hz(omega, Fsamp):
Expand Down Expand Up @@ -2037,8 +2037,8 @@ def zscore(time_series, axis=-1):
st = time_series.std(axis=axis)
sl = [slice(None)] * len(time_series.shape)
sl[axis] = np.newaxis
zt = time_series - et[sl]
zt /= st[sl]
zt = time_series - et[tuple(sl)]
zt /= st[tuple(sl)]
return zt


Expand Down
5 changes: 1 addition & 4 deletions nitime/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import sys
from nitime.six.moves import map
from nitime.six.moves import zip
if "nose" in sys.modules:
import matplotlib
matplotlib.use('agg')

# Then do all the rest of it:
import numpy as np
Expand All @@ -20,7 +17,7 @@
from matplotlib import pyplot as plt
import matplotlib.ticker as ticker
import matplotlib.colors as colors
from mpl_toolkits.axes_grid import make_axes_locatable
from mpl_toolkits.axes_grid1 import make_axes_locatable

from nitime import timeseries as ts
import nitime.utils as tsu
Expand Down