Skip to content

Commit

Permalink
Merge branch 'master' into fix_issue_211
Browse files Browse the repository at this point in the history
  • Loading branch information
chaithyagr authored Dec 6, 2024
2 parents 11b7859 + 406e9ae commit 5d02c33
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
4 changes: 3 additions & 1 deletion docs/binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ dependencies:
- jupyter>=1.0.0
- pip:
- mri-nufft[finufft]
- pynfft2
- joblib
- brainweb-dl
- torch
2 changes: 1 addition & 1 deletion docs/sphinx_add_colab_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def notebook_modifier(self, notebook_path, commands):
idx = self.find_index_of_colab_link(notebook)
code_lines = ["# Install libraries"]
code_lines.append(commands)
code_lines.append("pip install brainweb-dl # Required for data")
code_lines.append("!pip install brainweb-dl # Required for data")
dummy_notebook_content = {"cells": []}
add_code_cell(
dummy_notebook_content,
Expand Down
6 changes: 6 additions & 0 deletions examples/GPU/example_cg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
- https://en.wikipedia.org/wiki/Momentum
"""

# %%
# .. colab-link::
# :needs_gpu: 1
#
# !pip install mri-nufft[gpunufft] scikit-image

# %%
# Imports
import numpy as np
Expand Down
5 changes: 5 additions & 0 deletions examples/GPU/example_fastMRI_UNet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
.. warning::
We train on a single image here. In practice, this should be done on a database like fastMRI [fastmri]_.
"""
# %%
# .. colab-link::
# :needs_gpu: 1
#
# !pip install mri-nufft[gpunufft] scikit-image fastmri

# %%
# Imports
Expand Down
7 changes: 7 additions & 0 deletions examples/GPU/example_learn_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
.. warning::
This example only showcases the autodiff capabilities, the learned sampling pattern is not scanner compliant as the scanner gradients required to implement it violate the hardware constraints. In practice, a projection :math:`\Pi_\mathcal{Q}(\mathbf{K})` into the scanner constraints set :math:`\mathcal{Q}` is recommended (see [Proj]_). This is implemented in the proprietary SPARKLING package [Sparks]_. Users are encouraged to contact the authors if they want to use it.
"""

# %%
# .. colab-link::
# :needs_gpu: 1
#
# !pip install mri-nufft[gpunufft] scikit-image

import time
import joblib

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "MRI Non-Cartesian Fourier Operators with multiple computation bac
authors = [{name="Pierre-antoine Comby", email="[email protected]"}]

readme = "README.md"
dependencies = ["numpy<2.0", "scipy", "matplotlib", "tqdm"]
dependencies = ["numpy<=2.0.0", "scipy", "matplotlib", "tqdm"]
requires-python = ">=3.8"

dynamic = ["version"]
Expand All @@ -15,7 +15,7 @@ gpunufft = ["gpuNUFFT>=0.9.0", "cupy-cuda12x"]
torchkbnufft = ["torchkbnufft", "cupy-cuda12x"]
cufinufft = ["cufinufft<2.3", "cupy-cuda12x"]
finufft = ["finufft"]
pynfft = ["pynfft2>=1.4.3", "numpy>=2.0.0"]
pynfft = ["pynfft2>=1.4.3; python_version < '3.12'", "numpy>=2.0.0; python_version < '3.12'"]
pynufft = ["pynufft"]
io = ["pymapvbvd"]
smaps = ["scikit-image"]
Expand Down
3 changes: 1 addition & 2 deletions src/mrinufft/io/cfl.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def _writecfl(array, cfl_file, hdr_file=None):

with open(hdr_file, "w") as h:
h.write("# Dimensions\n")
for i in array.shape:
h.write("%d " % i)
h.write("".join(f"{i} " for i in array.shape))
h.write("\n")

size = np.prod(array.shape) * np.dtype(np.complex64).itemsize
Expand Down
7 changes: 4 additions & 3 deletions src/mrinufft/operators/off_resonance.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ def __init__(
):
if backend == "gpu" and not CUPY_AVAILABLE:
raise RuntimeError("Cupy is required for gpu computations.")
if backend == "torch":
elif backend == "torch":
self.xp = torch
if backend == "gpu":
elif backend == "gpu":
self.xp = cp
elif backend == "cpu":
self.xp = np
else:
raise ValueError("Unsupported backend.")

self._fourier_op = fourier_op

self.n_coils = fourier_op.n_coils
Expand Down Expand Up @@ -311,7 +312,7 @@ def adj_op(self, coeffs, *args):
"""
y = 0.0
coeffs_d = self.xp.array(coeffs)
coeffs_d = self.xp.asarray(coeffs)
if self.C is not None:
for idx in range(self.n_interpolators):
y += self.xp.conj(self.C[idx]) * self._fourier_op.adj_op(
Expand Down

0 comments on commit 5d02c33

Please sign in to comment.