brainiak-tutorials
brainiak-tutorials copied to clipboard
FCMA tutorial CircosPlot epoch_coords
Hello all,
I have got to the plotting part of the FCMA tutorial. Everything so far makes perfect sense until the example code reads in the np array epoch_corr_coords.npy
. I don't think other parts of the tutorial mentioned anything about what this array is and how it was generated. I'm new to CircosPlot and get confused when reading the code. It would be easier to navigate the code if any insights could be given on what information does this array contain and how it stores the info (i.e.,its shape).
It is the last code chunk in the FCMA tutorial, and I'm referring to the epoch_coords
variable which reads in epoch_corr_coords.npy
.
# %matplotlib inline
# What is the (absolute) correlation threshold
threshold = 0.95
# Load in the data
plot_out_dir = os.path.join(output_dir, 'plotting_out')
epoch_corr = np.load(os.path.join(plot_out_dir,"epoch_corr.npy"))
epoch_coords = np.load(os.path.join(plot_out_dir,"epoch_corr_coords.npy"))
# Preset the graph
G = nx.Graph()
# Create the edge list
nodelist = []
edgelist = []
for row_counter in range(epoch_corr.shape[0]):
nodelist.append(str(row_counter)) # Set up the node names
for col_counter in range(epoch_corr.shape[1]):
# Determine whether to include the edge based on whether it exceeds the threshold
if abs(epoch_corr[row_counter, col_counter]) > threshold:
# Add a tuple specifying the voxel pairs being compared and the weight of the edge
edgelist.append((str(row_counter), str(col_counter), {'weight': epoch_corr[row_counter, col_counter]}))
# Create the nodes in the graph
G.add_nodes_from(nodelist)
# Add the edges
G.add_edges_from(edgelist)
# Set the colors and grouping (specify a key in a dictionary that can then be referenced)
for n, d in G.nodes(data=True):
# Is the x coordinate negative (left)
if epoch_coords[0][int(n)] < 0:
if epoch_coords[1][int(n)] < 0:
G.node[n]['grouping'] = 'posterior_left'
else:
G.node[n]['grouping'] = 'posterior_right'
else:
if epoch_coords[1][int(n)] < 0:
G.node[n]['grouping'] = 'anterior_left'
else:
G.node[n]['grouping'] = 'anterior_right'
# plot the data
c = CircosPlot(graph=G, node_grouping='grouping', node_color='grouping', group_label_position='middle',figsize=(10,6))
c.draw()
plt.title('Circos plot of epoch data')
Thank you all very much in advance!