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: Cleanup annoying isolated dots in reportlets + new tests #168

Merged
merged 1 commit into from
Dec 29, 2020
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
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ out/**/*
out/
tools/**/*
tools
.DS_Store

# CI, etc.
.circleci/**/*
Expand All @@ -49,4 +50,5 @@ tools
.readthedocs.yml
.travis.yml
.zenodo.json
CONTRIBUTING.md
CONTRIBUTING.md

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ venv.bak/

# mypy
.mypy_cache/

# Mac OSX
.DS_Store
2 changes: 1 addition & 1 deletion sdcflows/interfaces/reportlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _generate_report(self):
break

if isdefined(self.inputs.moving):
movnii = load_img(self.inputs.moving)
movnii = rotate_affine(load_img(self.inputs.moving), rot=canonical_r)

contour_nii = mask_nii = None
if isdefined(self.inputs.mask):
Expand Down
30 changes: 30 additions & 0 deletions sdcflows/interfaces/tests/test_reportlets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Test the fieldmap reportlets."""
from pathlib import Path
import pytest
from ..reportlets import FieldmapReportlet
from ...utils.epimanip import epi_mask


@pytest.mark.parametrize("mask", [True, False])
@pytest.mark.parametrize("apply_mask", [True, False])
def test_FieldmapReportlet(tmpdir, outdir, testdata_dir, mask, apply_mask):
"""Generate one reportlet."""
tmpdir.chdir()

if not outdir:
outdir = Path.cwd()

report = FieldmapReportlet(
reference=str(testdata_dir / "epi.nii.gz"),
moving=str(testdata_dir / "epi.nii.gz"),
fieldmap=str(testdata_dir / "topup-field.nii.gz"),
out_report=str(
outdir / f"test-fieldmap{'-masked' * mask}{'-zeroed' * apply_mask}.svg"
),
apply_mask=apply_mask,
)

if mask:
report.inputs.mask = epi_mask(str(testdata_dir / "epi.nii.gz"))

report.run()
1 change: 0 additions & 1 deletion sdcflows/interfaces/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def test_ConvertWarp(tmpdir, shape):
)
def test_Xeoblique(tmpdir, angles, oblique):
"""Exercise De/Reoblique interfaces."""

tmpdir.chdir()

affine = nb.affines.from_matvec(nb.eulerangles.euler2mat(*angles))
Expand Down
1 change: 1 addition & 0 deletions sdcflows/utils/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@pytest.mark.parametrize("retval", [None, 10])
def test_get_free_mem(monkeypatch, retval):
"""Test the get_free_mem utility."""

def mock_func():
if retval is None:
raise ImportError
Expand Down
5 changes: 3 additions & 2 deletions sdcflows/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ def coolwarm_transparent(max_alpha=0.7, opaque_perc=30, transparent_perc=8):
midpoint = cmap.N // 2 + 1
_10perc = (cmap.N * transparent_perc) // 100
# Set alpha
alpha = np.ones(cmap.N) * max_alpha
alpha[midpoint - _10perc : midpoint + _10perc] = 0
alpha = np.zeros(cmap.N)
alpha[:_20perc] = max_alpha
alpha[-_20perc:] = max_alpha
alpha[_20perc : midpoint - _10perc - 1] = np.linspace(
max_alpha, 0, len(alpha[_20perc : midpoint - _10perc - 1])
)
Expand Down