Example #1
0
def test_nodemaker_tools_parlistfile_RSN():
    ##Set example inputs##
    base_dir = str(Path(__file__).parent / "examples")
    #base_dir = '/Users/PSYC-dap3463/Applications/PyNets/tests/examples'
    dir_path = base_dir + '/997'
    func_file = dir_path + '/sub-997_ses-01_task-REST_run-01_bold_space-MNI152NLin2009cAsym_preproc_masked.nii.gz'
    parlistfile = base_dir + '/whole_brain_cluster_labels_PCA200.nii.gz'
    network = 'Default'
    parc = True
    atlas_select = 'whole_brain_cluster_labels_PCA200'

    [coords, atlas_select, par_max,
     parcel_list] = nodemaker.get_names_and_coords_of_parcels(parlistfile)

    label_names = np.arange(len(coords) +
                            1)[np.arange(len(coords) + 1) != 0].tolist()

    [net_coords, net_parcel_list, net_label_names,
     network] = nodemaker.get_node_membership(network, func_file, coords,
                                              label_names, parc, parcel_list)

    [net_parcels_map_nifti,
     parcel_list_exp] = nodemaker.create_parcel_atlas(net_parcel_list)

    out_path = nodemaker.gen_network_parcels(parlistfile, network,
                                             net_label_names, dir_path)

    assert coords is not None
    assert net_coords is not None
    assert net_label_names is not None
    assert net_parcel_list is not None
    assert out_path is not None
    assert net_parcels_map_nifti is not None
    assert parcel_list_exp is not None
    assert network is not None
Example #2
0
def test_nodemaker_tools_masking_parlistfile_RSN():
    # Set example inputs
    base_dir = str(Path(__file__).parent / "examples")
    #base_dir = '/Users/rxh180012/PyNets-development/tests/examples'
    dir_path = base_dir + '/997'
    func_file = dir_path + '/sub-997_ses-01_task-REST_run-01_bold_space-MNI152NLin2009cAsym_preproc_masked.nii.gz'
    parlistfile = base_dir + '/whole_brain_cluster_labels_PCA200.nii.gz'
    mask = dir_path + '/pDMN_3_bin.nii.gz'
    network = 'Default'
    ID = '997'
    perc_overlap = 0.10
    parc = True

    start_time = time.time()
    [coords, _, _] = nodemaker.get_names_and_coords_of_parcels(parlistfile)
    print("%s%s%s" % ('get_names_and_coords_of_parcels --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    label_names = np.arange(len(coords) +
                            1)[np.arange(len(coords) + 1) != 0].tolist()

    start_time = time.time()
    parcel_list = nodemaker.gen_img_list(parlistfile)
    [net_coords, net_parcel_list, net_label_names,
     network] = nodemaker.get_node_membership(network, func_file, coords,
                                              label_names, parc, parcel_list)
    print("%s%s%s" % ('get_node_membership --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    [net_coords_masked, net_label_names_masked, net_parcel_list_masked
     ] = nodemaker.parcel_masker(mask, net_coords, net_parcel_list,
                                 net_label_names, dir_path, ID, perc_overlap)
    print("%s%s%s" % ('parcel_masker --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    [net_parcels_map_nifti,
     parcel_list_exp] = nodemaker.create_parcel_atlas(net_parcel_list_masked)
    print("%s%s%s" % ('create_parcel_atlas --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    out_path = nodemaker.gen_network_parcels(parlistfile, network,
                                             net_label_names_masked, dir_path)
    print("%s%s%s" % ('gen_network_parcels --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    assert coords is not None
    assert net_coords is not None
    assert net_label_names is not None
    assert net_parcel_list is not None
    assert net_coords_masked is not None
    assert net_label_names_masked is not None
    assert net_parcel_list_masked is not None
    assert out_path is not None
    assert net_parcels_map_nifti is not None
    assert parcel_list_exp is not None
    assert network is not None
Example #3
0
def test_nodemaker_tools_masking_parlistfile_RSN():
    # Set example inputs
    base_dir = str(Path(__file__).parent / "examples")
    dir_path = base_dir + '/002/fmri'
    func_file = dir_path + '/002.nii.gz'
    parlistfile = base_dir + '/whole_brain_cluster_labels_PCA200.nii.gz'
    roi = base_dir + '/pDMN_3_bin.nii.gz'
    network = 'Default'
    ID = '002'
    perc_overlap = 0.10
    parc = True

    start_time = time.time()
    [coords, _, _] = nodemaker.get_names_and_coords_of_parcels(parlistfile)
    print("%s%s%s" % ('get_names_and_coords_of_parcels --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    labels = np.arange(len(coords) +
                       1)[np.arange(len(coords) + 1) != 0].tolist()

    start_time = time.time()
    parcel_list = nodemaker.gen_img_list(parlistfile)
    [net_coords, net_parcel_list, net_labels,
     network] = nodemaker.get_node_membership(network, func_file, coords,
                                              labels, parc, parcel_list)
    print("%s%s%s" % ('get_node_membership --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    [net_coords_masked, net_labels_masked, net_parcel_list_masked
     ] = nodemaker.parcel_masker(roi, net_coords, net_parcel_list, net_labels,
                                 dir_path, ID, perc_overlap)
    print("%s%s%s" % ('parcel_masker --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    [net_parcels_map_nifti,
     parcel_list_exp] = nodemaker.create_parcel_atlas(net_parcel_list_masked)
    print("%s%s%s" % ('create_parcel_atlas --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    out_path = nodemaker.gen_network_parcels(parlistfile, network,
                                             net_labels_masked, dir_path)
    print("%s%s%s" % ('gen_network_parcels --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    assert coords is not None
    assert net_coords is not None
    assert net_labels is not None
    assert net_parcel_list is not None
    assert net_coords_masked is not None
    assert net_labels_masked is not None
    assert net_parcel_list_masked is not None
    assert out_path is not None
    assert net_parcels_map_nifti is not None
    assert parcel_list_exp is not None
    assert network is not None
Example #4
0
def test_nodemaker_tools_parlistfile_RSN():
    # Set example inputs
    base_dir = str(Path(__file__).parent / "examples")
    #base_dir = '/Users/PSYC-dap3463/Applications/PyNets/tests/examples'
    dir_path = base_dir + '/997'
    func_file = dir_path + '/sub-997_ses-01_task-REST_run-01_bold_space-MNI152NLin2009cAsym_preproc_masked.nii.gz'
    parlistfile = base_dir + '/whole_brain_cluster_labels_PCA200.nii.gz'
    network = 'Default'
    parc = True

    start_time = time.time()
    [coords, _, _,
     parcel_list] = nodemaker.get_names_and_coords_of_parcels(parlistfile)
    print("%s%s%s" % ('get_names_and_coords_of_parcels --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    label_names = np.arange(len(coords) +
                            1)[np.arange(len(coords) + 1) != 0].tolist()

    start_time = time.time()
    [net_coords, net_parcel_list, net_label_names,
     network] = nodemaker.get_node_membership(network, func_file, coords,
                                              label_names, parc, parcel_list)
    print("%s%s%s" % ('get_node_membership --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    [net_parcels_map_nifti,
     parcel_list_exp] = nodemaker.create_parcel_atlas(net_parcel_list)
    print("%s%s%s" % ('create_parcel_atlas --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    start_time = time.time()
    out_path = nodemaker.gen_network_parcels(parlistfile, network,
                                             net_label_names, dir_path)
    print("%s%s%s" % ('gen_network_parcels --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    assert coords is not None
    assert net_coords is not None
    assert net_label_names is not None
    assert net_parcel_list is not None
    assert out_path is not None
    assert net_parcels_map_nifti is not None
    assert parcel_list_exp is not None
    assert network is not None