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

import clearity as cl  # I wrote this module for easier operations on data
import clearity.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 [3]:
c = cl.Clarity('Fear197')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadNiiImg().imgToPoints(threshold=0.1,sample=0.11).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "Fear197.csv saved."
del c
gc.collect()


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

In [ ]:
c = cl.Clarity('globaleq')
    #fname = rs.HIST_DATA_PATH+token+".csv"
claritycsv = c.loadEqImg().imgToPoints(threshold=0.99,sample=0.008).savePoints()
    #np.savetxt(token,claritycsv,delimiter=',')
print "globaleq.csv saved."
del c
gc.collect()

In [7]:
import nibabel as nb
fear197 = nb.load('../data/raw/Fear197.nii')
globaleq = nb.load('../data/raw/globaleq.nii')
print fear197.shape
print globaleq.shape


(896, 576, 1087, 1)
(896, 576, 1087)

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


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-3-a60dd4fab8cb> in <module>()
      1 c = cl.Clarity('localeq')
      2     #fname = rs.HIST_DATA_PATH+token+".csv"
----> 3 claritycsv = c.loadEqImg().imgToPoints(threshold=0.1,sample=0.11).savePoints()
      4     #np.savetxt(token,claritycsv,delimiter=',')
      5 print "Fear197.csv saved."

/Users/gui/claritycontrol/code/scripts/clearity/__init__.py in loadEqImg(self, path, info)
     46         if info:
     47             print(img)
---> 48         self._img = img.get_data()[:,:,:,0]
     49         self._shape = self._img.shape
     50         self._max = np.max(self._img)

IndexError: too many indices for array

In [99]:
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")


Fear187
Out[99]:

In [ ]:
thedata = np.genfromtxt('../data/points/globaleq.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 "globaleq"
py.iplot(fig, filename= "globaleq")

In [ ]:
thedata = np.genfromtxt('../data/points/localeq.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 "localeq"
py.iplot(fig, filename= "localeq")