Skip to content

Commit

Permalink
Merge pull request #37 from tcml-bme/main
Browse files Browse the repository at this point in the history
Sample notebook + README file for contributing SUPER IVIM DC package
  • Loading branch information
oliverchampion authored Feb 29, 2024
2 parents 2dbe31e + e0602fc commit fac848a
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/original/TCML_TechnionIIT/SUPER-IVIM-DC/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SUPER-IVIM-DC

Provided here is a sample Jupyter notebook for the SUPER-IVIM-DC package.

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/

Citation:

```
@article{
Korngut_Rotman_Afacan_Kurugol_Zaffrani-Reznikov_Nemirovsky-Rotman_Warfield_Freiman_2022,
title={SUPER-IVIM-DC: Intra-voxel incoherent motion based fetal lung maturity assessment from limited DWI data using supervised learning coupled with data-consistency},
volume={13432}, DOI={10.1007/978-3-031-16434-7_71},
journal={Lecture Notes in Computer Science},
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},
year={2022},
pages={743–752}
}
```

[The paper is also available on ArXiv](https://arxiv.org/abs/2206.03820).
167 changes: 167 additions & 0 deletions src/original/TCML_TechnionIIT/SUPER-IVIM-DC/sample.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"working_dir: str = './working_dir'\n",
"super_ivim_dc_filename: str = 'super_ivim_dc' # do not include .pt\n",
"ivimnet_filename: str = 'ivimnet' # do not include .pt\n",
"\n",
"bvalues = np.array([0,15,30,45,60,75,90,105,120,135,150,175,200,400,600,800])\n",
"snr = 10\n",
"sample_size = 100"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Simulate"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run training, generate .pt files"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from super_ivim_dc.train import train\n",
"\n",
"train(\n",
" SNR=snr, \n",
" bvalues=bvalues, \n",
" super_ivim_dc=True,\n",
" ivimnet=True,\n",
" work_dir=working_dir,\n",
" super_ivim_dc_filename=super_ivim_dc_filename,\n",
" ivimnet_filename=ivimnet_filename,\n",
" verbose=False\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Files that will be created:\n",
"\n",
"- **super_ivim_dc_init.json** - contains the initial values used in the training\n",
"- **super_ivim_dc_init_NRMSE.csv** - ???\n",
"- **super_ivim_dc_init.pt** - the pytorch model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Test\n",
"\n",
"Generate a simulated signal + ..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from super_ivim_dc.infer import test_infer\n",
"\n",
"test_infer(\n",
" SNR=snr,\n",
" bvalues=bvalues,\n",
" work_dir=working_dir,\n",
" super_ivim_dc_filename=super_ivim_dc_filename,\n",
" ivimnet_filename=ivimnet_filename,\n",
" save_figure_to=None, # if set to None, the figure will be shown in the notebook\n",
" sample_size=sample_size,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Generate simulated signal"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from super_ivim_dc.IVIMNET import simulations\n",
"\n",
"IVIM_signal_noisy, Dt, f, Dp = simulations.sim_signal(\n",
" SNR=snr, \n",
" bvalues=bvalues, \n",
" sims=sample_size\n",
")\n",
"\n",
"Dt, f, Dp = np.squeeze(Dt), np.squeeze(f), np.squeeze(Dp)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run inference on the simulated signal"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from super_ivim_dc.infer import infer_from_signal\n",
"\n",
"Dp_ivimnet, Dt_ivimnet, Fp_ivimnet, S0_ivimnet = infer_from_signal(\n",
" signal=IVIM_signal_noisy, \n",
" bvalues=bvalues,\n",
" model_path=f\"{working_dir}/{ivimnet_filename}.pt\",\n",
")\n",
"\n",
"Dp_superivimdc, Dt_superivimdc, Fp_superivimdc, S0_superivimdc = infer_from_signal(\n",
" signal=IVIM_signal_noisy, \n",
" bvalues=bvalues,\n",
" model_path=f\"{working_dir}/{super_ivim_dc_filename}.pt\",\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "super_ivim_dc",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit fac848a

Please sign in to comment.