Skip to content

Commit 06167e7

Browse files
authored
Merge branch 'main' into created_repostatus/statistics
2 parents 6ab39b5 + 2c3787e commit 06167e7

File tree

20 files changed

+3173
-92
lines changed

20 files changed

+3173
-92
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Download Artifact
3+
description: Download artifact from the same or different workflow
4+
5+
inputs:
6+
name:
7+
description: Artifact to be downloaded
8+
required: true
9+
type: string
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Download Artifact
15+
uses: actions/github-script@v6
16+
with:
17+
script: |
18+
var inputs = ${{ toJSON(inputs) }}
19+
var artifactName = inputs['name']
20+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
run_id: context.payload.workflow_run.id,
24+
});
25+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
26+
return artifact.name == artifactName
27+
})[0];
28+
let download = await github.rest.actions.downloadArtifact({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
artifact_id: matchArtifact.id,
32+
archive_format: 'zip',
33+
});
34+
let fs = require('fs');
35+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}.zip`, Buffer.from(download.data));
36+
37+
- name: 'Unzip artifact'
38+
run: unzip ${{ inputs.name }}.zip
39+
shell: bash

.github/workflows/analysis.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ jobs:
1818
uses: actions/setup-python@v5
1919
with:
2020
python-version: "3.11"
21-
cache: 'pip'
22-
# - name: Cache virtualenv
23-
# uses: actions/cache@v3
24-
# with:
25-
# key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('requirements.txt') }}
26-
# path: .venv
21+
- name: Cache pip
22+
uses: actions/cache@v3
23+
id: pip-cache
24+
with:
25+
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}
26+
path: ${{ env.pythonLocation }}
27+
if: steps.pip-cache.outputs.cache-hit != 'true'
28+
2729
- name: Install dependencies
2830
run: |
29-
python -m venv .venv
30-
source .venv/bin/activate
31-
python -m pip install -r requirements.txt
32-
python -m pip install pytest
31+
pip install -r requirements.txt
32+
3333
- name: Read algorithms
3434
id: algorithms
3535
run: |
@@ -58,21 +58,16 @@ jobs:
5858
uses: actions/setup-python@v5
5959
with:
6060
python-version: "3.11"
61-
cache: 'pip'
62-
# - name: Cache virtualenv
63-
# uses: actions/cache@v3
64-
# with:
65-
# key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('requirements.txt') }}
66-
# path: .venv
67-
- name: Install dependencies
68-
run: |
69-
python -m venv .venv
70-
source .venv/bin/activate
71-
python -m pip install -r requirements.txt
72-
python -m pip install pytest
61+
if: steps.pip-cache.outputs.cache-hit != 'true'
62+
- name: Restore cache
63+
id: python-cache
64+
uses: actions/cache@v3
65+
with:
66+
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}
67+
path: ${{ env.pythonLocation }}
68+
7369
- name: Generate fitting data
7470
run: |
75-
source .venv/bin/activate
7671
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
7772
- name: Upload raw data
7873
uses: actions/upload-artifact@v3

.github/workflows/documentation.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build & Deploy Documentation
2+
3+
on:
4+
workflow_run:
5+
workflows: [Algorithm Analysis]
6+
types:
7+
- completed
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Setup Pages
18+
uses: actions/configure-pages@v4
19+
- name: Set up Python
20+
id: setup_python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.11"
24+
- name: Cache pip
25+
uses: actions/cache@v3
26+
id: pip-cache
27+
with:
28+
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}
29+
path: ${{ env.pythonLocation }}
30+
if: steps.pip-cache.outputs.cache-hit != 'true'
31+
32+
- name: Install dependencies
33+
run: |
34+
pip install -r requirements.txt
35+
36+
# Action to download artifacts from a different workflow (analysis.yml)
37+
- name: 'Download artifact'
38+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
39+
uses: ./.github/actions/download-artifact
40+
with:
41+
name: 'Figures'
42+
43+
- name: Build html
44+
run: |
45+
mkdir docs/_static
46+
mv *.pdf docs/_static/
47+
sphinx-apidoc -o docs src
48+
cd docs/
49+
make html
50+
51+
- name: Upload docs artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: 'docs/_build/html'
55+
56+
deploy:
57+
needs: build
58+
environment:
59+
name: github-pages
60+
url: ${{ steps.deployment.outputs.page_url }}
61+
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Deploy to GitHub Pages
65+
id: deployment
66+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ __pycache__/
99
*.mat
1010
*.raw
1111
bvals.txt
12+
download
13+
md5sums.txt
14+
*.gz
15+
*.zip
16+
*.tmp
17+
1218
# Unit test / coverage reports
1319
.tox/
1420
.coverage

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ The **utils** folder contains various helpful tools.
3131

3232
## View Testing Reports
3333
[![Unit tests](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/unit_test.yml/badge.svg?branch=main)](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/unit_test.yml)
34-
[![Algorithm Analysis](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/analysis.yml/badge.svg?branch=main)](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/analysis.yml)
34+
[![Algorithm Analysis](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/analysis.yml/badge.svg?branch=main)](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/analysis.yml)
35+
[![Build & Deploy Documentation](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/documentation.yml/badge.svg?branch=main)](https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/actions/workflows/documentation.yml)

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
import os
10+
import sys
11+
12+
sys.path.insert(0, os.path.abspath(".."))
13+
14+
project = 'TF2.4 IVIM MRI Code Collection'
15+
copyright = '2024, OSIPI'
16+
author = 'OSIPI team'
17+
18+
# -- General configuration ---------------------------------------------------
19+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20+
21+
extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"]
22+
23+
templates_path = ['_templates']
24+
exclude_patterns = ['Thumbs.db', '.DS_Store']
25+
26+
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
27+
html_show_sphinx = False
28+
29+
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
30+
html_show_copyright = False
31+
32+
# -- Options for HTML output -------------------------------------------------
33+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
34+
35+
html_theme = 'sphinx_rtd_theme'
36+
html_static_path = ['_static']

docs/figures.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Algorithm Analysis Figures
2+
===========
3+
4+
.. raw:: html
5+
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
<head>
9+
<meta charset="UTF-8">
10+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
11+
<title>Algorithm Analysis Figures</title>
12+
<style>
13+
14+
embed {
15+
width: 90%;
16+
margin-bottom: 4rem;
17+
height: 100vh;
18+
}
19+
</style>
20+
</head>
21+
<body>
22+
<h4>Diffusion grid for limited algorithms:</h4>
23+
<embed src="_static/D_limited.pdf" type="application/pdf" frameborder="0" scrolling="auto">
24+
<h4>Diffusion grid for all algorithms:</h4>
25+
<embed src="_static/D.pdf" type="application/pdf" frameborder="0" scrolling="auto">
26+
27+
<h4>Perfusion grid for limited algorithms:</h4>
28+
<embed src="_static/Dp_limited.pdf" type="application/pdf" frameborder="0" scrolling="auto">
29+
<h4>Perfusion grid for all algorithms:</h4>
30+
<embed src="_static/Dp.pdf" type="application/pdf" frameborder="0" scrolling="auto">
31+
32+
<h4>Perfusion fraction grid for limited algorithms:</h4>
33+
<embed src="_static/f_limited.pdf" type="application/pdf" frameborder="0" scrolling="auto">
34+
<h4>Perfusion fraction grid for all algorithms:</h4>
35+
<embed src="_static/f.pdf" type="application/pdf" frameborder="0" scrolling="auto">
36+
37+
<h4>Fitted curves:</h4>
38+
<embed src="_static/fitted_curves.pdf" type="application/pdf" frameborder="0" scrolling="auto">
39+
<h4>Curve plot:</h4>
40+
<embed src="_static/curve_plot.pdf" type="application/pdf" frameborder="0" scrolling="auto">
41+
<h4>Algorithm Fitting duration:</h4>
42+
<embed src="_static/durations.pdf" type="application/pdf" frameborder="0" scrolling="auto">
43+
44+
</body>
45+
</html>

docs/index.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. TF2.4 IVIM MRI Code Collection documentation master file, created by
2+
sphinx-quickstart on Wed Mar 6 00:06:13 2024.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to TF2.4 IVIM MRI Code Collection's documentation!
7+
==========================================================
8+
9+
.. toctree::
10+
:maxdepth: 4
11+
:caption: Contents:
12+
13+
figures
14+
modules
15+
16+
Indices and tables
17+
==================
18+
19+
* :ref:`modindex`

phantoms/MR_XCAT_qMRI/README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
# MR_XCAT_qMRI
1+
# 4D IVIM Phantom Generator
2+
3+
A command-line tool for generating a 4D IVIM (Intravoxel Incoherent Motion) phantom as a NIfTI file.
4+
5+
## Usage
6+
7+
```sh
8+
python sim_vim_sig.py [-h] [-b BVALUE [BVALUE ...] | -f FILE] [-n NOISE] [-m] [-i]
9+
```
10+
11+
## Arguments
12+
13+
- `-b`, `--bvalue` : B values (list of numbers)
14+
- `-f`, `--bvalues-file` : JSON file containing the B values (default: b_values.json)
15+
- `-n`, `--noise` : Noise level (default: 0.0005)
16+
- `-m`, `--motion` : Enable motion flag (default: False)
17+
- `-i`, `--interleaved` : Enable interleaved flag (default: False)
18+
19+
**Note:** Either provide `--bvalue` or `--bvalues-file`, not both.
20+
21+
If neither `--bvalues-file` nor `--bvalue` is provided, the script will use the default `b_values.json` file.
22+
23+
## Customizing B Values
24+
25+
You can customize the B values by editing the `b_values.json` file. Here's an example of the default format:
26+
27+
```json
28+
{
29+
"original": [0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 30.0, 50.0, 75.0, 100.0, 150.0, 250.0, 350.0, 400.0, 550.0, 700.0, 850.0, 1000.0],
30+
"one": [0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 30.0, 50.0, 75.0, 100.0, 150.0, 250.0, 350.0, 400.0, 550.0, 700.0, 850.0, 1000.0, 1100.0, 1200.0],
31+
"two": [0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 30.0, 50.0, 75.0, 100.0, 150.0, 250.0, 350.0, 400.0, 500.0, 700.0, 800.0, 1000.0, 1100.0, 1200.0],
32+
"three": [0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 30.0, 50.0, 75.0, 100.0, 150.0, 250.0, 350.0, 450.0, 550.0, 675.0, 800.0],
33+
"four": [0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 30.0, 50.0, 75.0, 100.0, 150.0, 250.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0]
34+
}
35+
```
36+
37+
You can add or remove values as needed for your simulation. Here are the effects of customizing the B values for each of the generic profiles (`generic.json`, `generic_one.json`, `generic_two.json`, `generic_three.json`, `generic_four.json`):
38+
39+
The default `generic_<custom_name>.json` file can be found in the following location:
40+
41+
```
42+
TF2.4_IVIM-MRI_CodeCollection/tests/IVIMmodels/unit_tests
43+
```
44+
45+
## Running the Script
46+
47+
To run the script, you can add the following line to your shell configuration file (e.g., `.bashrc` or `.zshrc`) to include the necessary directory in your `PYTHONPATH`:
48+
49+
```sh
50+
export PYTHONPATH=$PYTHONPATH:~/TF2.4_IVIM-MRI_CodeCollection
51+
```
52+
53+
Replace `~/TF2.4_IVIM-MRI_CodeCollection` with the actual path to the directory containing the script.
54+
55+
## Example
56+
57+
```sh
58+
python sim_ivim_sig.py -n 0.0001 -m
59+
```
60+
61+
This command will generate a 4D IVIM phantom using B values from the default `b_values.json` file, with a noise level of 0.0001 and motion enabled.

0 commit comments

Comments
 (0)