Skip to content

Commit

Permalink
sync .ipynb/.py in pre-commit, add preamble in .py files
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlunin committed Nov 19, 2024
1 parent 0600a53 commit beddf13
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 20 deletions.
21 changes: 8 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,16 @@ repos:

- repo: https://github.com/mwouts/jupytext
rev: v1.16.4
# converts (--to ipynb) the .py to the .ipynb and preserves (--update) the assigned
# "clear" cells' ids from the nbstripout
hooks:
- id: jupytext
name: convert .py to .ipynb
args: [--to, ipynb, --update]
files: '^examples/(.*\.py)$'
- repo: https://github.com/mwouts/jupytext
rev: v1.16.4
# if user interacted with the .ipynb and changed the kernel name
hooks:
- id: jupytext
name: update .ipynb metadata
args: [--update-metadata, '{"kernelspec": {"display_name": "Python 3 (ipykernel)","language": "python","name": "python3"}}']
files: '^examples/(.*\.ipynb)$'
name: sync .py and .ipynb
args:
- --sync
- --update-metadata
- '{"kernelspec": {"display_name": "Python 3 (ipykernel)","language": "python","name": "python3"}}'
- --set-formats
- ipynb,py:percent
files: '^examples/(.*\.ipynb|.*\.py)$'
ci:
autofix_commit_msg: |
[pre-commit] auto fixes from pre-commit hooks
Expand Down
3 changes: 2 additions & 1 deletion examples/direct_reconstruction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/direct_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Direct Reconstruction of 2D golden angle radial data
# Here we use the DirectReconstruction class to reconstruct images from ISMRMRD 2D radial data
Expand Down
3 changes: 2 additions & 1 deletion examples/iterative_sense_reconstruction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/iterative_sense_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Iterative SENSE Reconstruction of 2D golden angle radial data
# Here we use the IterativeSENSEReconstruction class to reconstruct images from ISMRMRD 2D radial data
Expand Down
3 changes: 2 additions & 1 deletion examples/pulseq_2d_radial_golden_angle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/pulseq_2d_radial_golden_angle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Reconstruction of 2D golden angle radial data from pulseq sequence
# Here we manually do all steps of a direction reconstruction, i.e.
Expand Down
3 changes: 2 additions & 1 deletion examples/qmri_sg_challenge_2024_t1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/qmri_sg_challenge_2024_t1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # QMRI Challenge ISMRM 2024 - $T_1$ mapping

Expand Down
3 changes: 2 additions & 1 deletion examples/qmri_sg_challenge_2024_t2_star.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/qmri_sg_challenge_2024_t2_star.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # QMRI Challenge ISMRM 2024 - $T_2^*$ mapping

Expand Down
3 changes: 2 additions & 1 deletion examples/regularized_iterative_sense_reconstruction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/regularized_iterative_sense_reconstruction.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # Regularized Iterative SENSE Reconstruction of 2D golden angle radial data
# Here we use the RegularizedIterativeSENSEReconstruction class to reconstruct images from ISMRMRD 2D radial data
Expand Down
3 changes: 2 additions & 1 deletion examples/t1_mapping_with_grad_acq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@
],
"metadata": {
"jupytext": {
"cell_metadata_filter": "-all"
"cell_metadata_filter": "-all",
"formats": "ipynb,py:percent"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down
16 changes: 16 additions & 0 deletions examples/t1_mapping_with_grad_acq.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# formats: ipynb,py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Python 3 (ipykernel)
# language: python
# name: python3
# ---

# %% [markdown]
# # $T_1$ mapping from a continuous Golden radial acquisition

Expand Down

0 comments on commit beddf13

Please sign in to comment.