RittmanResearch / maybrain

Python package for analysing and visualising brain connectome data
Apache License 2.0
10 stars 7 forks source link

Node labels for plotting #2

Closed rittman closed 10 years ago

rittman commented 10 years ago

Can we make the node labels for plotting the actual node names rather than an index? I don't want to update this before you do a merge with the master.

mrittman commented 10 years ago

Not sure what you mean by this. Can you give example and references to some lines of code?

rittman commented 10 years ago

It would be good to specify the node label when plotting, not merely the index since they may not be in the correct order.

Test script here showing the problem:

# -*- coding: utf-8 -*-
"""
Created on Mon Sep 29 12:24:22 2014

@author: tim
"""

from maybrain import mayBrainTools as mbt
from maybrain import mbplot as mbp

a = mbt.brainObj()

edges = [(0,2),
         (0,4),
         (0,6)]

locations = {0:(1,1,1),
             2:(2,2,2),
             4:(3,3,3),
             6:(4,4,4)}

a.G.add_edges_from(edges)
for n in a.G.nodes():
    a.G.node[n]['xyz'] = locations[n]

b = mbp.plotObj()

# this works:
b.plotBrainCoords(a)

# this works:
b.plotBrainCoords(a, nodes=[0,1,2,3])

# this does not work:
b.plotBrainCoords(a, nodes=[0,2,4,6])
mrittman commented 10 years ago

Thanks fixed this for nodes. Do you need a similar function for edges?

mrittman commented 10 years ago

Merged with the master, will write some test code for plotting and add that soon.

mrittman commented 10 years ago

Test functions added to master.