Skip to content

Commit

Permalink
Merge pull request #473 from effigies/mnt/nireports
Browse files Browse the repository at this point in the history
rf: Transition from niworkflows reporting interfaces
  • Loading branch information
effigies authored Dec 19, 2024
2 parents 03076bd + 4defca7 commit a50506a
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"nilearn",
"nipy",
"nitime",
"nireports",
"pandas",
"seaborn",
"skimage",
Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ sphinx >= 7.2.2
sphinx-argparse
sphinxcontrib-apidoc
templateflow
traits < 6.4
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies = [
"nibabel >= 3.0",
"nipype >= 1.8.5",
"migas >= 0.4.0",
"nireports >= 24.1.0",
"niworkflows >= 1.7.0",
"nitransforms >= 24.1.0",
"numpy >= 1.22",
Expand Down
2 changes: 1 addition & 1 deletion sdcflows/interfaces/reportlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from nilearn.image import threshold_img, load_img
from niworkflows import NIWORKFLOWS_LOG
from niworkflows.utils.images import rotation2canonical, rotate_affine
from niworkflows.viz.utils import cuts_from_bbox, compose_view
from nireports.reportlets.utils import cuts_from_bbox, compose_view
from nipype.interfaces.base import File, isdefined, traits
from nipype.interfaces.mixins import reporting

Expand Down
13 changes: 1 addition & 12 deletions sdcflows/tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from nitransforms.linear import LinearTransformsMapping
from skimage.morphology import ball
import scipy.ndimage as nd
from nireports.interfaces.reporting.base import SimpleBeforeAfterRPT as SimpleBeforeAfter

from sdcflows import transform as tf
from sdcflows.interfaces.bspline import bspline_grid
Expand Down Expand Up @@ -120,10 +121,6 @@ def test_displacements_field(tmpdir, testdata_dir, outdir, pe_dir, rotation, fli
assert np.all((np.sqrt(((ours - theirs) ** 2).sum()) / ours.size) < 1e-1)

if outdir:
from niworkflows.interfaces.reportlets.registration import (
SimpleBeforeAfterRPT as SimpleBeforeAfter,
)

orientation = "".join([ax[bool(f)] for ax, f in zip(("RL", "AP", "SI"), flip)])

SimpleBeforeAfter(
Expand Down Expand Up @@ -204,10 +201,6 @@ def test_apply_transform(tmpdir, outdir, datadir, pe0, hmc, fmap):
error = np.sqrt(((corrected.dataobj - realigned.dataobj) ** 2))

if outdir:
from niworkflows.interfaces.reportlets.registration import (
SimpleBeforeAfterRPT as SimpleBeforeAfter,
)

# Do not include the first volume in the average to enhance differences
realigned_data = np.asanyarray(corrected.dataobj)[..., 1:].mean(-1)
realigned_data[realigned_data < 0] = 0
Expand Down Expand Up @@ -241,10 +234,6 @@ def test_apply_transform(tmpdir, outdir, datadir, pe0, hmc, fmap):
error_margin = 200 # test oracle is pretty bad here - needs revision.

if outdir:
from niworkflows.interfaces.reportlets.registration import (
SimpleBeforeAfterRPT as SimpleBeforeAfter,
)

# Do not include the first volume in the average to enhance differences
realigned_data = np.asanyarray(corrected.dataobj)[..., 1:].mean(-1)
realigned_data[realigned_data < 0] = 0
Expand Down
2 changes: 1 addition & 1 deletion sdcflows/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def plot_registration(
import matplotlib.pyplot as plt
from nilearn.plotting import plot_anat
from svgutils.transform import SVGFigure
from niworkflows.viz.utils import robust_set_limits, extract_svg, SVGNS
from nireports.reportlets.utils import robust_set_limits, extract_svg, SVGNS

plot_params = plot_params or {}

Expand Down
4 changes: 1 addition & 3 deletions sdcflows/workflows/apply/tests/test_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import pytest
from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu
from nireports.interfaces.reporting.base import SimpleBeforeAfterRPT as SimpleBeforeAfter
from sdcflows.workflows.apply.correction import init_unwarp_wf


Expand Down Expand Up @@ -58,9 +59,6 @@ def test_unwarp_wf(tmpdir, datadir, workdir, outdir, with_affine):
)

if outdir:
from niworkflows.interfaces.reportlets.registration import (
SimpleBeforeAfterRPT as SimpleBeforeAfter,
)
from ...outputs import DerivativesDataSink
from ....interfaces.reportlets import FieldmapReportlet

Expand Down
4 changes: 1 addition & 3 deletions sdcflows/workflows/apply/tests/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu
from nireports.interfaces.reporting.base import SimpleBeforeAfterRPT as SimpleBeforeAfter

from ...fit.fieldmap import init_magnitude_wf
from ..registration import init_coeff2epi_wf
Expand Down Expand Up @@ -70,9 +71,6 @@ def test_registration_wf(tmpdir, datadir, workdir, outdir):
# fmt: on

if outdir:
from niworkflows.interfaces.reportlets.registration import (
SimpleBeforeAfterRPT as SimpleBeforeAfter,
)
from ...outputs import DerivativesDataSink

report = pe.Node(
Expand Down
2 changes: 1 addition & 1 deletion sdcflows/workflows/tests/test_ancillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import pytest
from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu
from niworkflows.interfaces.reportlets.masks import SimpleShowMaskRPT
from nireports.interfaces.reporting.masks import SimpleShowMaskRPT
from ..ancillary import init_brainextraction_wf


Expand Down
3 changes: 2 additions & 1 deletion sdcflows/workflows/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# https://www.nipreps.org/community/licensing/
#
"""Test the base workflow."""

from pathlib import Path
import json
import pytest
Expand All @@ -31,7 +32,7 @@
from sdcflows.interfaces.reportlets import FieldmapReportlet
from sdcflows.workflows.apply import correction as swac
from sdcflows.workflows.apply import registration as swar
from niworkflows.interfaces.reportlets.registration import (
from nireports.interfaces.reporting.base import (
SimpleBeforeAfterRPT as SimpleBeforeAfter,
)

Expand Down

0 comments on commit a50506a

Please sign in to comment.