|
1 |
| -from nibabies.utils.derivatives import copy_derivatives |
| 1 | +from niworkflows.utils.testing import generate_bids_skeleton |
| 2 | + |
| 3 | +from nibabies.utils.derivatives import ( |
| 4 | + collect_anatomical_derivatives, |
| 5 | + collect_functional_derivatives, |
| 6 | + copy_derivatives, |
| 7 | +) |
| 8 | + |
| 9 | +from . import DERIV_SKELETON |
| 10 | + |
| 11 | + |
| 12 | +def test_collect_derivatives(tmp_path): |
| 13 | + deriv_dir = tmp_path / 'derivatives' |
| 14 | + generate_bids_skeleton(deriv_dir, str(DERIV_SKELETON)) |
| 15 | + output_spaces = ['MNIInfant:cohort-1'] |
| 16 | + |
| 17 | + anat_cache = collect_anatomical_derivatives( |
| 18 | + derivatives_dir=deriv_dir, |
| 19 | + subject_id='01', |
| 20 | + session_id=None, |
| 21 | + std_spaces=output_spaces, |
| 22 | + ) |
| 23 | + for suffix in ('preproc', 'mask', 'dseg'): |
| 24 | + assert anat_cache[f't2w_{suffix}'] |
| 25 | + assert len(anat_cache['t2w_tpms']) == 3 |
| 26 | + xfms = anat_cache['transforms'] |
| 27 | + for space in output_spaces: |
| 28 | + assert xfms[space]['reverse'] |
| 29 | + assert xfms[space]['forward'] |
| 30 | + for surface in ( |
| 31 | + 'white', |
| 32 | + 'pial', |
| 33 | + 'midthickness', |
| 34 | + 'sphere', |
| 35 | + 'thickness', |
| 36 | + 'sulc', |
| 37 | + 'sphere_reg', |
| 38 | + 'sphere_reg_fsLR', |
| 39 | + ): |
| 40 | + assert len(anat_cache[surface]) == 2 |
| 41 | + |
| 42 | + func_cache = collect_functional_derivatives(deriv_dir, {'subject': '01'}, None) |
| 43 | + for val in ('hmc_boldref', 'coreg_boldref', 'hmc'): |
| 44 | + assert func_cache[val] |
2 | 45 |
|
3 | 46 |
|
4 | 47 | def test_copy_derivatives(tmp_path):
|
|
0 commit comments