Storing binary data in stimulus announcements
romesh is trying to replicate what you do with dots (outputting the x/y locations of every dot).
he noticed that you are stringing them along with no comma or delimiters. How do you then parse them out? Or are the number always a certain number of digits?
best
najib
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Christopher Sta... on 15 Oct, 2015 03:18 PM
Hi Najib,
I assume you're referring to this line from MovingDots.cpp:
The key point is that I'm not converting anything to a string. Rather, I'm taking the raw bytes from the
dotPositions
vector, casting them tochar *
(without modifying the data in any way), and then creating a string-typedDatum
from them. This is taking advantage of the facts that achar
holds one byte, and that basic C/C++ strings (and hence MWorks strings) are stored without any awareness of character encoding. Ultimately, the position data is not a string, and it would look very weird if you tried to print it out.To see how to unpack the position data from an event file, have a look at validateDotsData.m (or the Python equivalent, validate_dots_data.py). In both cases, you take the bytes of the "string" and cast them to a single-precision floating-point array.
Cheers,
Chris
Christopher Stawarz closed this discussion on 21 Oct, 2015 02:09 PM.