roi.y2 = img.shape[1] - 1
roi.z1 = roi.z2 = img.shape[0] / 2

predSingleSlice = model.predictWithChannels( img, eigV1, channels1, zAnisotropyFactor, useEarlyStopping=True, subROI=roi)


# show image & prediction side by side
plt.ion()
plt.figure()

plt.subplot(1,3,1)
plt.imshow(img[roi.z1,:,:],cmap="gray")
plt.title("Click on the image to exit")

plt.subplot(1,3,2)
plt.imshow(pred[roi.z1,:,:],cmap="gray")
plt.title("Click on the image to exit")

plt.subplot(1,3,3)
plt.imshow(predSingleSlice[roi.z1,:,:],cmap="gray")
plt.title("Click on the image to exit")

plt.ginput(1)

print "Serializing..."
ss = model.serialize()
print "Deserializing..."
model.deserialize( ss )
print "DONE."
#print "Serialization string: " + model.serialize()