Skip to content

Commit b7417e6

Browse files
Merge branch 'main' into zenodo_IO
2 parents 0801ec3 + 1f4cbf4 commit b7417e6

File tree

5 files changed

+200
-10
lines changed

5 files changed

+200
-10
lines changed

.github/workflows/analysis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
outputs: # here we use the outputs from steps, and set outputs for the job `configure`
1313
algorithms: ${{ steps.algorithms.outputs.algorithms }}
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Set up Python
1717
id: setup_python
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: "3.11"
2121
cache: 'pip'
@@ -53,9 +53,9 @@ jobs:
5353
algorithm: ${{fromJson(needs.algorithms.outputs.algorithms).algorithms}}
5454
SNR: [10, 30, 50, 100, 200]
5555
steps:
56-
- uses: actions/checkout@v3
56+
- uses: actions/checkout@v4
5757
- name: Set up Python
58-
uses: actions/setup-python@v4
58+
uses: actions/setup-python@v5
5959
with:
6060
python-version: "3.11"
6161
cache: 'pip'
@@ -111,7 +111,7 @@ jobs:
111111
runs-on: ubuntu-latest
112112
needs: merge
113113
steps:
114-
- uses: actions/checkout@v3
114+
- uses: actions/checkout@v4
115115
- name: Set up R
116116
uses: r-lib/actions/setup-r@v2
117117
with:
@@ -151,7 +151,7 @@ jobs:
151151
runs-on: ubuntu-latest
152152
needs: merge
153153
steps:
154-
- uses: actions/checkout@v3
154+
- uses: actions/checkout@v4
155155
- name: Set up R
156156
uses: r-lib/actions/setup-r@v2
157157
with:
@@ -175,4 +175,4 @@ jobs:
175175
name: Comparison
176176
path: |
177177
test_reference.csv
178-
test_results.csv
178+
test_results.csv

.github/workflows/unit_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
# - os: windows-latest
1919
# python-version: "3.7"
2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
- name: Set up Python
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626
cache: 'pip'

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ dipy
88
matplotlib
99
scienceplots
1010
cvxpy
11-
zenodo-get
11+
zenodo-get
12+
pytest
13+
tqdm
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SUPER-IVIM-DC
2+
3+
Provided here is a sample Jupyter notebook for the SUPER-IVIM-DC package.
4+
5+
Full README and usage instructions can be found here: https://github.com/TechnionComputationalMRILab/SUPER-IVIM-DC or https://pypi.org/project/super-ivim-dc/0.4.0/
6+
7+
Citation:
8+
9+
```
10+
@article{
11+
Korngut_Rotman_Afacan_Kurugol_Zaffrani-Reznikov_Nemirovsky-Rotman_Warfield_Freiman_2022,
12+
title={SUPER-IVIM-DC: Intra-voxel incoherent motion based fetal lung maturity assessment from limited DWI data using supervised learning coupled with data-consistency},
13+
volume={13432}, DOI={10.1007/978-3-031-16434-7_71},
14+
journal={Lecture Notes in Computer Science},
15+
author={Korngut, Noam and Rotman, Elad and Afacan, Onur and Kurugol, Sila and Zaffrani-Reznikov, Yael and Nemirovsky-Rotman, Shira and Warfield, Simon and Freiman, Moti},
16+
year={2022},
17+
pages={743–752}
18+
}
19+
```
20+
21+
[The paper is also available on ArXiv](https://arxiv.org/abs/2206.03820).
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import numpy as np\n",
10+
"working_dir: str = './working_dir'\n",
11+
"super_ivim_dc_filename: str = 'super_ivim_dc' # do not include .pt\n",
12+
"ivimnet_filename: str = 'ivimnet' # do not include .pt\n",
13+
"\n",
14+
"bvalues = np.array([0,15,30,45,60,75,90,105,120,135,150,175,200,400,600,800])\n",
15+
"snr = 10\n",
16+
"sample_size = 100"
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
"source": [
23+
"## Simulate"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"Run training, generate .pt files"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"from super_ivim_dc.train import train\n",
40+
"\n",
41+
"train(\n",
42+
" SNR=snr, \n",
43+
" bvalues=bvalues, \n",
44+
" super_ivim_dc=True,\n",
45+
" ivimnet=True,\n",
46+
" work_dir=working_dir,\n",
47+
" super_ivim_dc_filename=super_ivim_dc_filename,\n",
48+
" ivimnet_filename=ivimnet_filename,\n",
49+
" verbose=False\n",
50+
")"
51+
]
52+
},
53+
{
54+
"cell_type": "markdown",
55+
"metadata": {},
56+
"source": [
57+
"Files that will be created:\n",
58+
"\n",
59+
"- **super_ivim_dc_init.json** - contains the initial values used in the training\n",
60+
"- **super_ivim_dc_init_NRMSE.csv** - ???\n",
61+
"- **super_ivim_dc_init.pt** - the pytorch model"
62+
]
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"metadata": {},
67+
"source": [
68+
"## Test\n",
69+
"\n",
70+
"Generate a simulated signal + ..."
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"from super_ivim_dc.infer import test_infer\n",
80+
"\n",
81+
"test_infer(\n",
82+
" SNR=snr,\n",
83+
" bvalues=bvalues,\n",
84+
" work_dir=working_dir,\n",
85+
" super_ivim_dc_filename=super_ivim_dc_filename,\n",
86+
" ivimnet_filename=ivimnet_filename,\n",
87+
" save_figure_to=None, # if set to None, the figure will be shown in the notebook\n",
88+
" sample_size=sample_size,\n",
89+
")"
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"## Generate simulated signal"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": null,
102+
"metadata": {},
103+
"outputs": [],
104+
"source": [
105+
"from super_ivim_dc.IVIMNET import simulations\n",
106+
"\n",
107+
"IVIM_signal_noisy, Dt, f, Dp = simulations.sim_signal(\n",
108+
" SNR=snr, \n",
109+
" bvalues=bvalues, \n",
110+
" sims=sample_size\n",
111+
")\n",
112+
"\n",
113+
"Dt, f, Dp = np.squeeze(Dt), np.squeeze(f), np.squeeze(Dp)"
114+
]
115+
},
116+
{
117+
"cell_type": "markdown",
118+
"metadata": {},
119+
"source": [
120+
"Run inference on the simulated signal"
121+
]
122+
},
123+
{
124+
"cell_type": "code",
125+
"execution_count": null,
126+
"metadata": {},
127+
"outputs": [],
128+
"source": [
129+
"from super_ivim_dc.infer import infer_from_signal\n",
130+
"\n",
131+
"Dp_ivimnet, Dt_ivimnet, Fp_ivimnet, S0_ivimnet = infer_from_signal(\n",
132+
" signal=IVIM_signal_noisy, \n",
133+
" bvalues=bvalues,\n",
134+
" model_path=f\"{working_dir}/{ivimnet_filename}.pt\",\n",
135+
")\n",
136+
"\n",
137+
"Dp_superivimdc, Dt_superivimdc, Fp_superivimdc, S0_superivimdc = infer_from_signal(\n",
138+
" signal=IVIM_signal_noisy, \n",
139+
" bvalues=bvalues,\n",
140+
" model_path=f\"{working_dir}/{super_ivim_dc_filename}.pt\",\n",
141+
")"
142+
]
143+
}
144+
],
145+
"metadata": {
146+
"kernelspec": {
147+
"display_name": "super_ivim_dc",
148+
"language": "python",
149+
"name": "python3"
150+
},
151+
"language_info": {
152+
"codemirror_mode": {
153+
"name": "ipython",
154+
"version": 3
155+
},
156+
"file_extension": ".py",
157+
"mimetype": "text/x-python",
158+
"name": "python",
159+
"nbconvert_exporter": "python",
160+
"pygments_lexer": "ipython3",
161+
"version": "3.10.12"
162+
},
163+
"orig_nbformat": 4
164+
},
165+
"nbformat": 4,
166+
"nbformat_minor": 2
167+
}

0 commit comments

Comments
 (0)