-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEST: Smoke-test FSInjectBrainExtracted interface
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from pathlib import Path | ||
import numpy as np | ||
import nibabel as nb | ||
from ..freesurfer import FSInjectBrainExtracted | ||
|
||
|
||
def test_inject_skullstrip(tmp_path): | ||
t1_mgz = tmp_path / 'sub-01' / 'mri' / 'T1.mgz' | ||
t1_mgz.parent.mkdir(parents=True) | ||
# T1.mgz images are uint8 | ||
nb.MGHImage(np.ones((5,5,5), dtype=np.uint8), np.eye(4)).to_filename(str(t1_mgz)) | ||
|
||
mask_nii = tmp_path / 'mask.nii.gz' | ||
# Masks may be in a different space (and need resampling), but should be boolean, | ||
# or uint8 in NIfTI | ||
nb.Nifti1Image(np.ones((6,6,6), dtype=np.uint8), | ||
np.eye(4)).to_filename(str(mask_nii)) | ||
|
||
res = FSInjectBrainExtracted(subjects_dir=str(tmp_path), | ||
subject_id='sub-01', | ||
in_brain=str(mask_nii)).run() | ||
|
||
assert Path.exists(tmp_path / 'sub-01' / 'mri' / 'brainmask.auto.mgz') | ||
assert Path.exists(tmp_path / 'sub-01' / 'mri' / 'brainmask.mgz') | ||
|
||
# Run a second time to hit "already exists" condition | ||
res = FSInjectBrainExtracted(subjects_dir=str(tmp_path), | ||
subject_id='sub-01', | ||
in_brain=str(mask_nii)).run() | ||
|