Skip to content

Commit fac848a

Browse files
Merge pull request #37 from tcml-bme/main
Sample notebook + README file for contributing SUPER IVIM DC package
2 parents 2dbe31e + e0602fc commit fac848a

File tree

2 files changed

+188
-0
lines changed

2 files changed

+188
-0
lines changed
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)