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
15 changes: 8 additions & 7 deletions sigpy/alg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
and implements commonly used methods, such as gradient methods,
Newton's method, and the augmented Lagrangian method.
"""

import numpy as np

import sigpy as sp
Expand Down Expand Up @@ -88,7 +89,7 @@ class PowerMethod(Alg):
def __init__(self, A, x, norm_func=None, max_iter=30):
self.A = A
self.x = x
self.max_eig = np.infty
self.max_eig = np.inf
self.norm_func = norm_func
super().__init__(max_iter)

Expand Down Expand Up @@ -180,7 +181,7 @@ def __init__(
self.z = self.x.copy()
self.t = 1

self.resid = np.infty
self.resid = np.inf
super().__init__(max_iter)

def _update(self):
Expand Down Expand Up @@ -371,7 +372,7 @@ def __init__(
with self.u_device:
self.sigma_min = xp.amin(xp.abs(sigma)).item()

self.resid = np.infty
self.resid = np.inf

super().__init__(max_iter)

Expand Down Expand Up @@ -490,7 +491,7 @@ def _update(self):
xp = device.xp
with device:
util.axpy(self.u, self.mu, self.g(self.x))
backend.copyto(self.u, xp.clip(self.u, 0, np.infty))
backend.copyto(self.u, xp.clip(self.u, 0, np.inf))

if self.h is not None:
util.axpy(self.v, self.mu, self.h(self.x))
Expand Down Expand Up @@ -802,10 +803,10 @@ def __init__(
self.gradf = gradf
self.inv_hessf = inv_hessf
self.x = x
self.lamda = np.infty
self.lamda = np.inf
self.beta = beta
self.f = f
self.residual = np.infty
self.residual = np.inf
self.tol = tol

super().__init__(max_iter)
Expand Down Expand Up @@ -864,7 +865,7 @@ def __init__(self, A, y, x0, max_iter=500, tol=0, max_tol=0, lamb=0):
self.tol = tol
self.max_tol = max_tol
self.lamb = lamb
self.residual = np.infty
self.residual = np.inf

def _update(self):
device = backend.get_device(self.y)
Expand Down
22 changes: 11 additions & 11 deletions sigpy/mri/rf/slr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""MRI RF excitation pulse design functions,
including SLR and small tip spatial design
including SLR and small tip spatial design
"""

import numpy as np
Expand Down Expand Up @@ -135,7 +135,7 @@ def dzls(n=64, tb=4, d1=0.01, d2=0.01):
m = [1, 1, 0, 0]
w = [1, d1 / d2]

h = signal.firls(n + 1, f, m, w)
h = signal.firls(n + 1, f, m, weight=w)
# shift the filter half a sample to make it symmetric, like in MATLAB
c = np.exp(
1j
Expand All @@ -160,7 +160,7 @@ def dzmp(n=64, tb=4, d1=0.01, d2=0.01):
m = [1, 0]
w = [1, 2 * d1 / (0.5 * d2 * d2)]

hl = signal.remez(n2, f, m, w)
hl = signal.remez(n2, f, m, weight=w)

h = fmp(hl)

Expand Down Expand Up @@ -188,7 +188,7 @@ def dzlp(n=64, tb=4, d1=0.01, d2=0.01):
m = [1, 0]
w = [1, d1 / d2]

h = signal.remez(n, f, m, w)
h = signal.remez(n, f, m, weight=w)

return h

Expand Down Expand Up @@ -253,8 +253,8 @@ def dz_gslider_b(
m_sub = [1, 1, 0, 0, 0, 0]
w = [1, 1, d1 / d2]

b_notch = signal.firls(n + 1, f, m_notch, w) # the notched filter
b_sub = signal.firls(n + 1, f, m_sub, w) # the subslice filter
b_notch = signal.firls(n + 1, f, m_notch, weight=w) # the notched filter
b_sub = signal.firls(n + 1, f, m_sub, weight=w) # the subslice filter
# add them with the subslice phase
b = np.add(b_notch, np.multiply(np.exp(1j * phi), b_sub))
# shift the filter half a sample to make it symmetric,
Expand Down Expand Up @@ -344,15 +344,15 @@ def dz_gslider_b(
)
)

b_notch = signal.firls(n + 1, f, m_notch, w) # the notched filter
b_notch = signal.firls(n + 1, f, m_notch, weight=w) # the notched filter
b_notch = sp.ifft(
np.multiply(sp.fft(b_notch, center=False), c), center=False
)
b_notch = np.real(b_notch[:n])
# hilbert transform to suppress negative passband
b_notch = signal.hilbert(b_notch)

b_sub = signal.firls(n + 1, f, m_sub, w) # the sub-band filter
b_sub = signal.firls(n + 1, f, m_sub, weight=w) # the sub-band filter
b_sub = sp.ifft(
np.multiply(sp.fft(b_sub, center=False), c), center=False
)
Expand Down Expand Up @@ -460,8 +460,8 @@ def dz_hadamard_b(n=128, g=5, gind=1, tb=4, d1=0.01, d2=0.01, shift=32):
[np.arange(0, n / 2 + 1, 1), np.arange(-n / 2, 0, 1)]
)
)
bp = signal.firls(n + 1, f, mp, w) # the positive filter
bn = signal.firls(n + 1, f, mn, w) # the negative filter
bp = signal.firls(n + 1, f, mp, weight=w) # the positive filter
bn = signal.firls(n + 1, f, mn, weight=w) # the negative filter

# combine the filters and demodulate
b = sp.ifft(
Expand Down Expand Up @@ -793,7 +793,7 @@ def dz_recursive_rf(
win_len = (win_fact - 1) * n
npad = n * z_pad_fact - win_fact * n
# blackman window?
window = signal.blackman(int((win_fact - 1) * n))
window = signal.windows.blackman(int((win_fact - 1) * n))
# split in half; stick N ones in the middle
window = np.concatenate(
(
Expand Down
6 changes: 3 additions & 3 deletions sigpy/mri/rf/trajgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ def sdotmax(
ds_p = np.linalg.norm(cp1_highres, axis=1)

# s vs p to enable conversion
s_of_p = integrate.cumtrapz(ds_p, p_highres, initial=0)
s_of_p = integrate.cumulative_trapezoid(ds_p, p_highres, initial=0)
curve_length = s_of_p[-1]

# decide ds and compute st for the first point
Expand Down Expand Up @@ -981,7 +981,7 @@ def sdotmax(
st_of_s = np.minimum(sta, stb)

# compute time
t_of_s = integrate.cumtrapz(1.0 / st_of_s, initial=0) * ds
t_of_s = integrate.cumulative_trapezoid(1.0 / st_of_s, initial=0) * ds

t = np.arange(0, t_of_s[-1] + np.finfo(float).eps, dt)

Expand All @@ -992,7 +992,7 @@ def sdotmax(
g = np.diff(c, axis=0, append=np.zeros((1, 3))) / gamma / dt
g[-1, :] = g[-2, :] + g[-2, :] - g[-3, :]

k = integrate.cumtrapz(g, t, initial=0, axis=0) * gamma
k = integrate.cumulative_trapezoid(g, t, initial=0, axis=0) * gamma

s = np.diff(g, axis=0) / dt

Expand Down
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

class TestVersion(unittest.TestCase):
def test_version(self):
assert version.__version__ == "0.1.25"
assert version.__version__ == "0.1.26"