Model
F(X,Y) | ~ Histogram Data
a) $F(I,k) = \{ F(I|k)*F(k) \}$
$F(k)= \{0,1\}$
b) $F(I,k) = \{ F(I|k)*F(k) \}$
$F(k)= \{0,1\}$
Assumption
H0:
$F(I,0) < ||= F(I,1)$
The maximum gray value for Cocaine stimulated brain is equal to the control brain.
HA:
$F(I,0) > || != F(I,1)$
The maximum gray value for Cocaine stimulated brain is greater than the control brain.
$P_n$ = Number of pixels of intensity n / Total number of pixels
$F(I) = mean (F(i,j))$ % mean gray value in the image
In order to run the program, we need to install the packages in python
PyQt4 install from tar file
SIP install from tar file
matplotlib,numpy,jgraph,vispy,nibabel (use pip install or pip2 install)
In [1]:
import os
PATH="/Users/david/Desktop/CourseWork/TheArtOfDataScience/claritycontrol/code/scripts/" # use your own path
os.chdir(PATH)
import clarity as cl # I wrote this module for easier operations on data
import matplotlib.pyplot as plt
import jgraph as ig
%matplotlib inline
In [2]:
# create a instance
c = cl.Clarity("Fear199")
# load image, to points # takes a while to process the data
# * threshold rate is used to cut off some noise data.
# * sample is sampling rate
# show histogram
c.loadImg().imgToPoints(threshold=0.02,sample=0.3).showHistogram(bins=256)
In [3]:
b = cl.Clarity("Cocaine174")
b.loadImg(info=False).imgToPoints(threshold=0.08,sample=0.1).showHistogram(bins=256)
In [4]:
a = cl.Clarity("Control239")
a.loadImg(info=False).imgToPoints(threshold=0.04,sample=0.3).showHistogram(bins=256)
In [ ]:
# save points to csv file
# load directly from points data, instead of the origin data
c.loadImg().imgToPoints(threshold=0.04,sample=0.5).savePoints()
# load from points data file
# show on 3D graph, GPU intensive
c.loadPoints().show()
In [5]:
# A screen shot
from IPython.display import Image
from IPython.core.display import HTML
Image(url= "https://raw.githubusercontent.com/Upward-Spiral-Science/claritycontrol/master/figs/a04/3dvisualdemo.png")
Out[5]:
We can infer from the histogram plots that the maximum gray values in cocaine stimulated brain is higher than the control brain. This is conclusive with the alternative hypothesis. This also agrees with literature that indicates that the brain is more active when stimulated by cocaine, thereby lighting up more than the control brain.