예제 #1
0
def test_plot_all_nonet_no_mask(plotting_data):
    """
    Test plot_all_nonet_no_mask functionality
    """

    base_dir = str(Path(__file__).parent/"examples")
    temp_dir = tempfile.TemporaryDirectory()
    dir_path = str(temp_dir.name)
    network = None
    ID = '002'
    thr = 0.95
    node_size = 2
    smooth = 2
    conn_model = 'sps'
    parlistfile = None
    atlas = 'whole_brain_cluster_labels_PCA200'
    roi = f"{base_dir}/miscellaneous/pDMN_3_bin.nii.gz"
    prune = 1
    norm = 1
    hpass = 0.1
    binary = False
    extract_strategy = 'mean'
    edge_threshold = '99%'

    conn_matrix = plotting_data['conn_matrix']
    labels = plotting_data['labels']
    coords = plotting_data['coords']

    start_time = time.time()
    plot_gen.plot_all_func(conn_matrix, conn_model, atlas, dir_path, ID, network, labels, roi,
                           coords, thr, node_size, edge_threshold, smooth, prune,
                           parlistfile, norm, binary, hpass, extract_strategy)
    print("%s%s%s" % ('plot_all --> finished: ', str(np.round(time.time() - start_time, 1)), 's'))

    temp_dir.cleanup()
예제 #2
0
def test_plot_all_nonet_with_mask(plotting_data):
    """
    Test plot_all_nonet_with_mask functionality
    """

    temp_dir = tempfile.TemporaryDirectory()
    dir_path = str(temp_dir.name)
    network = None
    ID = '002'
    thr = 0.95
    node_size = 'None'
    smooth = 2
    prune = False
    norm = 1
    hpass = 0.1
    binary = False
    conn_model = 'sps'
    atlas = b'whole_brain_cluster_labels_PCA200'
    parlistfile = None
    roi = None
    extract_strategy = 'mean'
    edge_threshold = '99%'

    conn_matrix = plotting_data['conn_matrix']
    labels = plotting_data['labels']
    coords = plotting_data['coords']

    # Force an isolate in the matrix
    conn_matrix[:, 0] = 0
    conn_matrix[0, :] = 0

    # Adds coverage
    coords = np.array(coords)
    labels = np.array(labels)

    start_time = time.time()
    plot_gen.plot_all_func(conn_matrix,
                           conn_model,
                           atlas,
                           dir_path,
                           ID,
                           network,
                           labels,
                           roi,
                           coords,
                           thr,
                           node_size,
                           edge_threshold,
                           smooth,
                           prune,
                           parlistfile,
                           norm,
                           binary,
                           hpass,
                           extract_strategy,
                           edge_color_override=True)
    print("%s%s%s" % ('plot_all (Masking version) --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))

    temp_dir.cleanup()
예제 #3
0
    def _run_interface(self, runtime):
        from pynets.plotting import plot_gen

        if self.inputs.coords.ndim == 1:
            print('Only 1 node detected. Plotting is not applicable...')
        else:
            plot_gen.plot_all_func(self.inputs.conn_matrix,
                                   self.inputs.conn_model,
                                   self.inputs.atlas,
                                   self.inputs.dir_path,
                                   self.inputs.ID,
                                   self.inputs.network,
                                   self.inputs.labels.tolist(),
                                   self.inputs.roi,
                                   [tuple(coord) for coord in self.inputs.coords.tolist()],
                                   self.inputs.thr,
                                   self.inputs.node_size,
                                   self.inputs.edge_threshold,
                                   self.inputs.smooth,
                                   self.inputs.prune,
                                   self.inputs.uatlas,
                                   self.inputs.c_boot,
                                   self.inputs.norm,
                                   self.inputs.binary,
                                   self.inputs.hpass)

        self._results['out'] = 'None'

        return runtime
예제 #4
0
def test_plot_all_nonet_with_mask():
    """
    Test plot_all_nonet_with_mask functionality
    """
    import tempfile

    base_dir = str(Path(__file__).parent / "examples")
    dir_path = str(tempfile.TemporaryDirectory().name)
    os.makedirs(dir_path)

    network = None
    ID = '002'
    thr = 0.95
    node_size = 2
    smooth = 2
    prune = 1
    norm = 1
    hpass = 0.1
    binary = False
    conn_model = 'sps'
    atlas = 'whole_brain_cluster_labels_PCA200'
    parlistfile = None
    roi = None
    extract_strategy = 'mean'
    conn_matrix = np.genfromtxt(
        f"{base_dir}/miscellaneous/002_rsn-Default_nodetype-parc_est-sps_thrtype-PROP_thr-0.94.txt"
    )
    edge_threshold = '99%'
    labels_file_path = f"{base_dir}/miscellaneous/Default_func_labelnames_wb.pkl"
    labels_file = open(labels_file_path, 'rb')
    labels = pickle.load(labels_file)
    coord_file_path = f"{base_dir}/miscellaneous/Default_func_coords_wb.pkl"
    coord_file = open(coord_file_path, 'rb')
    coords = pickle.load(coord_file)

    start_time = time.time()
    #coords already a list
    plot_gen.plot_all_func(conn_matrix, conn_model, atlas, dir_path, ID,
                           network, labels, roi, coords, edge_threshold, thr,
                           node_size, smooth, prune, parlistfile, norm, binary,
                           hpass, extract_strategy)
    print("%s%s%s" % ('plot_all (Masking version) --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))
예제 #5
0
def test_plot_all_nonet_no_mask():
    """
    Test plot_all_nonet_no_mask functionality
    """
    # Set example inputs
    base_dir = str(Path(__file__).parent / "examples")
    dir_path = base_dir + '/002/fmri'
    network = None
    ID = '002'
    thr = 0.95
    node_size = 2
    smooth = 2
    c_boot = 3
    conn_model = 'sps'
    parlistfile = None
    atlas = 'whole_brain_cluster_labels_PCA200'
    roi = None
    prune = 1
    norm = 1
    hpass = 0.1
    binary = False
    conn_matrix = np.genfromtxt(
        dir_path +
        '/whole_brain_cluster_labels_PCA200/002_Default_est_sps_0.94.txt')
    edge_threshold = '99%'
    labels_file_path = dir_path + '/whole_brain_cluster_labels_PCA200/Default_func_labelnames_wb.pkl'
    labels_file = open(labels_file_path, 'rb')
    labels = pickle.load(labels_file)
    coord_file_path = dir_path + '/whole_brain_cluster_labels_PCA200/Default_func_coords_wb.pkl'
    coord_file = open(coord_file_path, 'rb')
    coords = pickle.load(coord_file)

    start_time = time.time()
    #coords already a list
    plot_gen.plot_all_func(conn_matrix, conn_model, atlas, dir_path, ID,
                           network, labels, roi, coords, edge_threshold, thr,
                           node_size, smooth, prune, parlistfile, c_boot, norm,
                           binary, hpass)
    print("%s%s%s" % ('plot_all --> finished: ',
                      str(np.round(time.time() - start_time, 1)), 's'))