1. The relationship between unmasked and synapses is linear

The count of synapses is related linearly to the unmasked value at maximum, and is zero at minimum.

(Super intuitive, but it's good to confirm it!)


In [4]:
%matplotlib inline

In [5]:
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns


:0: FutureWarning: IPython widgets are experimental and may change in the future.

In [6]:
import csv

data = open('../data/data.csv', 'r').readlines()
fieldnames = ['x', 'y', 'z', 'unmasked', 'synapses']
reader = csv.reader(data)
reader.next()

rows = [[int(col) for col in row] for row in reader]

sorted_x = sorted(list(set([r[0] for r in rows])))
sorted_y = sorted(list(set([r[1] for r in rows])))
sorted_z = sorted(list(set([r[2] for r in rows])))

vol = np.zeros((len(sorted_x), len(sorted_y), len(sorted_z)))
for r in rows:
    vol[sorted_x.index(r[0]), sorted_y.index(r[1]), sorted_z.index(r[2])] = r[-1]

In [7]:
x = [r[3] for r in rows]
y = [r[4] for r in rows]
plt.scatter(x=x, y=y, c='c')
plt.hold(True)
plt.plot([0, 150000], [0, 512], color="r")
plt.plot([0, 150000], [0, 300], color="r")
plt.xlabel("Unmasked Count")
plt.ylabel("Synapse Count")
plt.title("Synapse count with regards to unmasked count", fontdict={
        'fontsize': '16',
        'fontweight': 'bold'
})
plt.hold(False)


/usr/local/lib/python2.7/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):

In general, synapse count is sublinearly related to the unmasked count.

2. Heatmap of density over data


In [1]:
from PIL import Image
import urllib, cStringIO

file = cStringIO.StringIO(urllib.urlopen("http://openconnecto.me/ocp/ca/bock11/image/xy/7/0,1050/0,936/2917/").read())
img = Image.open(file)
img_array = np.array(img)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-1-2122421ccba0> in <module>()
      2 import urllib, cStringIO
      3 
----> 4 file = cStringIO.StringIO(urllib.urlopen("http://openconnecto.me/ocp/ca/bock11/image/xy/7/0,1050/0,936/2917/").read())
      5 img = Image.open(file)
      6 img_array = np.array(img)

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc in urlopen(url, data, proxies, context)
     85         opener = _urlopener
     86     if data is None:
---> 87         return opener.open(url)
     88     else:
     89         return opener.open(url, data)

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc in open(self, fullurl, data)
    211         try:
    212             if data is None:
--> 213                 return getattr(self, name)(url)
    214             else:
    215                 return getattr(self, name)(url, data)

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.pyc in open_http(self, url, data)
    348         if realhost: h.putheader('Host', realhost)
    349         for args in self.addheaders: h.putheader(*args)
--> 350         h.endheaders(data)
    351         errcode, errmsg, headers = h.getreply()
    352         fp = h.getfile()

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in endheaders(self, message_body)
   1047         else:
   1048             raise CannotSendHeader()
-> 1049         self._send_output(message_body)
   1050 
   1051     def request(self, method, url, body=None, headers={}):

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in _send_output(self, message_body)
    891             msg += message_body
    892             message_body = None
--> 893         self.send(msg)
    894         if message_body is not None:
    895             #message_body was not a string (i.e. it is a file) and

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in send(self, data)
    853         if self.sock is None:
    854             if self.auto_open:
--> 855                 self.connect()
    856             else:
    857                 raise NotConnected()

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in connect(self)
    830         """Connect to the host and port specified in __init__."""
    831         self.sock = self._create_connection((self.host,self.port),
--> 832                                            self.timeout, self.source_address)
    833 
    834         if self._tunnel_host:

/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc in create_connection(address, timeout, source_address)
    555     host, port = address
    556     err = None
--> 557     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    558         af, socktype, proto, canonname, sa = res
    559         sock = None

KeyboardInterrupt: 

In [ ]:
plt.imshow(img_array)
plt.hold(True)
plt.axis('off')
#plt.scatter(x=[r[0]/4.2 for r in rows], y=[(r[1]/3)-350 for r in rows], 'r-', alpha=0.2)