Esempio n. 1
0
def _link_dist_worker(args):
    fname, cfg = args
    adj_mat, ok_nodes = ch.do_start(fname, cfg['blacklist_fname'])
    all_distances = []
    # load voxeldata
    node_info = dataio.load_mat(cfg['node_info_fname'])['rois'][0]
    node_info = node_info[ok_nodes]
    coords = np.zeros((len(node_info), 3))
    for j in range(len(node_info)):
        coords[j] = np.ravel(node_info['centroidMNI'][j])  # 1 for the coords

    for d in cfg['density_range']:
        net = netgen.make_net_from_unfiltered_data(adj_mat,
                                                   ok_nodes,
                                                   density=d,
                                                   include_mst=False,
                                                   weighted=False)
        es = net.es
        # compute results:
        distances = np.zeros(len(es))
        for j, e in enumerate(es):
            source_coords = coords[e.source]
            target_coords = coords[e.target]
            distances[j] = np.linalg.norm(source_coords - target_coords)
        all_distances.append(distances)
    out_dict = {
        settings.link_distance_tag: all_distances,
        settings.config_tag: cfg
    }
    out_fname = fnc.get_ind_fname(fname, cfg, settings.link_distance_tag)
    ch.do_end(fname, out_fname, out_dict)
Esempio n. 2
0
def _node_prop_worker(args):
    fname, cfg = args
    adj_mat, ok_nodes = ch.do_start(fname, cfg["blacklist_fname"])
    results = gencomps.get_node_props_from_mat(adj_mat,
                                               ok_nodes,
                                               cfg["density"],
                                               props=cfg["node_props"],
                                               include_mst=cfg["include_mst"])
    results[settings.config_tag] = cfg
    out_fname = fnc.get_ind_fname(fname, cfg, "node_props")
    ch.do_end(fname, out_fname, results)
Esempio n. 3
0
def _global_uw_prop_worker(args):
    fname, cfg = args
    adj_mat, ok_nodes = ch.do_start(fname, cfg['blacklist_fname'])
    results = gencomps.get_global_props_for_density_range(
        adj_mat,
        ok_nodes,
        cfg['density_range'],
        cfg['global_uw_props'],
        False,  # weighted
        cfg['include_mst'],
    )
    results[settings.config_tag] = cfg
    out_fname = fnc.get_ind_fname(fname, cfg, "global_uw_props")
    ch.do_end(fname, out_fname, results)
Esempio n. 4
0
def _paired_common_and_diff_link_distances_worker(args):
    fname1, fname2, cfg = args
    adj_mat1, ok_nodes = ch.do_start(fname1, cfg['blacklist_fname'])
    adj_mat2, _ = ch.do_start(fname2, cfg['blacklist_fname'])
    out_dict = {}

    alldistances = []

    for d in cfg['density_range']:
        # print d
        net1 = netgen.make_net_from_unfiltered_data(adj_mat1,
                                                    ok_nodes,
                                                    density=d,
                                                    include_mst=True)
        # print "net1"
        net2 = netgen.make_net_from_unfiltered_data(adj_mat2,
                                                    ok_nodes,
                                                    density=d,
                                                    include_mst=True)

        net1specific = net1.difference(net2)
        net2specific = net2.difference(net1)
        common2 = net2.difference(net2specific)
        common1 = net1.difference(net1specific)
        for i in range(3):
            assert common1.es[i].source == common2.es[i].source

        distances1 = get_link_distances_for_net(net1specific, cfg)
        distances2 = get_link_distances_for_net(net2specific, cfg)
        distancescommon = get_link_distances_for_net(common1, cfg)
        alldistances.append([distances1, distances2, distancescommon])
    out_dict[settings.link_distance_tag] = alldistances
    out_dict[settings.config_tag] = cfg
    out_fname = fnc.get_paired_fname(fname1, fname2, cfg,
                                     settings.link_distance_common_tag)
    ch.do_end(fname1, out_fname, out_dict)