In [1]:
import numpy as np
import matplotlib.pyplot as plt
import pickle
import sys
sys.path.insert(0,'../code/functions/')
In [9]:
def meanNorm(volume):
toStack = []
for plane in volume:
normFactor = (65535./float(np.max(plane)))
toStack.append(normFactor * np.array(plane))
return np.stack(toStack)
In [2]:
#get the data to test
data = pickle.load(open('../code/tests/synthDat/realDataRaw_t0.io', 'r'))
In [10]:
#generate the normalized data
normData = meanNorm(data)
In [16]:
#display 3 slices, one from top, middle, and bottom
sample = [0, 139, 279]
for idx in sample:
fig = plt.figure()
subPlt = fig.add_subplot(1,2,1)
plt.imshow(data[idx], cmap='gray')
plt.title('z='+ str(idx)+' Pre-Norm')
subPlt = fig.add_subplot(1, 2, 2)
plt.imshow(normData[idx], cmap='gray')
plt.title('z='+ str(idx)+' Post-Norm')
plt.show()
In [21]:
#Generate a line graph of average intensity in each slice, before and after norm
rawValList = [np.average(surface) for surface in data]
normValList = [np.average(surface) for surface in normData]
plt.figure()
plt.title('Average Slice Intensity vs Depth')
plt.scatter(np.arange(len(valList)), rawValList, c='b')
plt.scatter(np.arange(len(valList)), normValList, c='r')
plt.show()
In [28]:
#Generate a line graph of variance in each slice, before and after norm
rawValList = [np.var(surface) for surface in data]
normValList = [np.var(surface) for surface in normData]
plt.figure()
plt.title('Slice Variance vs Depth')
plt.scatter(np.arange(len(valList)), rawValList, c='b')
plt.scatter(np.arange(len(valList)), normValList, c='r')
plt.show()
In [ ]: