File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
fmriprep/workflows/bold/tests Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments