Skip to content

Commit

Permalink
Merge branch 'main' into gradient_checks_only_for_lin_op
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 authored Jan 13, 2025
2 parents 4eccec5 + e029d5e commit c3baccd
Show file tree
Hide file tree
Showing 56 changed files with 2,390 additions and 621 deletions.
11 changes: 5 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.github
.vscode
binder
examples
docs
tests
.github
.vscode
examples
docs
tests
53 changes: 21 additions & 32 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
docker_toml: ${{ steps.filter.outputs.docker_toml }}
dockerfiles: ${{ steps.set-matrix.outputs.dockerfiles }}
imagenames: ${{ steps.set-matrix.outputs.imagenames }}
docker_tasks: ${{ steps.set-matrix.outputs.docker_tasks }}
steps:
- name: Checkout mrpro repo
uses: actions/checkout@v4
Expand All @@ -39,20 +38,17 @@ jobs:
id: set-matrix
if: steps.filter.outputs.docker_toml == 'true' || github.event_name == 'push'
run: |
cd ./docker/
ls
dockerfiles=$(ls Dockerfile_* | jq -R -s -c 'split("\n")[:-1]')
echo "dockerfiles: $dockerfiles"
echo "dockerfiles=$dockerfiles" >> $GITHUB_OUTPUT
imagenames=$(ls Dockerfile_* | sed -e 's/Dockerfile_/ghcr.io\/ptb-mr\/mrpro_/' | jq -R -s -c 'split("\n")[:-1]')
echo "image names: $imagenames"
echo "imagenames=$imagenames" >> $GITHUB_OUTPUT
# docker_tasks is a list of pairs (dictionaries) with keys 'filepath' and 'image_name' like:
# [{"filepath": "docker/Dockerfile_x1", "image_name": "ghcr.io/ptb-mr/mrpro_x1"}, ...]
docker_tasks=$(find docker -type f -name 'Dockerfile*' | jq -R -s -c 'split("\n")[:-1]' | \
jq -r -c 'map({filepath: ., image_name: . | sub("docker/Dockerfile"; "ghcr.io\/ptb-mr\/mrpro")})')
echo "docker_tasks: $docker_tasks"
echo "docker_tasks=$docker_tasks" >> $GITHUB_OUTPUT
- name: Dockerfile overview
if: steps.filter.outputs.docker_toml == 'true' || github.event_name == 'push'
run: |
echo "final list of dockerfiles: ${{ steps.set-matrix.outputs.dockerfiles }}"
echo "final list of images: ${{ steps.set-matrix.outputs.imagenames }}"
echo "final list of docker_tasks: ${{ steps.set-matrix.outputs.docker_tasks }}"
push_test:
name: Create test images and push to GCR
Expand All @@ -64,16 +60,15 @@ jobs:
strategy:
fail-fast: false
matrix:
dockerfile: ${{ fromJson(needs.get_dockerfiles.outputs.dockerfiles) }}
docker_task: ${{ fromJson(needs.get_dockerfiles.outputs.docker_tasks) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create image name
- name: Get image basename
id: image_name
run: |
dockerfile=${{ matrix.dockerfile }}
echo "image_name=${dockerfile/Dockerfile_/ghcr.io/ptb-mr/mrpro_}" >> $GITHUB_OUTPUT
echo "dockerfile_basename=$(basename ${{ matrix.docker_task.filepath }})" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -89,11 +84,11 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha,scope=${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=${{ matrix.dockerfile }}
file: ./docker/${{ matrix.dockerfile }}
cache-from: type=gha,scope=$${{ steps.image_name.outputs.dockerfile_basename }})
cache-to: type=gha,mode=max,scope=${{ steps.image_name.outputs.dockerfile_basename }}
file: ${{ matrix.docker_task.filepath }}
push: true
tags: ${{ steps.image_name.outputs.image_name }}:test
tags: ${{ matrix.docker_task.image_name }}:test

test:
name: Test docker containers
Expand All @@ -105,10 +100,10 @@ jobs:
contents: write
strategy:
matrix:
imagename: ${{ fromJson(needs.get_dockerfiles.outputs.imagenames) }}
docker_task: ${{ fromJson(needs.get_dockerfiles.outputs.docker_tasks) }}
# runs within Docker container
container:
image: ${{ matrix.imagename }}:test
image: ${{ matrix.docker_task.image_name }}:test
options: --user runner

steps:
Expand All @@ -134,17 +129,11 @@ jobs:
packages: write
strategy:
matrix:
dockerfile: ${{ fromJson(needs.get_dockerfiles.outputs.dockerfiles) }}
docker_task: ${{ fromJson(needs.get_dockerfiles.outputs.docker_tasks) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create image name
id: image_name
run: |
dockerfile=${{ matrix.dockerfile }}
echo "image_name=${dockerfile/Dockerfile_/ghcr.io/ptb-mr/mrpro_}" >> $GITHUB_OUTPUT
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
Expand All @@ -154,6 +143,6 @@ jobs:

- name: Pull and push Docker image with new tag
run: |
docker pull ${{ steps.image_name.outputs.image_name }}:test
docker tag ${{ steps.image_name.outputs.image_name }}:test ${{ steps.image_name.outputs.image_name }}:latest
docker push ${{ steps.image_name.outputs.image_name }}:latest
docker pull ${{ matrix.docker_task.image_name }}:test
docker tag ${{ matrix.docker_task.image_name }}:test ${{ matrix.docker_task.image_name }}:latest
docker push ${{ matrix.docker_task.image_name}}:latest
29 changes: 23 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ jobs:

- id: set-matrix
run: |
cd ./examples/
ls
echo "notebooks=$(ls *.ipynb | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
echo "notebooks=$(find examples -type f -name '*.ipynb' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
- name: Notebook overview
run: |
Expand Down Expand Up @@ -108,19 +106,37 @@ jobs:
run: |
echo "current jupyter-notebook: ${{ matrix.notebook }}"
- name: Add nb-myst download badge
run: |
notebook=${{ matrix.notebook }}
notebook_name=$(basename $notebook)
download_badge_md="[![Download notebook](https://img.shields.io/badge/Download-notebook-blue?logo=jupyter)](path:$notebook_name)"
python_command="import nbformat as nbf\n\
nb = nbf.read(open('$notebook'), as_version=4)\n\
# if the 1st cell is md and has colab text => add space after\n\
if nb['cells'][0]['cell_type'] == 'markdown' and 'colab' in nb['cells'][0]['source'].lower():\n\
nb['cells'][0]['source'] += ' '\n\
# if there is no md cell with colab => create empty md cell on top\n\
else:\n\
nb['cells'].insert(0, nbf.v4.new_markdown_cell())\n\
nb['cells'][0]['source'] += '$download_badge_md'\n\
nbf.write(nb, open('$notebook', 'w'))"
python -c "exec (\"$python_command\")"
- name: Run notebook
uses: fzimmermann89/run-notebook@v3
env:
RUNNER: ${{ toJson(runner) }}
with:
notebook: ./examples/${{ matrix.notebook }}
notebook: ./${{ matrix.notebook }}

- name: Get artifact names
id: artifact_names
run: |
notebook=${{ matrix.notebook }}
echo "ARTIFACT_NAME=${notebook/.ipynb/}" >> $GITHUB_OUTPUT
echo "IPYNB_EXECUTED=${notebook}" >> $GITHUB_OUTPUT
echo "ARTIFACT_NAME=$(basename ${notebook/.ipynb})" >> $GITHUB_OUTPUT
echo "IPYNB_EXECUTED=$(basename $notebook)" >> $GITHUB_OUTPUT
- name: Upload notebook
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -155,6 +171,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: ./docs/source/_notebooks/
merge-multiple: true

- name: Build docs
run: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ jobs:
outputs:
imagenames: ${{ steps.set-matrix.outputs.imagenames }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Retrieve Docker Image Names
id: set-matrix
env:
GH_TOKEN: ${{ secrets.GHCR_TOKEN }}
run: |
imagenames=$(curl -s --request GET \
--url "https://api.github.com/orgs/PTB-MR/packages?package_type=container" \
--header "Authorization: Bearer $GH_TOKEN" | jq -r '.[].name')
# search for Dockerfile* in the docker directory, replace "Dockerfile" prefix with "mrpro" and to imagenames
imagenames=$(find docker -type f -name 'Dockerfile*' -exec basename {} \; | sed 's/^Dockerfile/mrpro/')
echo "image names: $imagenames"
# if imagenames is empty - fail the workflow
if [ -z "$imagenames" ]; then
echo "No Dockerfiles found in the docker directory. Exiting..."
exit 1
fi
imagenames_latest=()
for image in $(echo $imagenames)
for image in $imagenames
do
echo "checking $image ..."
if docker manifest inspect "ghcr.io/ptb-mr/"$image":latest" >/dev/null; then
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.6
hooks:
- id: ruff # linter
args: [--fix]
- id: ruff-format # formatter

- repo: https://github.com/crate-ci/typos
rev: v1.27.0
rev: v1.29.4
hooks:
- id: typos

Expand All @@ -33,7 +33,7 @@ repos:
exclude: ^tests/

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.1
hooks:
- id: mypy
pass_filenames: false
Expand Down
54 changes: 54 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
abstract:
<p>MRpro is a MR image reconstruction and processing framework specifically
developed to work well with PyTorch. The data classes utilize torch tensors for
storing data such as MR raw data or reconstructed image data. Where possible batch
parallelisation of PyTorch is utilized to speed up image reconstruction.</p>
authors:
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Zimmermann
given-names: Felix Frederik
orcid: 0000-0002-0862-8973
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Schuenke
given-names: Patrick
orcid: 0000-0002-3179-4830
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Brahma
given-names: Sherine
orcid: 0000-0003-4340-6513
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Guastini
given-names: Mara
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Hammacher
given-names: Johannes
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Kofler
given-names: Andreas
orcid: 0000-0002-7416-4433
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Kranich Redshaw
given-names: Catarina
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Lunin
given-names: Leonid
orcid: 0000-0001-6469-5532
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Martin
given-names: Stefan
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Schote
given-names: David
orcid: 0000-0003-3468-0676
- affiliation: Physikalisch-Technische Bundesanstalt
family-names: Kolbitsch
given-names: Christoph
orcid: 0000-0002-4355-8368
cff-version: 1.2.0
date-released: "2024-12-17"
doi: 10.5281/zenodo.14509598
license: Apache-2.0
repository-code: https://github.com/PTB-MR/mrpro/
title: MRpro - PyTorch-based MR image reconstruction and processing package
type: software
url: https://doi.org/10.5281/zenodo.14509598
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# MRpro
<h1 align="center">

![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12-blue)
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/source/_static/logo_white.svg">
<source media="(prefers-color-scheme: light)" srcset="docs/source/_static/logo.svg">
<img src="docs/source/_static/logo.svg" alt="MRpro logo" width="50%">
</picture>

</h1><br>

![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![Coverage Bagde](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/ckolbPTB/48e334a10caf60e6708d7c712e56d241/raw/coverage.json)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14509598.svg)](https://doi.org/10.5281/zenodo.14509598)

MR image reconstruction and processing package specifically developed for PyTorch.

- **Source code:** <https://github.com/PTB-MR/mrpro>
- **Documentation:** <https://ptb-mr.github.io/mrpro/>
- **Bug reports:** <https://github.com/PTB-MR/mrpro/issues>
- **Try it out:** [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/PTB-MR/mrpro.git/main?labpath=examples)
- **Try it out:** [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/PTB-MR/mrpro)

## Awards

Expand Down Expand Up @@ -84,5 +93,3 @@ We are looking forward to your contributions via Pull-Requests.
4. Setup pre-commit hook: ``` pre-commit install ```

Please look at our [contributor guide](https://ptb-mr.github.io/mrpro/contributor_guide.html) for more information on the repository structure, naming conventions, and other useful information.


9 changes: 0 additions & 9 deletions binder/environment.yml

This file was deleted.

Loading

0 comments on commit c3baccd

Please sign in to comment.