Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Connectivity Error #34

Open
TK-21st opened this issue Jan 11, 2021 · 0 comments · May be fixed by #35
Open

Get Connectivity Error #34

TK-21st opened this issue Jan 11, 2021 · 0 comments · May be fixed by #35

Comments

@TK-21st
Copy link
Member

TK-21st commented Jan 11, 2021

Issues

  1. Connectivity Data cannot be downloaded anymore.
  2. The Comment in the generated csv file contains commas, which will corrupt the output csv format.
# If Inferred=1, the connectivity between neurons was inferred using axonic/dendritic polarity predicted by SPIN:Skeleton-based Polarity Identification for Neurons. Please refer to
# SPIN: A Method of Skeleton-based Polarity Identification for Neurons. Neurinformatics 12:487-507. Yi-Hsuan Lee, Yen-Nan Lin, Chao-Chun Chuang and Chung-Chuan Lo (2014)
# for more details

Remedy

Change the following lines :

csv = 'If Inferred=1, the connectivity between neurons was inferred using axonic/dendritic polarity predicted by SPIN:Skeleton-based Polarity Identification for Neurons. Please refer to \nSPIN: A Method of Skeleton-based Polarity Identification for Neurons. Neurinformatics 12:487-507. Yi-Hsuan Lee, Yen-Nan Lin, Chao-Chun Chuang and Chung-Chuan Lo (2014)\nfor more details\n'
csv += 'PreSynaptic Neuron,PostSynaptic Neuron,N,Inferred'
nodes = res['nodes']
edges = res['edges']
for(e_pre in edges){
if(nodes[e_pre]['class'] == 'Neuron'){
if('uname' in nodes[e_pre])
pre = nodes[e_pre]['uname']
else
pre = nodes[e_pre]['name']
synapse_nodes = edges[e_pre]
for(synapse in synapse_nodes){
if(nodes[synapse]['class'] == 'Synapse')
inferred=0
else
inferred=1
N = nodes[synapse]['N']
post_node = nodes[Object.keys(edges[synapse])[0]]
if('uname' in post_node)
post = post_node['uname']
else
post = post_node['name']
csv += ('\n' + pre + ',' + post + ',' + N + ',' + inferred)
}
}
}

to:

nodes = res['nodes'];
edges = res['edges'];

let outgoing_edges = edges.filter(edge => nodes[edge[0]].class=='Neuron');
let incoming_edges = edges.filter(edge => !outgoing_edges.includes(edge));
let connectivity = [];
for (let edge of incoming_edges){
  let edge_id = edge[0];
  let inferred = (nodes[edge[0]].class == 'InferredSynapse') ? 1:0;
  let pre_outgoing_edge = outgoing_edges.filter(edge => edge[1] == edge_id);
  if (pre_outgoing_edge.length != 1) {
    console.error(`Cannot find outgoing edge from presynaptic neuron for edge ${edge}`);
    continue
  }
  let pre_node = pre_outgoing_edge[0][0];
  let post_node = edge[1];
  let N = nodes[edge_id].N;
  let pre_name = 'uname' in nodes[pre_node] ? nodes[pre_node].uname : nodes[pre_node].name;
  let post_name = 'uname' in nodes[post_node] ? nodes[post_node].uname : nodes[post_node].name;
  connectivity.push([pre_name, post_name, N, inferred])
  
}

csv = `PreSynaptic Neuron,PostSynaptic Neuron,N,Inferred
${connectivity.map(conn=>`${conn[0]},${conn[1]},${conn[2]},${conn[3]}\n`).join('')}`;

If we really want to include the comments, we can do the following (which will not be rendered correctly by default browsers, but can be parsed by pandas by specifying pd.read_csv(..., comment='#')).

csv = `
# If Inferred=1, the connectivity between neurons was inferred using axonic/dendritic polarity predicted by SPIN:Skeleton-based Polarity Identification for Neurons. Please refer to
# SPIN: A Method of Skeleton-based Polarity Identification for Neurons. Neurinformatics 12:487-507. Yi-Hsuan Lee, Yen-Nan Lin, Chao-Chun Chuang and Chung-Chuan Lo (2014)
# for more details

PreSynaptic Neuron,PostSynaptic Neuron,N,Inferred
${
  connectivity.map(conn=>`${conn[0]},${conn[1]},${conn[2]},${conn[3]}\n`).join('')
}
`;
TK-21st added a commit that referenced this issue Jan 11, 2021
@TK-21st TK-21st linked a pull request Jan 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant