Skip to content

Commit 58d3ac0

Browse files
committed
TST: Add simple test for label file parsing
1 parent 378eee3 commit 58d3ac0

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

nibabies/interfaces/conftest.py renamed to nibabies/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""py.test configuration"""
22
from pathlib import Path
3-
import pytest
43
from tempfile import TemporaryDirectory
4+
from pkg_resources import resource_filename
55

6+
import pytest
67

78
FILES = (
89
'functional.nii',
@@ -32,3 +33,4 @@ def data_dir():
3233
@pytest.fixture(autouse=True)
3334
def set_namespace(doctest_namespace, data_dir):
3435
doctest_namespace["data_dir"] = data_dir
36+
doctest_namespace["test_data"] = Path(resource_filename("nibabies", "tests/data"))

nibabies/tests/data/labelfile.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CEREBELLUM_LEFT
2+
8 230 148 34 255
3+
THALAMUS_LEFT
4+
10 0 118 14 255
5+
CAUDATE_LEFT
6+
11 122 186 220 255

nibabies/workflows/bold/alignment.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,11 @@ def parse_roi_labels(label_file):
232232
233233
Return a list of structure names and label keys.
234234
235-
Example
236-
-------
237-
CEREBELLUM_LEFT
238-
8 230 148 34 255
239-
THALAMUS_LEFT
240-
10 0 118 14 255
241-
242-
TODO: Add unit test
235+
>>> structs, ids = parse_roi_labels(test_data / "labelfile.txt")
236+
>>> structs
237+
'["CEREBELLUM_LEFT", "THALAMUS_LEFT", "CAUDATE_LEFT"]'
238+
>>> ids
239+
'[8, 10, 11]'
243240
"""
244241

245242
with open(label_file) as fp:

0 commit comments

Comments
 (0)