In [2]:
import os
PATH="/Users/albertlee/claritycontrol/code/scripts/" # use your own path
os.chdir(PATH)

import clarity as cl  # I wrote this module for easier operations on data
import clarity.resources as rs
import csv,gc  # garbage memory collection :)

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
import jgraph as ig

import plotly
import plotly.plotly as py
import plotly.graph_objs as go

%matplotlib inline

In [5]:
c = cl.Clarity('Cocaine174')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.4,sample=0.5).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Cocaine174.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Cocaine174.img
Coverting to points...
token=Cocaine174
total=751091775
max=3693.000000
threshold=0.400000
sample=0.500000
(This will take couple minutes)
Above threshold=70334
Samples=35210
Finished
Cocaine174.csv saved.
Out[5]:
0

In [18]:
c = cl.Clarity('Cocaine175')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.1,sample=0.07).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Cocaine175.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Cocaine175.img
Coverting to points...
token=Cocaine175
total=591495168
max=7136.000000
threshold=0.100000
sample=0.070000
(This will take couple minutes)
Above threshold=539201
Samples=37866
Finished
Cocaine175.csv saved.
Out[18]:
0

In [34]:
c = cl.Clarity('Cocaine178')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.2,sample=0.07).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Cocaine178.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Cocaine178.img
Coverting to points...
token=Cocaine178
total=606486528
max=4654.000000
threshold=0.200000
sample=0.070000
(This will take couple minutes)
Above threshold=553499
Samples=38806
Finished
Cocaine178.csv saved.
Out[34]:
0

In [11]:
c = cl.Clarity('Control181')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.4,sample=0.35).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Control181.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Control181.img
Coverting to points...
token=Control181
total=449253376
max=4230.000000
threshold=0.400000
sample=0.350000
(This will take couple minutes)
Above threshold=102758
Samples=36051
Finished
Control181.csv saved.
Out[11]:
0

In [40]:
c = cl.Clarity('Control182')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.1,sample=0.4).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Control182.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Control182.img
Coverting to points...
token=Control182
total=414695424
max=14589.000000
threshold=0.100000
sample=0.400000
(This will take couple minutes)
Above threshold=92917
Samples=37065
Finished
Control182.csv saved.
Out[40]:
0

In [52]:
c = cl.Clarity('Control189')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.02,sample=0.18).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Control189.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Control189.img
Coverting to points...
token=Control189
total=709795840
max=32767.000000
threshold=0.020000
sample=0.180000
(This will take couple minutes)
Above threshold=218433
Samples=39305
Finished
Control189.csv saved.
Out[52]:
0

In [57]:
c = cl.Clarity('Control239')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.2,sample=0.11).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Control239.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Control239.img
Coverting to points...
token=Control239
total=675840000
max=3742.000000
threshold=0.200000
sample=0.110000
(This will take couple minutes)
Above threshold=354342
Samples=39044
Finished
Control239.csv saved.
Out[57]:
0

In [64]:
c = cl.Clarity('Control258')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.03,sample=0.099).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Control258.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Control258.img
Coverting to points...
token=Control258
total=577237481
max=32767.000000
threshold=0.030000
sample=0.099000
(This will take couple minutes)
Above threshold=398853
Samples=39907
Finished
Control258.csv saved.
Out[64]:
0

In [72]:
c = cl.Clarity('Fear187')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.1,sample=0.11).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Fear187.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Fear187.img
Coverting to points...
token=Fear187
total=560996352
max=10320.000000
threshold=0.100000
sample=0.110000
(This will take couple minutes)
Above threshold=344963
Samples=37897
Finished
Fear187.csv saved.
Out[72]:
0

In [74]:
c = cl.Clarity('Fear197')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.05,sample=0.5).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Fear197.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Fear197.img
Coverting to points...
token=Fear197
total=584130560
max=32767.000000
threshold=0.050000
sample=0.500000
(This will take couple minutes)
Above threshold=76129
Samples=38487
Finished
Fear197.csv saved.
Out[74]:
0

In [80]:
c = cl.Clarity('Fear199')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.05,sample=0.125).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Fear199.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Fear199.img
Coverting to points...
token=Fear199
total=600735744
max=10950.000000
threshold=0.050000
sample=0.125000
(This will take couple minutes)
Above threshold=306348
Samples=38316
Finished
Fear199.csv saved.
Out[80]:
0

In [91]:
c = cl.Clarity('Fear200')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadImg().imgToPoints(threshold=0.05,sample=0.26).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Fear200.csv saved."
del c
gc.collect()


Image Loaded: ../data/raw/Fear200.img
Coverting to points...
token=Fear200
total=572866560
max=32767.000000
threshold=0.050000
sample=0.260000
(This will take couple minutes)
Above threshold=149406
Samples=38953
Finished
Fear200.csv saved.
Out[91]:
0

In [69]:
thedata = np.genfromtxt('../data/points/Cocaine174.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Cocaine174"
py.iplot(fig, filename= "Cocaine174")


Cocaine174
Out[69]:

In [92]:
thedata = np.genfromtxt('../data/points/Cocaine175.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Cocaine175"
py.iplot(fig, filename= "Cocaine175")


Cocaine175
Out[92]:

In [93]:
thedata = np.genfromtxt('../data/points/Cocaine178.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Cocaine178"
py.iplot(fig, filename= "Cocaine178")


Cocaine178
Out[93]:

In [94]:
thedata = np.genfromtxt('../data/points/Control181.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Control181"
py.iplot(fig, filename= "Control181")


Control181
Out[94]:

In [95]:
thedata = np.genfromtxt('../data/points/Control182.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Control182"
py.iplot(fig, filename= "Control182")


Control182
Out[95]:

In [96]:
thedata = np.genfromtxt('../data/points/Control189.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Control189"
py.iplot(fig, filename= "Control189")


Control189
Out[96]:

In [97]:
thedata = np.genfromtxt('../data/points/Control239.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Control239"
py.iplot(fig, filename= "Control239")


Control239
Out[97]:

In [98]:
thedata = np.genfromtxt('../data/points/Control258.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Control258"
py.iplot(fig, filename= "Control258")


Control258
Out[98]:

In [99]:
thedata = np.genfromtxt('../data/points/Fear187.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Fear187"
py.iplot(fig, filename= "Fear187")


Fear187
Out[99]:

In [100]:
thedata = np.genfromtxt('../data/points/Fear197.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Fear197"
py.iplot(fig, filename= "Fear197")


Fear197
Out[100]:

In [101]:
thedata = np.genfromtxt('../data/points/Fear199.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Fear199"
py.iplot(fig, filename= "Fear199")


Fear199
Out[101]:

In [102]:
thedata = np.genfromtxt('../data/points/Fear200.csv', delimiter=',', dtype='int', usecols = (0,1,2), names=['a','b','c'])

trace1 = go.Scatter3d(
    x = thedata['a'],
    y = thedata['b'],
    z = thedata['c'],
    mode='markers',
    marker=dict(
        size=1,
        color='purple',                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.05
    )
)

data = [trace1]
layout = go.Layout(
    margin=dict(
        l=0,
        r=0,
        b=0,
        t=0
    )
)
    
fig = go.Figure(data=data, layout=layout)
print "Fear200"
py.iplot(fig, filename= "Fear200")


Fear200
Out[102]: