Thank you, Dr. Loewe.
I just had the chance to implement this example in my simulations.
This specific example simulates only discrete points in space to recover phie from. I rewrote the function writeECGgrid as writeEGMgrid as below. I hoped to simulate a 1 mm^3 spherical electrode, but this function gave me 28 discrete points instead, spaced by 0.5, within the bath to view unipolar EGMs.
---------------------------------------------------------
def writeEGMgrid(dim):
# centerline
xCtr = dim[0]/2
yCtr = dim[1]/2
z_endo = dim[2] + 0.5
xtemp = np.linspace((dim[0]/2)-0.5, (dim[0]/2)+0.5, int(((((dim[0]/2)+0.5) - ((dim[0]/2)-0.5))/0.5) + 1))
ytemp = np.linspace((dim[1]/2)-0.5, (dim[1]/2)+0.5, int(((((dim[1]/2)+0.5) - ((dim[1]/2)-0.5))/0.5) + 1))
ztemp = np.linspace((dim[2]), (dim[2])+1, int(((((dim[2])+1) - (dim[2])) / 0.5) + 1))
x, y, z = np.meshgrid(xtemp, ytemp, ztemp)
elecSpace = np.c_[x.ravel(), y.ravel(), z.ravel()]
T = spatial.cKDTree(elecSpace)
centre = np.asarray([xCtr, yCtr, z_endo])
elecElems = T.query_ball_point(centre,1)
# write a pts file
elecSpatialPts = np.array([xCtr*1e3, yCtr*1e3, z_endo*1e3])
for e in elecElems:
elecSpatialPts = np.vstack((elecSpatialPts,[elecSpace[e][0]*1e3, elecSpace[e][1]*1e3, elecSpace[e][2]*1e3]))
txt.write(os.path.join(CALLER_DIR, 'egm.pts'), elecSpatialPts)
---------------------------------------
Besides decreasing the stepsize of my spatial points, how can I simulate a solid sphere 1 mm^3? I also imagine I must postprocess these EGMs in Matlab, take their average to get a representative unipolar EGM from a solid spherical electrode. Is this correct?