import os

from xcp_d.tests.tests import mock_config
from xcp_d import config
from xcp_d.utils.bids import collect_data, collect_run_data
from xcp_d.workflows.bold.cifti import init_postprocess_cifti_wf

with mock_config():
    layout = config.execution.layout
    bold_file = str(
        config.execution.fmri_dir / "sub-01" / "func" /
        "sub-01_task-imagery_run-01_space-fsLR_den-91k_bold.dtseries.nii"
    )

    run_data = collect_run_data(
        layout=layout,
        bold_file=bold_file,
        file_format="cifti",
        target_space="MNI152NLin2009cAsym",
    )
    run_data['confounds'] = None

    from xcp_d.utils.utils import _create_mem_gb

    wf = init_postprocess_cifti_wf(
        bold_file=bold_file,
        head_radius=50.,
        run_data=run_data,
        t1w_available=True,
        t2w_available=True,
        n_runs=1,
        has_multiple_runs=False,
        exact_scans=[],
        mem_gb=_create_mem_gb(bold_file),
        name="cifti_postprocess_wf",
    )