Skip to content

Commit

Permalink
Remove redundant nifti download, cleanup defaced test data
Browse files Browse the repository at this point in the history
  • Loading branch information
ofgulban committed Jul 12, 2022
1 parent 376afbe commit 6c904a6
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import pytest
from pathlib import Path
# import urllib.request


def test_cleanup_files():
Expand Down Expand Up @@ -33,18 +32,21 @@ def test_get_outfile_type():

def test_deface_image():
if which('fsl'):
test_img = (
Path(__file__).
parent.parent.
joinpath(
'tests',
'data',
'ds000031_sub-01_ses-006_run-001_T1w.nii.gz').as_posix())
# # From https://stackoverflow.com/a/7244263
# data_url = 'https://openneuro.org/crn/datasets/ds000031/files/sub-01:ses-006:anat:sub-01_ses-006_run-001_T1w.nii.gz'
# urllib.request.urlretrieve(data_url, test_img)
pdu.deface_image(test_img, forcecleanup=True, force=True)
pdu.cleanup_files(test_img)
# Piece together test data path
test_img_name = 'ds000031_sub-01_ses-006_run-001_T1w'
pydeface_path = Path(__file__).parent.parent
test_img_path = os.path.join(
pydeface_path, 'tests', 'data',
"{}.nii.gz".format(test_img_name))

# Run pydeface
pdu.deface_image(test_img_path, forcecleanup=True, force=True)

# Cleanup output nifti to not mistakenly push to repo
test_img_outpath = os.path.join(
pydeface_path, 'tests', 'data',
"{}_defaced.nii.gz".format(test_img_name))
pdu.cleanup_files(test_img_outpath)

else:
pytest.skip("no fsl to run defacing.")
pytest.skip("No FSL to run defacing.")

0 comments on commit 6c904a6

Please sign in to comment.