Пример #1
0
def create_cpac_data_config(bids_dir,
                            participant_label=None,
                            aws_input_creds=None,
                            skip_bids_validator=False):
    from bids_utils import collect_bids_files_configs, bids_gen_cpac_sublist

    print("Parsing {0}..".format(bids_dir))

    (file_paths, config) = collect_bids_files_configs(bids_dir,
                                                      aws_input_creds)

    if participant_label:
        file_paths = [
            file_path for file_path in file_paths
            if any(participant_label in file_path
                   for participant_label in participant_labels)
        ]

    if not file_paths:
        print("Did not find data for {0}".format(", ".join(participant_label)))
        sys.exit(1)

    raise_error = not skip_bids_validator

    sub_list = bids_gen_cpac_sublist(bids_dir,
                                     file_paths,
                                     config,
                                     aws_input_creds,
                                     raise_error=raise_error)

    if not sub_list:
        print("Did not find data in {0}".format(bids_dir))
        sys.exit(1)

    return sub_list
Пример #2
0
def test_gen_bids_sublist(bids_dir, test_yml, creds_path, dbg=False):

    (img_files, config) = collect_bids_files_configs(bids_dir, creds_path)
    print("Found %d config files for %d image files" %
          (len(config), len(img_files)))

    sublist = bids_gen_cpac_sublist(bids_dir, img_files, config, creds_path,
                                    dbg)

    with open(test_yml, "w") as ofd:
        yaml.dump(sublist, ofd, encoding='utf-8')

    sublist = bids_gen_cpac_sublist(bids_dir, img_files, None, creds_path, dbg)

    test_yml = test_yml.replace(".yml", "_no_param.yml")
    with open(test_yml, "w") as ofd:
        yaml.dump(sublist, ofd, encoding='utf-8')

    assert sublist
Пример #3
0
# we have all we need if we are doing a group level analysis
if args.analysis_level == "group":
    # print ("Starting group level analysis of data in %s using %s"%(args.bids_dir, config_file))
    # import CPAC
    # CPAC.pipeline.cpac_group_runner.run(config_file, args.bids_dir)
    # sys.exit(1)
    print("Starting group level analysis of data in {0} using {1}".format(
        args.bids_dir, config_file))
    sys.exit(0)

# otherwise we move on to conforming the data configuration
if not args.data_config_file:

    from bids_utils import collect_bids_files_configs, bids_gen_cpac_sublist

    (file_paths, config) = collect_bids_files_configs(args.bids_dir,
                                                      args.aws_input_creds)

    if args.participant_label:

        pt_file_paths = []
        for pt in args.participant_label:

            if 'sub-' not in pt:
                pt = 'sub-' + pt

            pt_file_paths += [fp for fp in file_paths if pt in fp]

        file_paths = pt_file_paths

    if not file_paths:
        print("Did not find any files to process")
Пример #4
0
        sys.exit(1)

    else:
        import CPAC.pipeline.cpac_group_runner as cgr
        print("Starting group level analysis of data in {0} using {1}".format(args.bids_dir, args.group_file))
        cgr.run(args.group_file)
        
        sys.exit(0)

# otherwise we move on to conforming the data configuration
if not args.data_config_file:

    from bids_utils import collect_bids_files_configs, bids_gen_cpac_sublist

    (file_paths, config) = collect_bids_files_configs(args.bids_dir, args.aws_input_creds)

    if args.participant_label:

        pt_file_paths = []
        for pt in args.participant_label:

            if 'sub-' not in pt:
                pt = 'sub-' + pt

            pt_file_paths += [fp for fp in file_paths if pt in fp]

        file_paths = pt_file_paths

    if not file_paths:
        print("Did not find any files to process")