forked from Spokhim/MouseBrainModelling
-
Notifications
You must be signed in to change notification settings - Fork 1
/
brainrender_regions.py
147 lines (120 loc) · 3.92 KB
/
brainrender_regions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
"""
This tutorial shows how to create and render a brainrender scene with some brain regions
"""
import brainrender
brainrender.SHADER_STYLE = "cartoon"
from brainrender.scene import Scene
import numpy as np
import pandas as pd
import pylab
import matplotlib.pyplot as plt
from scipy import stats
from matplotlib.colors import ListedColormap
from turbo_colormap import *
import inspect
import os
import csv
import time
import sys
import glob
import pandas as pd
from pprint import pprint
import scipy.cluster.hierarchy as hierarchy
#from tvb.simulator.lab import *
#from tvb.simulator.plot.tools import *
# Input Simulation Pipeline
#from SimulationPipeline import *
#from useful_fns import *
from brainrender.colors import *
# Add the whole thalamus in gray (think they meant red)
#scene.add_brain_regions(["TH"], alpha=0.15)
# Alpha is liek transparency.
# Add VAL nucleus in wireframe style with the allen color
#scene.add_brain_regions(["VAL"], use_original_color=True, wireframe=True)
# Import the E and I densities
df = pd.read_csv(r"C:\Users\Pok Him\Desktop\MouseBrainModelling\CortexDensitiesAlter.csv",delimiter=",")
E_pop = df.excitatory.values
I_pop = df.inhibitory.values
E_mean = np.mean(E_pop)
I_mean = np.mean(I_pop)
# E_normalised is (when excluding region 7) -0.28 to 0.54
E_normalised = (E_pop-E_mean)/E_mean
# I_normalised is (when excluding region 7) -0.45 to 1.44
I_normalised = (I_pop-I_mean)/I_mean
"""
Regime = "LCycle"
G_value = 0.45
B_e_value = 2.8
File_start = r"D:\Simulations\2020_09_23\\" + Regime + "_G[[]" + str(G_value) + "[]]_b_e[[]" + str(B_e_value) + "[]]"
TseriesFile = glob.glob(File_start+"*Tseries*_.csv")[0]
df = np.genfromtxt(TseriesFile,delimiter="\t")
bold_time = df[0]
bold_data = df[1:]
Region0 = bold_data[0]
print(Region0)
Value = Region0[0]
print(Value)
"""
# https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html
# Transparency
alpha = 0.8
print(len(E_normalised))
'''
# For just normal colouring of brain regions.
# Create a scene_e
scene_e = Scene(
#screenshot_kwargs=dict(folder="Docs/Media/clean_screenshots"),
title="Brain Regions",
)
for i in np.arange(len(E_normalised)):
acronym = df.acronym[i]
scene_e.add_brain_regions([acronym], alpha=0.5,use_original_color=True,wireframe=True)
scene_e.render()
'''
Peace=colorMap(E_normalised, name=ListedColormap(turbo_colormap_data),vmin=min(E_normalised),vmax=max(E_normalised))
'''
# Create Colourbars
# create dummy invisible image
# (use the colormap you want to have on the colorbar)
img = plt.imshow(np.array([[min(E_normalised),max(E_normalised)]]), cmap=ListedColormap(turbo_colormap_data))
img.set_visible(False)
plt.colorbar(orientation="vertical")
plt.savefig("colorbar_e.pdf")
# create dummy invisible image
# (use the colormap you want to have on the colorbar)
img = plt.imshow(np.array([[min(I_normalised),max(I_normalised)]]), cmap=ListedColormap(turbo_colormap_data))
img.set_visible(False)
plt.colorbar(orientation="vertical")
plt.savefig("colorbar_i.pdf")
'''
# Create a scene_e
scene_e = Scene(
#screenshot_kwargs=dict(folder="Docs/Media/clean_screenshots"),
title="Excitatory Neuron Densities",
)
for i in np.arange(len(E_normalised)):
colour_value = tuple(Peace[i])
acronym = df.acronym[i]
scene_e.add_brain_regions([acronym], alpha=alpha,color=colour_value)
scene_e.render()
# Create a scene_i
scene_i = Scene(
#screenshot_kwargs=dict(folder="Docs/Media/clean_screenshots"),
title="Inhibitory Neuron Densities",
)
# Transparency
print(len(I_normalised))
Inhib = colorMap(I_normalised, name=ListedColormap(turbo_colormap_data),vmin=min(I_normalised),vmax=max(I_normalised))
for i in np.arange(len(I_normalised)):
colour_value = tuple(Inhib[i])
acronym = df.acronym[i]
scene_i.add_brain_regions([acronym], alpha=alpha,color=colour_value)
scene_i.render()
'''
# Create a scene
scene = Scene(
#screenshot_kwargs=dict(folder="Docs/Media/clean_screenshots"),
title="Brain",
)
scene.render()
'''