From e0602fc5a8f00cec4f470106fcc478e541b7a7aa Mon Sep 17 00:00:00 2001 From: "ang.a" Date: Mon, 26 Feb 2024 12:38:29 +0200 Subject: [PATCH 1/8] added super ivim dc --- .../TCML_TechnionIIT/SUPER-IVIM-DC/README.md | 21 +++ .../SUPER-IVIM-DC/sample.ipynb | 167 ++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 src/original/TCML_TechnionIIT/SUPER-IVIM-DC/README.md create mode 100644 src/original/TCML_TechnionIIT/SUPER-IVIM-DC/sample.ipynb diff --git a/src/original/TCML_TechnionIIT/SUPER-IVIM-DC/README.md b/src/original/TCML_TechnionIIT/SUPER-IVIM-DC/README.md new file mode 100644 index 0000000..fe191ef --- /dev/null +++ b/src/original/TCML_TechnionIIT/SUPER-IVIM-DC/README.md @@ -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). diff --git a/src/original/TCML_TechnionIIT/SUPER-IVIM-DC/sample.ipynb b/src/original/TCML_TechnionIIT/SUPER-IVIM-DC/sample.ipynb new file mode 100644 index 0000000..90dae5b --- /dev/null +++ b/src/original/TCML_TechnionIIT/SUPER-IVIM-DC/sample.ipynb @@ -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 +} From dd0216285053907076359b491b080cf7d356e486 Mon Sep 17 00:00:00 2001 From: AhmedBasem Date: Tue, 27 Feb 2024 23:31:36 +0200 Subject: [PATCH 2/8] Add pytest to requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index acb0486..1f53cb7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ joblib dipy matplotlib scienceplots -cvxpy \ No newline at end of file +cvxpy +pytest \ No newline at end of file From 35848fc0126d6508485c1547321094e3379ca571 Mon Sep 17 00:00:00 2001 From: AhmedBasem Date: Tue, 27 Feb 2024 23:39:27 +0200 Subject: [PATCH 3/8] Add tqdm to requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1f53cb7..382e3c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ dipy matplotlib scienceplots cvxpy -pytest \ No newline at end of file +pytest +tqdm \ No newline at end of file From 92a80d61cfca322da49d126dcd598996fca92668 Mon Sep 17 00:00:00 2001 From: Unique-Usman Date: Fri, 1 Mar 2024 15:20:53 +0530 Subject: [PATCH 4/8] Updated the github workflow actions Node.js 16 actions are deprecated. Updated the github actions to use Node.js 20 Fixes #42 - [ ] Self-review of changed code - [ ] Added automated tests where applicable - [ ] Update Docs & Guides --- .github/workflows/analysis.yml | 26 +++++++++++++------------- .github/workflows/unit_test.yml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 53f6257..f8da4b1 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -12,10 +12,10 @@ jobs: outputs: # here we use the outputs from steps, and set outputs for the job `configure` algorithms: ${{ steps.algorithms.outputs.algorithms }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python id: setup_python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" cache: 'pip' @@ -53,9 +53,9 @@ jobs: algorithm: ${{fromJson(needs.algorithms.outputs.algorithms).algorithms}} SNR: [10, 30, 50, 100, 200] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" cache: 'pip' @@ -75,7 +75,7 @@ jobs: source .venv/bin/activate python -m pytest -m slow --selectAlgorithm ${{ matrix.algorithm }} --saveFileName test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv --SNR ${{ matrix.SNR }} --fitCount 300 --saveDurationFileName test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv - name: Upload raw data - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Working_Data retention-days: 1 @@ -88,7 +88,7 @@ jobs: needs: build steps: - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: artifacts - name: Merge fitting results @@ -100,7 +100,7 @@ jobs: head -n 1 $(ls artifacts/Working_Data/test_duration_*.csv | head -n 1) > test_duration.csv tail -q -n +2 artifacts/Working_Data/test_duration_*.csv >> test_duration.csv - name: Upload merged artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Data path: | @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest needs: merge steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up R uses: r-lib/actions/setup-r@v2 with: @@ -126,13 +126,13 @@ jobs: any::data.table any::ggplot2 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Data - name: Generate figures run: Rscript --vanilla tests/IVIMmodels/unit_tests/analyze.r test_output.csv test_duration.csv - name: Upload figures - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: always() with: name: Figures @@ -151,7 +151,7 @@ jobs: runs-on: ubuntu-latest needs: merge steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up R uses: r-lib/actions/setup-r@v2 with: @@ -163,7 +163,7 @@ jobs: any::tidyverse any::assertr - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: Data - name: Test against previous results @@ -175,4 +175,4 @@ jobs: name: Comparison path: | test_reference.csv - test_results.csv \ No newline at end of file + test_results.csv diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 95b9b9d..3488007 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -18,9 +18,9 @@ jobs: # - os: windows-latest # python-version: "3.7" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: 'pip' From 831c7c538187e9bc0c08e1f8e4a97b5e69070884 Mon Sep 17 00:00:00 2001 From: Unique-Usman Date: Sat, 2 Mar 2024 00:06:38 +0530 Subject: [PATCH 5/8] Added my branch for to iterate over the solution --- .github/workflows/analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index f8da4b1..a5559eb 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -5,6 +5,7 @@ on: branches: - 'main' - 'analysis/**' + - 'usman' jobs: algorithms: From a643f59f697becf30eaf38118b9d36236167a27d Mon Sep 17 00:00:00 2001 From: Unique-Usman Date: Sat, 2 Mar 2024 00:22:24 +0530 Subject: [PATCH 6/8] Downgraded actions/upload-artifact@v4 to v3 The actions/upload-artifact@v4 is not yet supported in GHES See actions/upload-artifact#478 --- .github/workflows/analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index a5559eb..ff0fdd6 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -76,7 +76,7 @@ jobs: source .venv/bin/activate python -m pytest -m slow --selectAlgorithm ${{ matrix.algorithm }} --saveFileName test_output_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv --SNR ${{ matrix.SNR }} --fitCount 300 --saveDurationFileName test_duration_${{ matrix.algorithm }}_${{ matrix.SNR }}.csv - name: Upload raw data - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: Working_Data retention-days: 1 @@ -101,7 +101,7 @@ jobs: head -n 1 $(ls artifacts/Working_Data/test_duration_*.csv | head -n 1) > test_duration.csv tail -q -n +2 artifacts/Working_Data/test_duration_*.csv >> test_duration.csv - name: Upload merged artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: Data path: | @@ -133,7 +133,7 @@ jobs: - name: Generate figures run: Rscript --vanilla tests/IVIMmodels/unit_tests/analyze.r test_output.csv test_duration.csv - name: Upload figures - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 if: always() with: name: Figures From bde1bebd719d447d264e9e1bb98972704318851b Mon Sep 17 00:00:00 2001 From: Unique-Usman Date: Sat, 2 Mar 2024 00:28:57 +0530 Subject: [PATCH 7/8] Downgraded download-artifact See actions/upload-artifact#478 --- .github/workflows/analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index ff0fdd6..0199ce1 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -89,7 +89,7 @@ jobs: needs: build steps: - name: Download artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: path: artifacts - name: Merge fitting results @@ -127,7 +127,7 @@ jobs: any::data.table any::ggplot2 - name: Download artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: Data - name: Generate figures @@ -164,7 +164,7 @@ jobs: any::tidyverse any::assertr - name: Download artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: Data - name: Test against previous results From a147635df817b217f0ef774f4a303af376d2e28c Mon Sep 17 00:00:00 2001 From: Unique-Usman Date: Sat, 2 Mar 2024 01:05:20 +0530 Subject: [PATCH 8/8] Downgraded upload and download-artifact@v4 to v3 The actions/upload-artifact@v4 actions/download-artifact@v4 and is not yet supported in GHES See actions/upload-artifact#478 --- .github/workflows/analysis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 0199ce1..a15ba6a 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -5,7 +5,6 @@ on: branches: - 'main' - 'analysis/**' - - 'usman' jobs: algorithms: