-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1ed37e
commit 301a153
Showing
6 changed files
with
198 additions
and
120 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
.github/workflows/test_pipeline_dwi_preprocessing_using_phase_diff.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: DWI Preprocessing Using Phase Diff Pipelines Tests | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
pull_request: | ||
branches: [dev] | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | ||
cancel-in-progress: true | ||
|
||
env: | ||
POETRY_VERSION: '1.6.1' | ||
PYTHON_VERSION: '3.10' | ||
|
||
jobs: | ||
test-pipelines-dwi-preprocessing-using-phase-diff-MacOS: | ||
runs-on: | ||
- self-hosted | ||
- macOS | ||
- aramis | ||
timeout-minutes: 720 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: snok/install-poetry@v1 | ||
- name: Run tests for dwi preprocessing using phase diff pipeline | ||
run: ./scripts/run_nonregression.sh | ||
env: | ||
TEST: dwi/preprocessing/using_phase_diff | ||
MODALITY: dwi_preprocessing_using_phase_diff | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
test-pipelines-dwi-preprocessing-using-phase-diff-Linux: | ||
runs-on: | ||
- self-hosted | ||
- Linux | ||
timeout-minutes: 720 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: snok/install-poetry@v1 | ||
with: | ||
version: ${{ env.POETRY_VERSION }} | ||
virtualenvs-create: false | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: poetry | ||
- name: Run tests for dwi preprocessing using phase diff pipeline | ||
run: ./scripts/run_nonregression.sh | ||
env: | ||
TEST: dwi/preprocessing/using_phase_diff | ||
MODALITY: dwi_preprocessing_using_phase_diff | ||
WORKSPACE: ${{ github.workspace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...nregression/pipelines/dwi/preprocessing/using_phase_diff/test_full_phase_diff_pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from os import fspath | ||
from pathlib import Path | ||
from test.nonregression.testing_tools import configure_paths, similarity_measure | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.slow | ||
def test_dwi_preprocessing_using_phase_diff_field_map(cmdopt, tmp_path): | ||
base_dir = Path(cmdopt["input"]) | ||
working_dir = Path(cmdopt["wd"]) | ||
input_dir, tmp_dir, ref_dir = configure_paths( | ||
base_dir, | ||
tmp_path, | ||
"DWIPreprocessingUsingPhaseDiffFieldmap", | ||
) | ||
run_dwi_preprocessing_using_phase_diff_field_map( | ||
input_dir, tmp_dir, ref_dir, working_dir | ||
) | ||
|
||
|
||
def run_dwi_preprocessing_using_phase_diff_field_map( | ||
input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path | ||
) -> None: | ||
from clinica.pipelines.dwi_preprocessing_using_fmap.dwi_preprocessing_using_phasediff_fmap_pipeline import ( | ||
DwiPreprocessingUsingPhaseDiffFMap, | ||
) | ||
|
||
caps_dir = output_dir / "caps" | ||
tsv = input_dir / "subjects.tsv" | ||
|
||
parameters = { | ||
"initrand": True, | ||
"low_bval": 5, | ||
"use_cuda": False, | ||
"delete_cache": True, | ||
} | ||
pipeline = DwiPreprocessingUsingPhaseDiffFMap( | ||
bids_directory=fspath(input_dir / "bids"), | ||
caps_directory=fspath(caps_dir), | ||
tsv_file=fspath(tsv), | ||
base_dir=fspath(working_dir), | ||
parameters=parameters, | ||
) | ||
pipeline.build() | ||
pipeline.run(plugin="MultiProc", plugin_args={"n_procs": 4}, bypass_check=True) | ||
|
||
out_file = fspath( | ||
caps_dir | ||
/ "subjects" | ||
/ "sub-PREVDEMALS0010025PG" | ||
/ "ses-M000" | ||
/ "dwi" | ||
/ "preprocessing" | ||
/ "sub-PREVDEMALS0010025PG_ses-M000_dwi_space-b0_preproc.nii.gz" | ||
) | ||
ref_file = fspath( | ||
ref_dir / "sub-PREVDEMALS0010025PG_ses-M000_dwi_space-b0_preproc.nii.gz" | ||
) | ||
|
||
assert similarity_measure(out_file, ref_file, 0.95) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
test/nonregression/pipelines/dwi/preprocessing/using_t1/test_full_t1_pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Non regression test for the full DWIPreprocessingUsingT1 pipeline.""" | ||
|
||
from os import fspath | ||
from pathlib import Path | ||
from test.nonregression.testing_tools import ( | ||
configure_paths, | ||
similarity_measure_large_nifti, | ||
) | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.slow | ||
def test_dwi_preprocessing_using_t1(cmdopt, tmp_path): | ||
base_dir = Path(cmdopt["input"]) | ||
working_dir = Path(cmdopt["wd"]) | ||
input_dir, tmp_dir, ref_dir = configure_paths( | ||
base_dir, tmp_path, "DWIPreprocessingUsingT1" | ||
) | ||
run_dwi_preprocessing_using_t1(input_dir, tmp_dir, ref_dir, working_dir) | ||
|
||
|
||
def run_dwi_preprocessing_using_t1( | ||
input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path | ||
) -> None: | ||
from clinica.pipelines.dwi_preprocessing_using_t1.dwi_preprocessing_using_t1_pipeline import ( | ||
DwiPreprocessingUsingT1, | ||
) | ||
|
||
caps_dir = output_dir / "caps" | ||
tsv = input_dir / "subjects.tsv" | ||
|
||
parameters = { | ||
"initrand": True, | ||
"low_bval": 5, | ||
"use_cuda": False, | ||
"random_seed": 42, | ||
} | ||
pipeline = DwiPreprocessingUsingT1( | ||
bids_directory=fspath(input_dir / "bids"), | ||
caps_directory=fspath(caps_dir), | ||
tsv_file=fspath(tsv), | ||
base_dir=fspath(working_dir), | ||
parameters=parameters, | ||
) | ||
pipeline.build() | ||
pipeline.run(plugin="MultiProc", plugin_args={"n_procs": 4}, bypass_check=True) | ||
|
||
output_folder = ( | ||
caps_dir | ||
/ "subjects" | ||
/ "sub-PREVDEMALS0010025PG" | ||
/ "ses-M000" | ||
/ "dwi" | ||
/ "preprocessing" | ||
) | ||
out_preprocessed_image = ( | ||
output_folder / "sub-PREVDEMALS0010025PG_ses-M000_dwi_space-T1w_preproc.nii.gz" | ||
) | ||
ref_preprocessed_image = ( | ||
ref_dir / "sub-PREVDEMALS0010025PG_ses-M000_dwi_space-T1w_preproc.nii.gz" | ||
) | ||
|
||
assert similarity_measure_large_nifti( | ||
out_preprocessed_image, ref_preprocessed_image, 0.99 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters