def test_workflow_func_motion_correct_no_slice_time():

    import os
    import nibabel as nb

    import pkg_resources as p

    from qap.functional_preproc import run_func_motion_correct
    from qap.workflow_utils import build_test_case

    func_scan = p.resource_filename("qap", os.path.join(test_sub_dir, "rest_1", "functional_scan", "rest.nii.gz"))

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

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

    # build the workflow
    wf, base_dir = run_func_motion_correct(func_scan, 0, "End", False, 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_scan, "IN_FILE_A_HERE", 1)
    wf_inputs_string = wf_inputs_string.replace(func_scan, "IN_FILES_HERE")

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

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

    import os
    import nibabel as nb

    import pkg_resources as p

    from qap.functional_preproc import run_func_motion_correct

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

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

        raise Exception(err)

    func_scan = p.resource_filename("qap", os.path.join(test_sub_dir, "rest_1", "functional_scan", "rest.nii.gz"))

    """ NEED A SLICE TIME CORRECTED VERSION OF THIS!!!! NOT COMPLETE """
    ref_out = p.resource_filename(
        "qap", os.path.join(test_sub_dir, "rest_1", "func_motion_correct", "rest_calc_tshift_resample_volreg.nii.gz")
    )

    # run the workflow
    output = run_func_motion_correct(func_scan, 0, "End", True)

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

    os.system("rm -R func_motion_correct")

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

    assert bool_vector.all()
Exemplo n.º 3
0
def test_workflow_func_motion_correct_slice_time():

    import os

    import pkg_resources as p

    from qap.functional_preproc import run_func_motion_correct
    from qap.workflow_utils import build_test_case


    func_scan = p.resource_filename("qap", os.path.join(test_sub_dir, \
                                    "rest_1", \
                                    "functional_scan", \
                                    "rest.nii.gz"))

    ref_graph = p.resource_filename("qap", os.path.join("test_data", \
                                    "workflow_reference", \
                                    "func_motion_correct_slice_time", \
                                    "graph_func_motion_correct" \
                                    "_slice_time.dot"))

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

    # build the workflow
    wf, base_dir = run_func_motion_correct(func_scan, 0, "End", True, 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_scan, "IN_FILE_A_HERE",\
                                                1)
    wf_inputs_string = wf_inputs_string.replace(func_scan, "IN_FILES_HERE")

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

    assert flag == 2, err
Exemplo n.º 4
0
def test_run_func_motion_correct_slice_time():

    import os
    import nibabel as nb

    import pkg_resources as p

    from qap.functional_preproc import run_func_motion_correct

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

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

        raise Exception(err)


    func_scan = p.resource_filename("qap", os.path.join(test_sub_dir, \
                                    "rest_1", \
                                    "functional_scan", \
                                    "rest.nii.gz"))
    ''' NEED A SLICE TIME CORRECTED VERSION OF THIS!!!! NOT COMPLETE '''
    ref_out = p.resource_filename("qap", os.path.join(test_sub_dir, \
                                  "rest_1", \
                                  "func_motion_correct", \
                                  "rest_calc_tshift_resample_volreg.nii.gz"))

    # run the workflow
    output = run_func_motion_correct(func_scan, 0, "End", True)

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

    os.system("rm -R func_motion_correct")

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

    assert bool_vector.all()