diff --git a/examples/example_density.py b/examples/example_density.py index 38280edd..98950aee 100644 --- a/examples/example_density.py +++ b/examples/example_density.py @@ -111,7 +111,7 @@ # %% flat_traj = traj.reshape(-1, 2) -weights = np.sqrt(np.sum(flat_traj ** 2, axis=1)) +weights = np.sqrt(np.sum(flat_traj**2, axis=1)) nufft = get_operator("finufft")(traj, shape=mri_2D.shape, density=weights) adjoint_manual = nufft.adj_op(kspace) fig, axs = plt.subplots(1, 3, figsize=(15, 5)) diff --git a/src/mrinufft/density/geometry_based.py b/src/mrinufft/density/geometry_based.py index cb091831..4dc0ecc5 100644 --- a/src/mrinufft/density/geometry_based.py +++ b/src/mrinufft/density/geometry_based.py @@ -87,7 +87,7 @@ def voronoi_unique(traj, *args, **kwargs): # For edge point (infinite voronoi cells) we extrapolate from neighbours # Initial implementation in Jeff Fessler's MIRT - rho = np.sum(traj ** 2, axis=1) + rho = np.sum(traj**2, axis=1) igood = (rho > 0.6 * np.max(rho)) & ~np.isinf(wi) if len(igood) < 10: print("dubious extrapolation with", len(igood), "points") diff --git a/src/mrinufft/extras/smaps.py b/src/mrinufft/extras/smaps.py index 68d28624..8a33f353 100644 --- a/src/mrinufft/extras/smaps.py +++ b/src/mrinufft/extras/smaps.py @@ -89,9 +89,7 @@ def _extract_kspace_center( a_0 = 0.5 if window_fun in ["hann", "hanning"] else 0.53836 window = a_0 + (1 - a_0) * xp.cos(xp.pi * radius / threshold) elif window_fun == "ellipse": - window = ( - xp.sum(kspace_loc ** 2 / xp.asarray(threshold) ** 2, axis=1) <= 1 - ) + window = xp.sum(kspace_loc**2 / xp.asarray(threshold) ** 2, axis=1) <= 1 else: raise ValueError("Unsupported window function.") data_thresholded = window * kspace_data diff --git a/src/mrinufft/extras/utils.py b/src/mrinufft/extras/utils.py index 41988b1f..5c9a7b9d 100644 --- a/src/mrinufft/extras/utils.py +++ b/src/mrinufft/extras/utils.py @@ -1,4 +1,5 @@ """Utils for extras module.""" + from mrinufft._utils import MethodRegister register_smaps = MethodRegister("sensitivity_maps") diff --git a/src/mrinufft/io/siemens.py b/src/mrinufft/io/siemens.py index b3cc79c2..9cc782aa 100644 --- a/src/mrinufft/io/siemens.py +++ b/src/mrinufft/io/siemens.py @@ -1,4 +1,5 @@ """Siemens specific rawdat reader, wrapper over pymapVBVD.""" + import numpy as np diff --git a/src/mrinufft/trajectories/maths.py b/src/mrinufft/trajectories/maths.py index eb8310e9..d8ad192f 100644 --- a/src/mrinufft/trajectories/maths.py +++ b/src/mrinufft/trajectories/maths.py @@ -187,19 +187,19 @@ def Ra(vector, theta): return np.array( [ [ - cos_t + v_x ** 2 * (1 - cos_t), + cos_t + v_x**2 * (1 - cos_t), v_x * v_y * (1 - cos_t) + v_z * sin_t, v_x * v_z * (1 - cos_t) - v_y * sin_t, ], [ v_y * v_x * (1 - cos_t) - v_z * sin_t, - cos_t + v_y ** 2 * (1 - cos_t), + cos_t + v_y**2 * (1 - cos_t), v_y * v_z * (1 - cos_t) + v_x * sin_t, ], [ v_z * v_x * (1 - cos_t) + v_y * sin_t, v_z * v_y * (1 - cos_t) - v_x * sin_t, - cos_t + v_z ** 2 * (1 - cos_t), + cos_t + v_z**2 * (1 - cos_t), ], ] ) diff --git a/src/mrinufft/trajectories/tools.py b/src/mrinufft/trajectories/tools.py index 972d013d..a3feebcd 100644 --- a/src/mrinufft/trajectories/tools.py +++ b/src/mrinufft/trajectories/tools.py @@ -310,7 +310,7 @@ def stack_spherically( # Attribute shots to stacks following density proportional to surface Nc_per_stack = np.ones(nb_stacks).astype(int) - density = radii ** 2 # simplified version + density = radii**2 # simplified version for _ in range(Nc - nb_stacks): idx = np.argmax(density / Nc_per_stack) Nc_per_stack[idx] += 1 @@ -406,7 +406,7 @@ def shellify( ) # Carve upper hemisphere from trajectory - z_coords = KMAX ** 2 - shell_upper[..., 0] ** 2 - shell_upper[..., 1] ** 2 + z_coords = KMAX**2 - shell_upper[..., 0] ** 2 - shell_upper[..., 1] ** 2 z_signs = np.sign(z_coords) shell_upper[..., 2] += z_signs * np.sqrt(np.abs(z_coords)) diff --git a/src/mrinufft/trajectories/trajectory3D.py b/src/mrinufft/trajectories/trajectory3D.py index bc2255b5..aab30197 100644 --- a/src/mrinufft/trajectories/trajectory3D.py +++ b/src/mrinufft/trajectories/trajectory3D.py @@ -240,7 +240,7 @@ def initialize_3D_wave_caipi( elif packing == Packings.CIRCLE: positions = [[0, 0]] counter = 0 - while len(positions) < side ** 2: + while len(positions) < side**2: counter += 1 perimeter = 2 * np.pi * counter nb_shots = int(np.trunc(perimeter)) @@ -353,11 +353,11 @@ def initialize_3D_seiffert_spiral( """ # Normalize ellipses integrations by the requested period spiral = np.zeros((1, Ns // (1 + in_out), 3)) - period = 4 * ellipk(curve_index ** 2) + period = 4 * ellipk(curve_index**2) times = np.linspace(0, nb_revolutions * period, Ns // (1 + in_out), endpoint=False) # Initialize first shot - jacobi = ellipj(times, curve_index ** 2) + jacobi = ellipj(times, curve_index**2) spiral[0, :, 0] = jacobi[0] * np.cos(curve_index * times) spiral[0, :, 1] = jacobi[0] * np.sin(curve_index * times) spiral[0, :, 2] = jacobi[1] @@ -655,7 +655,7 @@ def initialize_3D_seiffert_shells( Nc_per_shell[idx] += 1 # Normalize ellipses integrations by the requested period - period = 4 * ellipk(curve_index ** 2) + period = 4 * ellipk(curve_index**2) times = np.linspace(0, nb_revolutions * period, Ns, endpoint=False) # Create shells one by one @@ -667,7 +667,7 @@ def initialize_3D_seiffert_shells( k0 = radii[i] # Initialize first shot - jacobi = ellipj(times, curve_index ** 2) + jacobi = ellipj(times, curve_index**2) trajectory[count, :, 0] = k0 * jacobi[0] * np.cos(curve_index * times) trajectory[count, :, 1] = k0 * jacobi[0] * np.sin(curve_index * times) trajectory[count, :, 2] = k0 * jacobi[1]