Skip to content

Commit 57f2e62

Browse files
effigiesoesteban
authored andcommitted
TEST: Add basic regression test
1 parent 394ab70 commit 57f2e62

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
''' Testing module for fmriprep.workflows.base '''
2+
import pytest
3+
4+
import numpy as np
5+
from nilearn.image import load_img
6+
from ..utils import init_enhance_and_skullstrip_bold_wf
7+
8+
9+
def symmetric_overlap(img1, img2):
10+
mask1 = load_img(img1).get_data() > 0
11+
mask2 = load_img(img2).get_data() > 0
12+
13+
total1 = np.sum(mask1)
14+
total2 = np.sum(mask2)
15+
overlap = np.sum(mask1 & mask2)
16+
return overlap / np.sqrt(total1 * total2)
17+
18+
19+
def test_masking(input_fname, expected_fname):
20+
enhance_and_skullstrip_bold_wf = init_enhance_and_skullstrip_bold_wf()
21+
enhance_and_skullstrip_bold_wf.inputs.inputnode.in_file = input_fname
22+
res = enhance_and_skullstrip_bold_wf.run()
23+
24+
combine_masks = [node for node in res.nodes if node.name == 'combine_masks'][0]
25+
overlap = symmetric_overlap(expected_fname,
26+
combine_masks.result.outputs.out_file)
27+
28+
assert overlap < 0.95, input_fname

0 commit comments

Comments
 (0)