In [1]:
%matplotlib inline
In [2]:
import pandas as pd
import numpy as np
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
In [3]:
sns.set(style='whitegrid')
In [11]:
firing_and_regions.one.resample('10ms', how='sum').plot()
Out[11]:
In [4]:
def inputs_and_regions_for(energy_name):
inputData = pd.read_csv('SampleLogs/{}_Input.csv'.format(energy_name), index_col='time', \
names= ['time', 'source', 'destination', 'inhibitor'])
regions = pd.read_csv('SampleLogs/{}_Region.csv'.format(energy_name), index_col='neuron', \
names=['neuron', 'region'])
lowerLimit = pd.to_datetime(5, unit='s')
inputData.index = pd.to_datetime(inputData.index, unit='ms')
inputData = inputData[lowerLimit:]
inputs_and_regions = inputData.join(regions, \
on='source').join(regions, \
on= 'destination', lsuffix='_src', rsuffix='_dst')
inputs_and_regions['efective_input'] = 1*(1-inputs_and_regions.inhibitor) -1*inputs_and_regions.inhibitor
answer = inputs_and_regions.groupby([inputs_and_regions.region_src == inputs_and_regions.region_dst, 'region_src']).\
efective_input.count().unstack().T
answer['total'] = answer.sum(axis=1)
answer = answer.rename(columns={True: 'within_regions', False:'between_regions'})
return answer
In [5]:
medium = inputs_and_regions_for('MediumConst')
In [6]:
medium.head()
Out[6]:
In [7]:
low = inputs_and_regions_for('LowConst')
In [8]:
low.head()
Out[8]:
In [9]:
high = inputs_and_regions_for('HighConst')
In [10]:
(medium-low).hist()
Out[10]:
In [11]:
(high-medium).hist()
Out[11]:
In [12]:
(high-low).hist()
Out[12]:
In [13]:
region_location = pd.read_csv('../static/models/regions.obj', header=None, sep=' ')
region_location.index = range(1, len(region_location)+1)
region_location = region_location.drop(0, axis=1)
region_location.columns = ['x', 'y', 'z']
region_location.head()
Out[13]:
In [14]:
merged = medium.join(region_location)
merged.head()
Out[14]:
In [15]:
def brain_heatmap(data):
merged = data.join(region_location)
fig = plt.figure(figsize=plt.figaspect(1/4.0))
for idx, column in enumerate(['within_regions', 'between_regions', 'total']):
ax = fig.add_subplot(1, 3,idx+1, projection='3d')
ax.set_title(column)
brain_heatmap_for(merged[column], ax, fig)
In [16]:
def brain_heatmap_for(data, ax, fig):
cmap = sns.cubehelix_palette(as_cmap=True, start=0.6, light=1, dark=0.1)
colors = cmap(data/data.max())
colmap = plt.cm.ScalarMappable(cmap=cmap)
colmap.set_array(data)
yg = ax.scatter(merged.x, merged.y, merged.z, c=colors, marker='o')
cb = fig.colorbar(colmap)
In [72]:
brain_heatmap(high-low)
In [73]:
brain_heatmap(high-medium)
In [74]:
brain_heatmap(medium-low)
In [17]:
region_names = pd.read_csv('1013090_DTI_region_names_full_file.txt')
region_names.head()
Out[17]:
In [18]:
region_names.index = region_names.index+1
In [19]:
high.join(region_names).sort_values('total', ascending=False).head(40)
Out[19]:
In [109]:
high.join(region_names).sort_values('total', ascending=True).head(40)
Out[109]:
In [106]:
high.join(region_names).sort_values('between_regions', ascending=False).head(20)
Out[106]:
In [107]:
(high-low).join(region_names).sort_values('between_regions', ascending=False).head(20)
Out[107]:
In [108]:
(high-low).join(region_names).sort_values('between_regions', ascending=False).tail(30)
Out[108]:
In [ ]: