-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
43 lines (34 loc) · 1.3 KB
/
conftest.py
File metadata and controls
43 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Shared fixtures for tests data."""
from pathlib import Path
from types import SimpleNamespace
import pytest
@pytest.fixture
def test_dataset_dir() -> Path:
"""Return path to test dataset directory."""
return Path(__file__).parent / "data" / "ds000001"
@pytest.fixture
def test_subject(test_dataset_dir: Path) -> SimpleNamespace:
"""Return namespace containing file paths to test subject data."""
subject_id = "01"
task_id = "balloonanalogrisktask"
subject_dir = test_dataset_dir / f"sub-{subject_id}"
anat_dir = subject_dir / "anat"
func_dir = subject_dir / "func"
subject_data = SimpleNamespace(
subject_id=subject_id,
subject_dir=subject_dir,
t1w=anat_dir / f"sub-{subject_id}_T1w.nii.gz",
bold=func_dir / f"sub-{subject_id}_task-{task_id}_run-01_bold.nii.gz",
tasks=test_dataset_dir / f"task-{task_id}_bold.json",
events=func_dir / f"sub-{subject_id}_task-{task_id}_run-01_events.tsv",
)
required_files = {
"T1w": subject_data.t1w,
"BOLD": subject_data.bold,
"task": subject_data.tasks,
"events": subject_data.events,
}
for name, fpath in required_files.items():
if not fpath.exists():
raise FileNotFoundError(f"{name} file not found: {fpath}")
return subject_data