def test_get_connectors(self): cn = pymaid.get_connectors(config_test.test_skids, remote_instance=self.rm) self.assertIsInstance(cn, pd.DataFrame) self.assertIsInstance( pymaid.get_connector_details(cn.connector_id.tolist(), remote_instance=self.rm), pd.DataFrame)
def merge_overlapping_connectors(remote_instance=None, verbose=True, tolerance=1): """Merge pairs of connectors that are at exactly the same coordinate""" if remote_instance in [None, 'source']: remote_instance = source_project if verbose: print('Merging overlapping connectors in source project.') elif remote_instance == 'target': remote_instance = target_project if verbose: print('Merging overlapping connectors in target project.') overlapping_pairs_ids = find_overlapping_connectors( remote_instance=remote_instance, verbose=False, tolerance=tolerance) user_input = input('Continue with merge? [Y/n] ') if user_input not in ('y', 'Y'): return resp = [] for ids in overlapping_pairs_ids: print('ids', ids) details = pymaid.get_connector_details(ids, remote_instance=remote_instance) # Put the connector with presynaptic links first, if there is one details.sort_values(by='presynaptic_to', inplace=True, ignore_index=True) # Make sure it's not the case that both connectors have presynaptic links assert details.at[ 1, 'presynaptic_to'] is None, "Can't merge two presynaptic connectors" #Add postsynaptic connections between the winner and the loser's postsynaptic nodes print('linking') link_resp = pymaid.link_connector([ (postsyn_node_id, details.at[0, 'connector_id'], 'postsynaptic_to') for postsyn_node_id in details.at[1, 'postsynaptic_to_node'] ], remote_instance=remote_instance) #Delete the loser print('deleting') del_resp = pymaid.delete_nodes(details.at[1, 'connector_id'], 'CONNECTOR', no_prompt=True, remote_instance=remote_instance) resp.append((link_resp, del_resp)) print('done') return resp
def get_connectors(nl): connectors = pymaid.get_connectors(nl) connectors.set_index("connector_id", inplace=True) connectors.drop( [ "confidence", "creation_time", "edition_time", "tags", "creator", "editor", "type", ], inplace=True, axis=1, ) details = pymaid.get_connector_details(connectors.index.values) details.set_index("connector_id", inplace=True) connectors = pd.concat((connectors, details), ignore_index=False, axis=1) connectors.reset_index(inplace=True) return connectors
connectors = pymaid.get_connectors(nl) connectors.set_index("connector_id", inplace=True) connectors.drop( [ "confidence", "creation_time", "edition_time", "tags", "creator", "editor", "type", ], inplace=True, axis=1, ) details = pymaid.get_connector_details(connectors.index.values) details.set_index("connector_id", inplace=True) connectors = pd.concat((connectors, details), ignore_index=False, axis=1) connectors.reset_index(inplace=True) # %% [markdown] # # pg = sns.PairGrid(data=connectors, x_vars=["x", "y", "z"], y_vars=["x", "y", "z"]) pg.map(sns.scatterplot, alpha=0.02, linewidth=0, s=1) # %% [markdown] # # import matplotlib.pyplot as plt import numpy as np import matplotlib as mpl