
datasink_qap_functional_temporal = 
_outputs = {}
base_directory = base_directory_here
container = <undefined>
ignore_exception = False
parameterization = True
regexp_substitutions = <undefined>
remove_dest_dir = False
strip_dir = <undefined>
substitutions = <undefined>

qap_functional_temporal = 
coord_xfm_matrix = coord_xfm_matrix_here
func_brain_mask = func_brain_mask_here
func_motion_correct = func_motion_correct_here
function_str = S'def qap_functional_temporal(func_motion_correct, func_brain_mask, \\\n                                coord_xfm_matrix, subject_id, session_id, \\\n                                scan_id, site_name=None, \\\n                                motion_threshold=1.0):\n\n    import sys\n\n    from qap.temporal_qc import mean_dvars_wrapper, summarize_fd, \\\n                                mean_outlier_timepoints, \\\n                                mean_quality_timepoints, global_correlation\n\n    # DVARS\n    mean_dvars  = mean_dvars_wrapper(func_motion_correct, func_brain_mask)\n\n    # Mean FD (Jenkinson)\n    (mean_fd, num_fd, percent_fd) = summarize_fd(coord_xfm_matrix, \\\n                                                 threshold=motion_threshold)\n\n    # 3dTout\n    mean_outlier = mean_outlier_timepoints(func_motion_correct, \\\n                                               func_brain_mask)\n\n    # 3dTqual\n    mean_quality = mean_quality_timepoints(func_motion_correct)\n\n    # new thing\n    gcor = global_correlation(func_motion_correct, func_brain_mask)\n\n    # Compile\n    qc = {\n        "subject":  subject_id,\n        "session":  session_id,\n        "scan":     scan_id,\n        "dvars":    mean_dvars, \n        "mean_fd":  mean_fd, \n        \'num_fd\':   num_fd, \n        \'perc_fd\':  percent_fd, \n        "outlier":  mean_outlier,\n        "quality":  mean_quality,\n        "gcor": gcor\n    }\n\n    if site_name:\n        qc[\'site\'] = site_name\n\n\n    return qc\n'
.
ignore_exception = False
scan_id = rest_1
session_id = session_1
site_name = site_1
subject_id = 1019436

qap_functional_temporal_to_csv = 
function_str = S'def write_to_csv(sub_qap_dict):  #, outfile):\n\n    import os\n    import csv\n\n    fields = sub_qap_dict.keys()\n\n    # put these at the forefront of the list of header items, to make the\n    # output CSV\'s more readable\n\n    fields = sorted(fields)\n\n    if "subject" in fields:\n        fields.remove("subject")\n        fields.insert(0, "subject")\n\n    if "session" in fields:\n        fields.remove("session")\n        fields.insert(1, "session")\n\n    if "scan" in fields:\n        fields.remove("scan")\n        fields.insert(2, "scan")\n\n    if "site" in fields:\n        fields.remove("site")\n        fields.insert(3, "site")\n\n\n    outfile = os.path.join(os.getcwd(), "qap_measures.csv")\n\n\n    with open(outfile, "wt") as out_f:\n\n        csv_writer = csv.DictWriter(out_f, fields)\n\n        csv_writer.writeheader()\n\n        csv_writer.writerow(sub_qap_dict)\n\n\n    return outfile\n'
.
ignore_exception = False


