Skip to content

Commit d338acc

Browse files
authored
[FIX] Fix t2smap optimal combination (#566)
* Fix t2smap optcom Introduced when I changed make_optcom’s arg from mask to adaptive mask in #358. * Add t2smap integration test.
1 parent bc55c2d commit d338acc

File tree

5 files changed

+72
-2
lines changed

5 files changed

+72
-2
lines changed

.circleci/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,30 @@ jobs:
202202
paths:
203203
- src/coverage/.coverage.five-echo
204204

205+
t2smap:
206+
docker:
207+
- image: continuumio/miniconda3
208+
working_directory: /tmp/src/tedana
209+
steps:
210+
- checkout
211+
- restore_cache:
212+
key: conda-py37-v1-{{ checksum "dev_requirements.txt" }}-{{ checksum "requirements.txt" }}
213+
- run:
214+
name: Run integration tests
215+
no_output_timeout: 40m
216+
command: |
217+
apt-get install -yqq make
218+
source activate tedana_py37 # depends on makeenv_37
219+
make t2smap
220+
mkdir /tmp/src/coverage
221+
mv /tmp/src/tedana/.coverage /tmp/src/coverage/.coverage.t2smap
222+
- store_artifacts:
223+
path: /tmp/data
224+
- persist_to_workspace:
225+
root: /tmp
226+
paths:
227+
- src/coverage/.coverage.t2smap
228+
205229
merge_coverage:
206230
working_directory: /tmp/src/tedana
207231
docker:
@@ -247,6 +271,9 @@ workflows:
247271
- five-echo:
248272
requires:
249273
- makeenv_37
274+
- t2smap:
275+
requires:
276+
- makeenv_37
250277
- merge_coverage:
251278
requires:
252279
- unittest_35
@@ -255,3 +282,4 @@ workflows:
255282
- three-echo
256283
- four-echo
257284
- five-echo
285+
- t2smap

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
.PHONY: all lint
22

3-
all_tests: lint unittest three-echo five-echo
3+
all_tests: lint unittest three-echo four-echo five-echo t2smap
44

55
help:
66
@echo "Please use 'make <target>' where <target> is one of:"
77
@echo " lint to run flake8 on all Python files"
88
@echo " unittest to run unit tests on tedana"
99
@echo " three-echo to run the three-echo test set on tedana"
1010
@echo " five-echo to run the five-echo test set on tedana"
11+
@echo " t2smap to run the t2smap integration test set on tedana"
1112
@echo " all_tests to run 'lint', 'unittest', and 'integration'"
1213

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

29+
t2smap:
30+
@py.test --cov-append --cov-report term-missing --cov=tedana -k test_integration_t2smap tedana/tests/test_integration.py
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
desc-full_S0map.nii.gz
2+
desc-full_T2starmap.nii.gz
3+
desc-optcom_bold.nii.gz
4+
S0map.nii.gz
5+
T2starmap.nii.gz

tedana/tests/test_integration.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pandas as pd
1717

1818
from tedana.workflows import tedana as tedana_cli
19+
from tedana.workflows import t2smap as t2smap_cli
1920
from tedana import io
2021

2122

@@ -183,3 +184,36 @@ def test_integration_three_echo(skip_integration):
183184
fn = resource_filename('tedana',
184185
'tests/data/cornell_three_echo_outputs.txt')
185186
check_integration_outputs(fn, out_dir)
187+
188+
189+
def test_integration_t2smap(skip_integration):
190+
"""Integration test of the full t2smap workflow using five-echo test data
191+
"""
192+
if skip_integration:
193+
pytest.skip('Skipping t2smap integration test')
194+
out_dir = '/tmp/data/five-echo/t2smap_five-echo'
195+
if os.path.exists(out_dir):
196+
shutil.rmtree(out_dir)
197+
198+
# download data and run the test
199+
download_test_data('https://osf.io/9c42e/download',
200+
os.path.dirname(out_dir))
201+
prepend = '/tmp/data/five-echo/p06.SBJ01_S09_Task11_e'
202+
suffix = '.sm.nii.gz'
203+
datalist = [prepend + str(i + 1) + suffix for i in range(5)]
204+
echo_times = [15.4, 29.7, 44.0, 58.3, 72.6]
205+
args = (['-d'] + datalist + ['-e'] + [str(te) for te in echo_times] +
206+
['--out-dir', out_dir, '--fittype', 'curvefit'])
207+
t2smap_cli._main(args)
208+
209+
# compare the generated output files
210+
fname = resource_filename('tedana',
211+
'tests/data/nih_five_echo_outputs_t2smap.txt')
212+
# Gets filepaths generated by integration test
213+
existing = [os.path.relpath(f, out_dir) for f in
214+
glob.glob(os.path.join(out_dir, '**'), recursive=True)[1:]]
215+
216+
# Compares remaining files with those expected
217+
with open(fname, 'r') as f:
218+
tocheck = f.read().splitlines()
219+
assert sorted(tocheck) == sorted(existing)

tedana/workflows/t2smap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def t2smap_workflow(data, tes, out_dir='.', mask=None,
227227

228228
LGR.info('Computing optimal combination')
229229
# optimally combine data
230-
OCcatd = combine.make_optcom(catd, tes, mask, t2s=t2s_full,
230+
OCcatd = combine.make_optcom(catd, tes, masksum, t2s=t2s_full,
231231
combmode=combmode)
232232

233233
# clean up numerical errors

0 commit comments

Comments
 (0)