Skip to content

Commit

Permalink
[FIX] Fix t2smap optimal combination (#566)
Browse files Browse the repository at this point in the history
* Fix t2smap optcom

Introduced when I changed make_optcom’s arg from mask to adaptive mask
in #358.

* Add t2smap integration test.
  • Loading branch information
tsalo authored May 7, 2020
1 parent bc55c2d commit d338acc
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,30 @@ jobs:
paths:
- src/coverage/.coverage.five-echo

t2smap:
docker:
- image: continuumio/miniconda3
working_directory: /tmp/src/tedana
steps:
- checkout
- restore_cache:
key: conda-py37-v1-{{ checksum "dev_requirements.txt" }}-{{ checksum "requirements.txt" }}
- run:
name: Run integration tests
no_output_timeout: 40m
command: |
apt-get install -yqq make
source activate tedana_py37 # depends on makeenv_37
make t2smap
mkdir /tmp/src/coverage
mv /tmp/src/tedana/.coverage /tmp/src/coverage/.coverage.t2smap
- store_artifacts:
path: /tmp/data
- persist_to_workspace:
root: /tmp
paths:
- src/coverage/.coverage.t2smap

merge_coverage:
working_directory: /tmp/src/tedana
docker:
Expand Down Expand Up @@ -247,6 +271,9 @@ workflows:
- five-echo:
requires:
- makeenv_37
- t2smap:
requires:
- makeenv_37
- merge_coverage:
requires:
- unittest_35
Expand All @@ -255,3 +282,4 @@ workflows:
- three-echo
- four-echo
- five-echo
- t2smap
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.PHONY: all lint

all_tests: lint unittest three-echo five-echo
all_tests: lint unittest three-echo four-echo five-echo t2smap

help:
@echo "Please use 'make <target>' where <target> is one of:"
@echo " lint to run flake8 on all Python files"
@echo " unittest to run unit tests on tedana"
@echo " three-echo to run the three-echo test set on tedana"
@echo " five-echo to run the five-echo test set on tedana"
@echo " t2smap to run the t2smap integration test set on tedana"
@echo " all_tests to run 'lint', 'unittest', and 'integration'"

lint:
Expand All @@ -25,3 +26,5 @@ four-echo:
five-echo:
@py.test --cov-append --cov-report term-missing --cov=tedana -k test_integration_five_echo tedana/tests/test_integration.py

t2smap:
@py.test --cov-append --cov-report term-missing --cov=tedana -k test_integration_t2smap tedana/tests/test_integration.py
5 changes: 5 additions & 0 deletions tedana/tests/data/nih_five_echo_outputs_t2smap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
desc-full_S0map.nii.gz
desc-full_T2starmap.nii.gz
desc-optcom_bold.nii.gz
S0map.nii.gz
T2starmap.nii.gz
34 changes: 34 additions & 0 deletions tedana/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import pandas as pd

from tedana.workflows import tedana as tedana_cli
from tedana.workflows import t2smap as t2smap_cli
from tedana import io


Expand Down Expand Up @@ -183,3 +184,36 @@ def test_integration_three_echo(skip_integration):
fn = resource_filename('tedana',
'tests/data/cornell_three_echo_outputs.txt')
check_integration_outputs(fn, out_dir)


def test_integration_t2smap(skip_integration):
"""Integration test of the full t2smap workflow using five-echo test data
"""
if skip_integration:
pytest.skip('Skipping t2smap integration test')
out_dir = '/tmp/data/five-echo/t2smap_five-echo'
if os.path.exists(out_dir):
shutil.rmtree(out_dir)

# download data and run the test
download_test_data('https://osf.io/9c42e/download',
os.path.dirname(out_dir))
prepend = '/tmp/data/five-echo/p06.SBJ01_S09_Task11_e'
suffix = '.sm.nii.gz'
datalist = [prepend + str(i + 1) + suffix for i in range(5)]
echo_times = [15.4, 29.7, 44.0, 58.3, 72.6]
args = (['-d'] + datalist + ['-e'] + [str(te) for te in echo_times] +
['--out-dir', out_dir, '--fittype', 'curvefit'])
t2smap_cli._main(args)

# compare the generated output files
fname = resource_filename('tedana',
'tests/data/nih_five_echo_outputs_t2smap.txt')
# Gets filepaths generated by integration test
existing = [os.path.relpath(f, out_dir) for f in
glob.glob(os.path.join(out_dir, '**'), recursive=True)[1:]]

# Compares remaining files with those expected
with open(fname, 'r') as f:
tocheck = f.read().splitlines()
assert sorted(tocheck) == sorted(existing)
2 changes: 1 addition & 1 deletion tedana/workflows/t2smap.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def t2smap_workflow(data, tes, out_dir='.', mask=None,

LGR.info('Computing optimal combination')
# optimally combine data
OCcatd = combine.make_optcom(catd, tes, mask, t2s=t2s_full,
OCcatd = combine.make_optcom(catd, tes, masksum, t2s=t2s_full,
combmode=combmode)

# clean up numerical errors
Expand Down

0 comments on commit d338acc

Please sign in to comment.