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

Update NeuroNLP.js #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions js/NeuroNLP.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,33 +509,32 @@ require([
$('#ui-blocker').show();
client.getConnectivity({success: function(res){
iziToast.hide({transitionOut:'fadeOut'},document.querySelector('.fetching_conn_notification'));
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)
}
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('')}`;

var data = new Blob([csv], {type: 'text/csv'});
// If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks.
Expand Down