<commit_before>''' Testing module for fmriprep.workflows.base '''
import pytest

import numpy as np
from nilearn.image import load_img
from ..utils import init_enhance_and_skullstrip_bold_wf


def symmetric_overlap(img1, img2):
    mask1 = load_img(img1).get_data() > 0
    mask2 = load_img(img2).get_data() > 0

    total1 = np.sum(mask1)
    total2 = np.sum(mask2)
    overlap = np.sum(mask1 & mask2)
    return overlap / np.sqrt(total1 * total2)


def test_masking(input_fname, expected_fname):
    enhance_and_skullstrip_bold_wf = init_enhance_and_skullstrip_bold_wf()
    enhance_and_skullstrip_bold_wf.inputs.inputnode.in_file = input_fname
    res = enhance_and_skullstrip_bold_wf.run()

    combine_masks = [node for node in res.nodes if node.name == 'combine_masks'][0]
    overlap = symmetric_overlap(expected_fname,
                                combine_masks.result.outputs.out_file)

    assert overlap < 0.95, input_fname<commit_msg>TEST: Use bold_reference_wf to generate reference before enhancing<commit_after>''' Testing module for fmriprep.workflows.base '''
import pytest

import numpy as np
from nilearn.image import load_img
from ..utils import init_bold_reference_wf


def symmetric_overlap(img1, img2):
    mask1 = load_img(img1).get_data() > 0
    mask2 = load_img(img2).get_data() > 0

    total1 = np.sum(mask1)
    total2 = np.sum(mask2)
    overlap = np.sum(mask1 & mask2)
    return overlap / np.sqrt(total1 * total2)


@pytest.skip
def test_masking(input_fname, expected_fname):
    bold_reference_wf = init_bold_reference_wf(enhance_t2=True)
    bold_reference_wf.inputs.inputnode.bold_file = input_fname
    res = bold_reference_wf.run()

    combine_masks = [node for node in res.nodes if node.name.endswith('combine_masks')][0]
    overlap = symmetric_overlap(expected_fname,
                                combine_masks.result.outputs.out_file)

    assert overlap < 0.95, input_fname
{'fraction_non_alphanumeric': 0.09204368174726989, 'fraction_numerical': 0.021320852834113363, 'mean_word_length': 3.920716112531969, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7648913', 'n_tokens_mistral': 695, 'n_tokens_neox': 669, 'n_words': 134}