Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only fit high-frequency spline for SyN-SDC #457

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading