Skip to content

Commit

Permalink
Merge pull request nipreps#457 from effigies/fix/one-layer-syn
Browse files Browse the repository at this point in the history
fix: Only fit high-frequency spline for SyN-SDC
  • Loading branch information
effigies authored Sep 24, 2024
2 parents 08e198f + 6a9da18 commit 82f419b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 13 additions & 7 deletions sdcflows/utils/epimanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"""


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 4 additions & 16 deletions sdcflows/workflows/fit/syn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -138,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

Expand Down Expand Up @@ -272,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"),
Expand Down

0 comments on commit 82f419b

Please sign in to comment.