From 19f20f82566642f6f53e4f10deb8c95743f26fca Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 24 Sep 2024 12:41:30 -0400 Subject: [PATCH 1/3] CI: Try running jobs with xdist --- .circleci/config.yml | 2 +- .github/workflows/unittests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 903c2aa56d..6d842d2389 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -341,7 +341,7 @@ jobs: nipreps/sdcflows:latest \ pytest -v --junit-xml=/out/pytest.xml \ --cov sdcflows --cov-report xml:/out/unittests.xml \ - sdcflows/ + -n auto sdcflows/ - save_cache: key: workdir-v3-{{ .Branch }}-{{ .BuildNum }} paths: diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 06ec4b298f..716c30d92c 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -175,7 +175,7 @@ jobs: run: | export LD_LIBRARY_PATH=/usr/lib/fsl/5.0:$LD_LIBRARY_PATH export PATH=$ANTSPATH:${AFNI_HOME}:/usr/lib/fsl/5.0:$PATH - pytest -v --cov sdcflows --cov-report xml:cov.xml --doctest-modules sdcflows + pytest -v --cov sdcflows --cov-report xml:cov.xml --doctest-modules -n auto sdcflows - uses: codecov/codecov-action@v4 with: From 9b52d0584cbbe1b1599c3240a8ba931c211c30dc Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 24 Sep 2024 13:04:16 -0400 Subject: [PATCH 2/3] doctest: Avoid module-level testsetup, which conflicts with xdist --- sdcflows/utils/epimanip.py | 20 +++++++++++++------- sdcflows/workflows/fit/syn.py | 11 ----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/sdcflows/utils/epimanip.py b/sdcflows/utils/epimanip.py index 6af5be7f21..a16e3a952d 100644 --- a/sdcflows/utils/epimanip.py +++ b/sdcflows/utils/epimanip.py @@ -23,13 +23,6 @@ """ Manipulation of EPI data. -.. testsetup:: - - >>> tmpdir = getfixture('tmpdir') - >>> tmp = tmpdir.chdir() # changing to a temporary directory - >>> nb.Nifti1Image(np.zeros((90, 90, 60)), None, None).to_filename( - ... tmpdir.join('epi.nii.gz').strpath) - """ @@ -42,6 +35,15 @@ def get_trt(in_meta, in_file=None): The first option is that a ``TotalReadoutTime`` field is found in the JSON sidecar: + .. testsetup:: + + >>> cwd = os.getcwd() + >>> tmpdir = getfixture('tmpdir') + >>> tmp = tmpdir.chdir() # changing to a temporary directory + >>> nb.Nifti1Image(np.zeros((90, 90, 60)), None, None).to_filename( + ... tmpdir.join('epi.nii.gz').strpath) + + >>> meta = {'TotalReadoutTime': 0.05251} >>> get_trt(meta) 0.05251 @@ -157,6 +159,10 @@ def get_trt(in_meta, in_file=None): Traceback (most recent call last): ValueError: + .. testcleanup:: + + >>> os.chdir(cwd) + .. admonition:: Thanks With thanks to Dr. Rorden for his thorough diff --git a/sdcflows/workflows/fit/syn.py b/sdcflows/workflows/fit/syn.py index a0783a6deb..5884173b9e 100644 --- a/sdcflows/workflows/fit/syn.py +++ b/sdcflows/workflows/fit/syn.py @@ -22,17 +22,6 @@ # """ Estimating the susceptibility distortions without fieldmaps. - -.. testsetup:: - - >>> tmpdir = getfixture('tmpdir') - >>> tmp = tmpdir.chdir() # changing to a temporary directory - >>> data = np.zeros((10, 10, 10, 1, 3)) - >>> data[..., 1] = 1 - >>> nb.Nifti1Image(data, None, None).to_filename( - ... tmpdir.join('field.nii.gz').strpath) - - """ from nipype.pipeline import engine as pe from nipype.interfaces import utility as niu From 6a9da18029e7c0f54e9162a5b211f37b43f9159b Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 16 Sep 2024 15:07:52 -0400 Subject: [PATCH 3/3] fix: Only fit high-frequency spline for SyN-SDC --- sdcflows/workflows/fit/syn.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sdcflows/workflows/fit/syn.py b/sdcflows/workflows/fit/syn.py index 5884173b9e..447f1878b4 100644 --- a/sdcflows/workflows/fit/syn.py +++ b/sdcflows/workflows/fit/syn.py @@ -127,9 +127,7 @@ def init_syn_sdc_wf( from ...interfaces.bspline import ( ApplyCoeffsField, BSplineApprox, - DEFAULT_LF_ZOOMS_MM, DEFAULT_HF_ZOOMS_MM, - DEFAULT_ZOOMS_MM, ) from ...interfaces.brainmask import BinaryDilation, Union @@ -261,9 +259,10 @@ def init_syn_sdc_wf( name="bs_filter", ) bs_filter.interface._always_run = debug - bs_filter.inputs.bs_spacing = ( - [DEFAULT_LF_ZOOMS_MM, DEFAULT_HF_ZOOMS_MM] if not sloppy else [DEFAULT_ZOOMS_MM] - ) + bs_filter.inputs.bs_spacing = [DEFAULT_HF_ZOOMS_MM] + + if sloppy: + bs_filter.inputs.zooms_min = 4.0 workflow.connect([ (inputnode, readout_time, [(("epi_ref", _pop), "in_file"),