You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, it's me again.
Thanks for your support, we have managed to improve our reconstructed image quality.
We are currently developing a feature to read data from the tank and plot the image along with the time. To achieve that, we modified the code as follows:
# coding: utf-8""" demo on dynamic eit using JAC method """# Copyright (c) Benyuan Liu. All Rights Reserved.# Distributed under the (new) BSD License. See LICENSE.txt for more info.from __future__ importabsolute_import, division, print_functionimportmatplotlib.pyplotaspltimportnumpyasnpimportpyeit.eit.jacasjacimportpyeit.meshasmeshfrompyeit.eit.femimportEITForwardfrompyeit.eit.interp2dimportsim2ptsfrompyeit.mesh.shapeimportthoraximportpyeit.eit.protocolasprotocolfrompyeit.mesh.wrapperimportPyEITAnomaly_Circleimportserialfromdatetimeimportdatetimeimporttimefrommatplotlib.animationimportFuncAnimation"""-2. Initial vars """arduino=serial.Serial('COM8', 115200 ,timeout=4)
v0=np.loadtxt('example_data/ref_data.txt')
fig, ax=plt.subplots(constrained_layout=True)
n_el=16"""-1. Functions """'''To read data from Arduino via COM portEach frame is 16 lines, each line has 13 values, in total there are 208 values representing the voltage measured from electrodes. Frames are separated by an enter character.'''defreadfromArduino():
while(True):
try:
data=arduino.readline().decode('ascii')
print("data: ", data)
breakexceptUnicodeDecodeError:
print("UnicodeDecodeError found! Retrying...")
continuereturndatadefget_difference_img_array(n_el=n_el, NewFrameSearchFlag=1, idx=0):
difference_image_array=''# Read difference image f1:whileidx<n_el:
data=readfromArduino()
#skip until the empty line is found to catch the whole framewhile(NewFrameSearchFlag==1):
iflen(data) <4:
print("Searching for new frame.")
data=readfromArduino()
continueelse:
print("New frame found.")
data=readfromArduino()
NewFrameSearchFlag=0breakdata=data.strip('\r\n')
difference_image_array+=datadifference_image_array+=' 'idx=idx+1#print("String: {0}".format(data))returndifference_image_array#Convert data to np typedefconvert_data_in(s):
data=sitems=[]
foritemindata.split(' '):
item=item.strip()
ifnotitem:
continuetry:
items.append(float(item))
exceptValueError:
print("Value Error found! Handling...")
items.append(float(0))
returnnp.array(items)
""" 0. build mesh """n_el=16# nb of electrodesuse_customize_shape=Falseifuse_customize_shape:
# Mesh shape is specified with fd parameter in the instantiation, e.g : fd=thoraxmesh_obj=mesh.create(n_el, h0=0.065, fd=thorax)
else:
mesh_obj=mesh.create(n_el, h0=0.065)
# extract node, element, alphapts=mesh_obj.nodetri=mesh_obj.elementx, y=pts[:, 0], pts[:, 1]
""" 1. problem setup """# mesh_obj["alpha"] = np.random.rand(tri.shape[0]) * 200 + 100 # NOT USEDanomaly=PyEITAnomaly_Circle(center=[0.5, 0.5], r=0.1, perm=1000.0)
mesh_new=mesh.set_perm(mesh_obj, anomaly=anomaly)
""" 2. FEM simulation """# setup EIT scan conditionsprotocol_obj=protocol.create(n_el, dist_exc=1, step_meas=1, parser_meas="fmmu")
# calculate simulated datafwd=EITForward(mesh_obj, protocol_obj)
#v0 = fwd.solve_eit()#v1 = fwd.solve_eit(perm=mesh_new.perm)""" 3. JAC solver """# Note: if the jac and the real-problem are generated using the same mesh,# then, data normalization in solve are not needed.# However, when you generate jac from a known mesh, but in real-problem# (mostly) the shape and the electrode positions are not exactly the same# as in mesh generating the jac, then data must be normalized.eit=jac.JAC(mesh_obj, protocol_obj)
eit.setup(p=0.5, lamb=0.001, method="kotre", perm=1000, jac_normalized=True)
defanimating(i):
whilearduino.inWaiting()==0:
print("waiting")
time.sleep(0.5)
passs1=get_difference_img_array()
v1=convert_data_in(s1)
try:
ds=eit.solve(v1, v0, normalize=True)
exceptExceptionase:
ani.event_source.stop() # Stop the current animation if error occurredani.event_source.start() # Start a new animationds_n=sim2pts(pts, tri, np.real(ds))
# Clear the graph after each animating frameax.clear()
# plot EIT reconstructionim=ax.tripcolor(x, y, tri, ds_n, shading="flat", cmap=plt.cm.magma)
fori, einenumerate(mesh_obj.el_pos):
ax.annotate(str(i+1), xy=(x[e], y[e]), color="r")
ax.set_aspect("equal")
# plt.savefig('../doc/images/demo_jac.png', dpi=96)ani=FuncAnimation(fig, animating, interval=50, cache_frame_data=False)
plt.show()
It is noteworthy that our electrodes were messy, and there are obvious contact problems with some, which severely affect the quality of the reconstructed image. Still, it should not be a big problem since we can replace them in no time. Besides, it works. We managed to show the movement of the objects inside our tank. You can watch the video at this Google Drive link: https://drive.google.com/drive/folders/1Y_9w8cCYSJimbiGiwunk6UIfk7JaeHzk?usp=sharing
However, it's clear to be seen that our fps is a little bit modest, and some frames are bad-reconstructed (we are currently fixing our hardware so the signal will me much more stable which should fix this problem).
I would like to ask you (and all other people who are reading this issue) to take a look at my code and give me some feedback.
Is there a better way to do this real-time data plotting? Please enlighten me.
Thank you so much!
The text was updated successfully, but these errors were encountered:
Hi Kiet,
I, Dung Trinh, have worked on EIT for a while. I am glad to know you are also working on this device.
Are you open to connect and discuss about this technology? - my facebook is https://www.facebook.com/Genji0306
Regards,
Steve Trinh
@TooNakko Hi, we use pyqtgraph for real time ploting and EIT imaging visualization. It is very fluent for a prototyping app, but for serious application, you may consider C++.
Hi, it's me again.
Thanks for your support, we have managed to improve our reconstructed image quality.
We are currently developing a feature to read data from the tank and plot the image along with the time. To achieve that, we modified the code as follows:
It is noteworthy that our electrodes were messy, and there are obvious contact problems with some, which severely affect the quality of the reconstructed image. Still, it should not be a big problem since we can replace them in no time. Besides, it works. We managed to show the movement of the objects inside our tank. You can watch the video at this Google Drive link: https://drive.google.com/drive/folders/1Y_9w8cCYSJimbiGiwunk6UIfk7JaeHzk?usp=sharing
However, it's clear to be seen that our fps is a little bit modest, and some frames are bad-reconstructed (we are currently fixing our hardware so the signal will me much more stable which should fix this problem).
I would like to ask you (and all other people who are reading this issue) to take a look at my code and give me some feedback.
Is there a better way to do this real-time data plotting? Please enlighten me.
Thank you so much!
The text was updated successfully, but these errors were encountered: