Ejemplo n.º 1
0
    truly_longitudinal_study = True if len(layout.get_sessions()) > 1 else False
    subjects_to_analyze, sessions_to_analyze, freesurfer_subjects_to_analyze = get_subjects_session(layout,
                                                                                                    args.participant_label,
                                                                                                    truly_longitudinal_study)

    if args.analysis_level == "participant":

        data_files = run_prepare_all(args.bids_dir, freesurfer_dir, out_dir, subjects_to_analyze,
                                     sessions_to_analyze, args.n_cpus, args.license_key, args.skip_missing)

        for subject, d in data_files.items():
            d["out_dir"] = out_dir
            d["model_dir"] = model_dir
            d["models"] = args.models
            d["subject_label"] = subject
            predict_brain_age_single_subject(**d)

    elif args.analysis_level == "group":
        print("Creating group table...")
        df = pd.DataFrame([])
        for subject in freesurfer_subjects_to_analyze:
            in_file = os.path.join(out_dir, subject, subject + "_predicted_age.tsv")
            if os.path.isfile(in_file):
                df = df.append(pd.read_csv(in_file, sep="\t"))
            elif not args.skip_missing:
                raise FileNotFoundError(in_file)

        group_out_dir = os.path.join(out_dir, "00_group")
        if not os.path.isdir(group_out_dir):
            os.makedirs(group_out_dir)
        out_file = os.path.join(group_out_dir, "group_predicted_age.tsv")
Ejemplo n.º 2
0
                        default=["Liem2016__OCI_norm"],
                        help='',
                        nargs="+")
    parser.add_argument('--lh_thickness_file', required=True, help='')
    parser.add_argument('--rh_thickness_file', required=True, help='')
    parser.add_argument('--lh_area_file', required=True, help='')
    parser.add_argument('--rh_area_file', required=True, help='')
    parser.add_argument('--aseg_file', required=True, help='')
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='BARACUS version {}'.format(__version__))

    args = parser.parse_args()

    model_dir = resource_filename(Requirement.parse("baracus"), 'models')

    if args.participant_label:
        subject = args.participant_label
    else:
        subject = ""
    predict_brain_age_single_subject(out_dir=args.out_dir,
                                     lh_thickness_file=args.lh_thickness_file,
                                     rh_thickness_file=args.rh_thickness_file,
                                     lh_area_file=args.lh_area_file,
                                     rh_area_file=args.rh_area_file,
                                     aseg_file=args.aseg_file,
                                     model_dir=model_dir,
                                     models=args.models,
                                     subject_label=subject)