Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have a trajectory learner example and reform the documentation build flow #167

Merged
merged 89 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
ee1bd5f
cufinufft and gpunufft smaps support update
AsmaTANABEN Jul 10, 2024
1d32671
Add smaps update tests for cufinufft and gpunuft
AsmaTANABEN Jul 10, 2024
bfd1bbc
No need to save traj variable if differenciation wrt trajectory is no…
AsmaTANABEN Jul 10, 2024
5039db5
add the case when differenciation is wrt to trajectory and not data t…
AsmaTANABEN Jul 11, 2024
0aa53c7
Corrections for PR comments
AsmaTANABEN Jul 17, 2024
9fe4a6b
Changes for ruff checks
AsmaTANABEN Jul 18, 2024
545bcd9
Get rid of saving trajectory
chaithyagr Jul 19, 2024
d4d4b7a
Fix data
chaithyagr Jul 19, 2024
dd5c3f7
Update tests/operators/test_update.py
chaithyagr Jul 19, 2024
29c8c2e
Update tests/operators/test_update.py
chaithyagr Jul 19, 2024
6b1d01f
Merge branch 'master' into smaps_update
chaithyagr Jul 19, 2024
425bf96
Run examples on tests on nodes
chaithyagr Jul 19, 2024
d923dc2
Merge branch 'smaps_update' of github.com:mind-inria/mri-nufft into s…
chaithyagr Jul 19, 2024
1086e15
Update test-ci.yml
chaithyagr Jul 20, 2024
8c62467
Merge branch 'master' into smaps_update
chaithyagr Jul 20, 2024
d0c3f79
Update tests/operators/test_update.py
chaithyagr Jul 22, 2024
8e5479e
Update tests/operators/test_update.py
chaithyagr Jul 23, 2024
d9befe1
Update tests/operators/test_update.py
chaithyagr Jul 23, 2024
46f0e59
Added autodiff changes as per suggestions
chaithyagr Jul 23, 2024
c72cce8
fix indent
chaithyagr Jul 23, 2024
21063a5
revert
chaithyagr Jul 23, 2024
1e11a17
Fixed
chaithyagr Jul 23, 2024
9b84696
Added
Apr 26, 2024
23bd7ca
Fix
Apr 26, 2024
ef223c6
Remove bymistake add
Apr 26, 2024
aaa49ef
Fix
Apr 26, 2024
ab19c4a
Fixed lint
Apr 26, 2024
32f3f80
Lint
Apr 26, 2024
f97d2ca
Added refbackend
Apr 26, 2024
505513c
Fix NDFT
Apr 26, 2024
4e954bb
feat(tests): move ndft vs nufft tests to own file.
paquiteau Apr 29, 2024
8f4d3d3
Setup samples
chaithyagr Jun 28, 2024
48a97f3
Working
chaithyagr Jun 28, 2024
0ee6063
Added example and few fixes
chaithyagr Jun 28, 2024
2f2a0c2
Update src/mrinufft/_utils.py
chaithyagr Jun 28, 2024
04dc8e1
Update
chaithyagr Jul 23, 2024
47250a1
Learn samples
chaithyagr Jul 23, 2024
015f8bb
Fix style
chaithyagr Jul 23, 2024
b496c13
Move to GPU
chaithyagr Jul 23, 2024
6534503
add shape check in smaps setters
AsmaTANABEN Jul 23, 2024
419fc26
Added a bunch of files
chaithyagr Jul 23, 2024
7355819
Updated codes to rightly generate the docs
chaithyagr Jul 23, 2024
3e38fce
Fixed black and also codes
chaithyagr Jul 23, 2024
bfec0da
Merge branch 'smaps_update' into learn
chaithyagr Jul 23, 2024
736903d
Tried to add to TOC
chaithyagr Jul 23, 2024
8d06e00
Added artifacts docs_build
chaithyagr Jul 24, 2024
bfe8f9a
Fix ruff
chaithyagr Jul 24, 2024
50d4805
fix docs_build
chaithyagr Jul 24, 2024
803ea94
Use direct self.smaps
chaithyagr Jul 24, 2024
ccd4aac
Dont download
chaithyagr Jul 24, 2024
42d1cb0
docs_build
chaithyagr Jul 24, 2024
d38772b
docs_build try again
chaithyagr Jul 24, 2024
36d0ad3
docs_build updated docs
chaithyagr Jul 24, 2024
7f67296
test_pr_comment docs_build
chaithyagr Jul 24, 2024
7803c22
test_pr_comment docs_build
chaithyagr Jul 24, 2024
8dfb7e7
Test new flow
chaithyagr Jul 24, 2024
f201876
Test docs_build
chaithyagr Jul 24, 2024
ffc407a
Test docs_builda
chaithyagr Jul 24, 2024
e4f5e60
docs_build
chaithyagr Jul 24, 2024
a5a930d
Update and remove docs_build
chaithyagr Jul 24, 2024
2d54b74
docs_build
chaithyagr Jul 24, 2024
e8fcb28
build_docs
chaithyagr Jul 24, 2024
359af34
Fixes in codes and
chaithyagr Jul 24, 2024
3100cc8
Call super
chaithyagr Jul 24, 2024
678e6e0
All fixed hopefully
chaithyagr Jul 25, 2024
be52237
Fixed cufinufft
chaithyagr Jul 25, 2024
3154645
Merge branch 'smaps_update' into learn
chaithyagr Jul 25, 2024
0d66c5d
Fixed source
chaithyagr Jul 25, 2024
b974311
Fixed cufinufft
chaithyagr Jul 25, 2024
6882173
Added new operator
chaithyagr Jul 25, 2024
4957e07
Add checks after setting smaps
chaithyagr Jul 25, 2024
e2a7133
Update
chaithyagr Jul 25, 2024
d7a3624
Remove unwanted print
chaithyagr Jul 25, 2024
b2bac48
Skip testing with tensorflow
chaithyagr Jul 25, 2024
686fa84
Move to check shapes and stop installing torch
chaithyagr Jul 25, 2024
79aabba
Black
chaithyagr Jul 25, 2024
3ecbd6a
Fix style
chaithyagr Jul 25, 2024
1776c19
Merge branch 'master' into smaps_update
chaithyagr Jul 25, 2024
c3202f3
remove
chaithyagr Jul 25, 2024
0c8c317
remove
chaithyagr Jul 25, 2024
8c42f36
restart
chaithyagr Jul 25, 2024
016c5ff
Fix
chaithyagr Jul 25, 2024
b263eb1
Remove tensorlfow
chaithyagr Jul 25, 2024
4d74862
Merge branch 'smaps_update' into learn
chaithyagr Jul 25, 2024
fd3b2a0
undo remove
chaithyagr Jul 25, 2024
c305ae2
Merge branch 'smaps_update' into learn
chaithyagr Jul 25, 2024
4427210
Merge branch 'master' into learn
chaithyagr Jul 25, 2024
76abe2b
Multiple critical fixes. Updating codes
chaithyagr Jul 26, 2024
93edf7e
Install and run on GPU
chaithyagr Jul 26, 2024
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
35 changes: 6 additions & 29 deletions .github/workflows/master-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,19 @@ jobs:
if: success()

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install .[doc]
python -m pip install finufft

- name: Build API documentation
run: |
python -m sphinx docs docs_build

- name: Get the badge from CI
- name: Get the docs_build artifact
uses: actions/download-artifact@v4
with:
name: coverage_badge
path: docs_build/_static
github-token: ${{ secrets.GITHUB_TOKEN }}
name: docs_final
path: docs_build
run-id: ${{ github.event.workflow_run.id }}

- name: Display structure of docs
run: ls -R docs_build/

- name: Display data
run: ls -R
working-directory: docs_build/_static
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: 'docs_build'

- name: Deploy to GitHub Pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Style checking
name: Style

on:
push:
Expand Down
88 changes: 87 additions & 1 deletion .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ jobs:
rm -rf venv

test-examples:
runs-on: cpu
runs-on: gpu
if: ${{ !contains(github.event.head_commit.message, 'style')}}

steps:
Expand All @@ -194,6 +194,15 @@ jobs:
python -m pip install --upgrade pip
python -m pip install -e .[test,dev]
python -m pip install finufft pooch brainweb-dl torch

- name: Install GPU related interfaces
run: |
export CUDA_BIN_PATH=/usr/local/cuda-11.8/
export PATH=/usr/local/cuda-11.8/bin/:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64/:${LD_LIBRARY_PATH}
pip install cupy-cuda11x
pip install torch --index-url https://download.pytorch.org/whl/cu118
python -m pip install gpuNUFFT cufinufft

- name: Run examples
shell: bash
Expand Down Expand Up @@ -268,3 +277,80 @@ jobs:
with:
name: coverage_badge
path: coverage_badge.svg

BuildDocs:
name: Build API Documentation
runs-on: gpu
if: ${{ contains(github.event.head_commit.message, 'docs_build')}} or ${{github.ref == 'refs/heads/master'}}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install .[doc]
python -m pip install finufft

- name: Install GPU related interfaces
run: |
export CUDA_BIN_PATH=/usr/local/cuda-11.8/
export PATH=/usr/local/cuda-11.8/bin/:${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64/:${LD_LIBRARY_PATH}
pip install cupy-cuda11x
pip install torch --index-url https://download.pytorch.org/whl/cu118
python -m pip install gpuNUFFT cufinufft

- name: Build API documentation
run: |
python -m sphinx docs docs_build

- name: Display data
run: ls -R
working-directory: docs_build/_static

- name: Upload artifact
id: artifact-upload-step
uses: actions/upload-artifact@v4
with:
# Upload the docs
name: docs
path: 'docs_build'
retention-days: 5

CompileDocs:
name: Compile the coverage badge in docs
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs: [BuildDocs, coverage]
steps:
- name: Get the docs_build artifact
uses: actions/download-artifact@v4
with:
name: docs
path: docs_build

- name: Get the badge from CI
uses: actions/download-artifact@v4
with:
name: coverage_badge
path: docs_build/_static
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: ReUpload artifacts
uses: actions/upload-artifact@v4
with:
name: docs_final
retention-days: 20
path: docs_build
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@
"examples_dirs": ["../examples/"],
"gallery_dirs": ["generated/autoexamples"],
"filename_pattern": "/example_",
"ignore_pattern": r"/(__init__|conftest|utils)\.py",
"ignore_pattern": r"(__init__|conftest|utils).py",
"nested_sections": True,
"parallel": 3,
}

intersphinx_mapping = {
Expand Down
6 changes: 6 additions & 0 deletions examples/GPU/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _gpu_examples:

GPU Examples
------------

This is a collection of examples showing features of mri-nufft, particularly those that are GPU-accelerated.
30 changes: 14 additions & 16 deletions examples/example_density.py → examples/GPU/example_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Create sample data
# ------------------

mri_2D = bwdl.get_mri(4, "T1")[80, ...].astype(np.float32)
mri_2D = np.flipud(bwdl.get_mri(4, "T1")[80, ...]).astype(np.float32)

print(mri_2D.shape)

Expand Down Expand Up @@ -136,18 +136,16 @@
# The Pipe method is currently only implemented for gpuNUFFT.

# %%
if check_backend("gpunufft"):
flat_traj = traj.reshape(-1, 2)
nufft = get_operator("gpunufft")(
traj, shape=mri_2D.shape, density={"name": "pipe", "osf": 2}
)
adjoint_manual = nufft.adj_op(kspace)
fig, axs = plt.subplots(1, 3, figsize=(15, 5))
axs[0].imshow(abs(mri_2D))
axs[0].set_title("Ground Truth")
axs[1].imshow(abs(adjoint))
axs[1].set_title("no density compensation")
axs[2].imshow(abs(adjoint_manual))
axs[2].set_title("Pipe density compensation")

print(nufft.density)
flat_traj = traj.reshape(-1, 2)
nufft = get_operator("gpunufft")(
traj, shape=mri_2D.shape, density={"name": "pipe", "osf": 2}
)
adjoint_manual = nufft.adj_op(kspace)
fig, axs = plt.subplots(1, 3, figsize=(15, 5))
axs[0].imshow(abs(mri_2D))
axs[0].set_title("Ground Truth")
axs[1].imshow(abs(adjoint))
axs[1].set_title("no density compensation")
axs[2].imshow(abs(adjoint_manual))
axs[2].set_title("Pipe density compensation")
print(nufft.density)
Loading
Loading