def test_workflow_mean_functional():

    import os

    import pkg_resources as p

    from qap.functional_preproc import run_mean_functional
    from qap.workflow_utils import build_test_case

    func_motion = p.resource_filename(
        "qap", os.path.join(test_sub_dir, "rest_1", "func_motion_correct", "rest_calc_tshift_resample_" "volreg.nii.gz")
    )

    ref_graph = p.resource_filename(
        "qap", os.path.join("test_data", "workflow_reference", "mean_functional", "graph_mean_functional.dot")
    )

    ref_inputs = p.resource_filename(
        "qap", os.path.join("test_data", "workflow_reference", "mean_functional", "wf_inputs.txt")
    )

    # build the workflow
    wf, base_dir = run_mean_functional(func_motion, False)

    # get the workflow inputs of the workflow being tested
    wf_inputs_string = str(wf.inputs).replace("\n", "")

    wf_inputs_string = wf_inputs_string.replace(base_dir, "BASE_DIRECTORY_HERE")
    wf_inputs_string = wf_inputs_string.replace(func_motion, "IN_FILE_HERE")

    flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)

    assert flag == 2, err
Example #2
0
def test_run_mean_functional():

    import os
    import nibabel as nb

    import pkg_resources as p

    from qap.functional_preproc import run_mean_functional

    if "mean_functional" in os.listdir(os.getcwd()):

        err = "\n[!] The output folder for this workflow already exists.\n"

        raise Exception(err)


    func_motion = p.resource_filename("qap", os.path.join(test_sub_dir, \
                                      "rest_1", \
                                      "func_motion_correct", \
                                      "rest_calc_tshift_resample_" \
                                      "volreg.nii.gz"))

    ref_out = p.resource_filename("qap", os.path.join(test_sub_dir, \
                                  "rest_1", \
                                  "mean_functional", \
                                  "rest_calc_tshift_resample_volreg_" \
                                  "tstat.nii.gz"))

    # run the workflow
    output = run_mean_functional(func_motion)

    # make the correlation
    ref_out_data = nb.load(ref_out).get_data()
    output_data = nb.load(output).get_data()

    os.system("rm -R mean_functional")

    # create a vector of True and False values
    bool_vector = ref_out_data == output_data

    assert bool_vector.all()
def test_workflow_mean_functional():

    import os

    import pkg_resources as p

    from qap.functional_preproc import run_mean_functional
    from qap.workflow_utils import build_test_case


    func_motion = p.resource_filename("qap", os.path.join(test_sub_dir, \
                                      "rest_1", \
                                      "func_motion_correct", \
                                      "rest_calc_tshift_resample_" \
                                      "volreg.nii.gz"))

    ref_graph = p.resource_filename("qap", os.path.join("test_data", \
                                    "workflow_reference", \
                                    "mean_functional", \
                                    "graph_mean_functional.dot"))

    ref_inputs = p.resource_filename("qap", os.path.join("test_data", \
                                     "workflow_reference", \
                                     "mean_functional", \
                                     "wf_inputs.txt"))

    # build the workflow
    wf, base_dir = run_mean_functional(func_motion, False)

    # get the workflow inputs of the workflow being tested
    wf_inputs_string = str(wf.inputs).replace("\n", "")

    wf_inputs_string = wf_inputs_string.replace(base_dir, \
                           "BASE_DIRECTORY_HERE")
    wf_inputs_string = wf_inputs_string.replace(func_motion, "IN_FILE_HERE")

    flag, err = build_test_case(wf, ref_inputs, ref_graph, wf_inputs_string)

    assert flag == 2, err
def test_run_mean_functional():

    import os
    import nibabel as nb

    import pkg_resources as p

    from qap.functional_preproc import run_mean_functional

    if "mean_functional" in os.listdir(os.getcwd()):

        err = "\n[!] The output folder for this workflow already exists.\n"

        raise Exception(err)

    func_motion = p.resource_filename(
        "qap", os.path.join(test_sub_dir, "rest_1", "func_motion_correct", "rest_calc_tshift_resample_" "volreg.nii.gz")
    )

    ref_out = p.resource_filename(
        "qap",
        os.path.join(test_sub_dir, "rest_1", "mean_functional", "rest_calc_tshift_resample_volreg_" "tstat.nii.gz"),
    )

    # run the workflow
    output = run_mean_functional(func_motion)

    # make the correlation
    ref_out_data = nb.load(ref_out).get_data()
    output_data = nb.load(output).get_data()

    os.system("rm -R mean_functional")

    # create a vector of True and False values
    bool_vector = ref_out_data == output_data

    assert bool_vector.all()