Closed fdkfla closed 9 years ago
This is probably fixed in the newer version hemokit-0.6.5
that I just uploaded to Hackage.
Can you cabal update
and try again?
it's worked ! thank you so much for your effort.
@fdkfla
Regarding your interfacing with Matlab question, you can do something like this:
hemokit-dump --format spaced --serve 127.0.0.1:1234
This serves the data via a local TCP port, and you have to read it from Matlab.
What you have to do now is similar to this tutorial:
http://www.mathworks.co.uk/help/instrument/writing-and-reading-data_f16-57447.html In Matlab, do something like:
t = tcpip('127.0.0.1', 1234);
fopen(t)
data = fscanf(t, '%d');
And check out whether there's something useful in data
.
You can call fscanf multiple times to read the next values; there are 32 values for each packet from the EEG.
It space-separates all values in the order [counter] [battery] [gyroX] [gyroY] [sensors (14 values)] [qualities (14 values)]
.
You can also get the data out as binary, but I recommend try it with the text format (--format spaced
) first.
Let me know whether it works - then we can make a Wiki page out of it.
thank you for your intereset. I have tried what you suggest, but after many trials, it's seems that the case is not easy, however when the data are text format, is that mean that they are characters? if I have the following data, how it will transfer?
EmotivState {counter = 34, battery = 70, gyroX = 115, gyroY = -39, sensors = fromList [8769,7945,8113,8658,8455,8767,8857,8351,7744,9585,8141,8019,8177,9101], qualities = fromList [24,24,0,0,8,24,16,0,0,8,16,8,16,24]}
from my trials, I belive that the solution is in the following function data = fread(t,32,'int16')
, where t
is an TCP object, that function tells to read 32 int16 value at a time, but it's read the wrong data.
if I have the following data, how it will transfer? EmotivState {counter = 34, battery = 70, gyroX = 115, gyroY = -39, sensors = fromList [8769,7945,8113,8658,8455,8767,8857,8351,7744,9585,8141,8019,8177,9101], qualities = fromList [24,24,0,0,8,24,16,0,0,8,16,8,16,24]}
You should use the --format spaced
option, then the data will look like this:
$ ./hemokit-dump --format spaced
48 0 646 -1636 14260 5451 6184 15047 13613 6573 15294 9075 5637 9415 8906 4214 16064 4322 0 0 0 0 0 0 0 0 0 0 0 0 0 0
128 0 288 -1082 16339 731 9041 5104 3837 6126 1916 14906 9550 2759 10431 5920 6503 14713 0 0 0 0 0 0 0 0 0 0 0 0 0 0
42 0 -1340 -1270 3461 9534 11386 15808 9507 5725 3030 12763 6679 8898 3755 13544 2893 10611 0 0 0 0 0 0 0 0 0 0 0 0 0 0
...
Let me know how that works!
the fscanf
function will return the readed value iif
I don't think you need to set the terminator when using data = fscanf(t, '%d');
, it will automatically split the data by white space.
Also, there are already \n
characters in the output - \n
is the newline at the end of each line.
Hey again :)
Yes your right, the problem is not what I was think. but I have a few questions, the first one is that the option --format sensorbytes
gives the reading of sensors without "headers" i.e the positions,the battery status? because I use it and I have succeed in recieving it to matlab.
The second question is how can I ensure that those values are for the same reading or trials (I will use the word trial to point on that ),for example for a single trial we have 14 values from sensors, but how to ensure that it does not read the last 10 readings of a trial, and the other 4 readings is for the first 4 readings of next trial ?
The third question is how to be sure that this will not allow to mis any trials? for example if I have three trials a,b and d which are follow each other, a then b then d,so how to be sure that we are not mis b?
May you say "oh! you complicate stuff !" , and you are totally right, but Im work for a Project, and I want to be sure that my system works correctly, also those questions will make the readers who will see this conservation to be more convenient to use matlab to get data from hemokit.
all the talk in the last comment will be shorted in the following question :) :
--format sensorbytes
, it will send the 14 value of the sensors at the same time, or it will send them one by one?a few questions, the first one is that the option --format sensorbytes gives the reading of sensors without "headers" i.e the positions,the battery status?
No, --format sensorbytes
only gives you the sensors, it does not include counter, battery, gyroX, gyroY, or sensor qualities. That is because it was made to be an input to OpenVibe, which only cares about sensors.
If you need that data I recommend using --format spaced
instead. I recommend this in general - the EEG generates so little data per second that you will not notice any meaninful performance boost by using a binary protocol.
when hemokit send the data with --format sensorbytes, it will send the 14 value of the sensors at the same time, or it will send them one by one?
how can I ensure that those values are for the same reading or trials
The answer to the two questions above is: With --format sensorbytes
Hemokit always sends values in chunks of 14 sensors. When you connect to the TCP server and read the first 14 values, you will get all and exactly the values from the current "trial". The next 14 values will then be for the next trial, and so on. TCP ensures that no value is lost in the middle; this makes sure that you don't read across "trials".
This is the same for --format spaced
, just that it's more values there, and that you get an additional check: Each "trial" is separated by a newline (\n
).
I tried to load hemokit by the command
cabal install hemokit
, but the following error appear: ` [4 of 4] Compiling Hemokit.Start ( src/Hemokit/Start.hs, dist/build/Hemokit/Start.o ) In-place registering hemokit-0.6.4... Preprocessing executable 'hemokit-mouse' for hemokit-0.6.4... [1 of 1] Compiling Main ( apps/Mouse.hs, dist/build/hemokit-mouse/hemokit-mouse-tmp/Main.o )apps/Mouse.hs:29:20: Ambiguous occurrence
connect' It could refer to either
Graphics.XHB.Connection.connect', imported fromGraphics.XHB.Connection' at apps/Mouse.hs:6:43-49 or
Test.Robot.connect', imported fromTest.Robot' at apps/Mouse.hs:9:1-27 (and originally defined in
Test.Robot.Internal')apps/Mouse.hs:38:7: Not in scope:
runRobotWithConnection' Failed to install hemokit-0.6.4 cabal: Error: some packages failed to install: hemokit-0.6.4 failed during the building phase. The exception was: ExitFailure 1
Then I tried to build the source code, it's give me the above message, after run the commandsudo runhaskell Setup.hs build
, the following messaeg appear:` Preprocessing executable 'hemokit-mouse' for hemokit-0.6.4... [1 of 1] Compiling Main ( apps/Mouse.hs, dist/build/hemokit-mouse/hemokit-mouse-tmp/Main.o )
apps/Mouse.hs:29:20: Ambiguous occurrence
connect' It could refer to either
Graphics.XHB.Connection.connect', imported fromGraphics.XHB.Connection' at apps/Mouse.hs:6:43-49 or
Test.Robot.connect', imported fromTest.Robot' at apps/Mouse.hs:9:1-27 (and originally defined in
Test.Robot.Internal')apps/Mouse.hs:38:7: Not in scope:
runRobotWithConnection'
note that both robotand
xhb` are installed.