It seems that the device I got had a different default configuration so the ASCII output format was not activated. According to the manual, sending the 'F' to the Fastrak only enables ASCII Output Format. If you send the command and this mode is already enabled, the command will not have any effect. In that sense, I do not think the new line could generate any problems with other devices. However, as you said, someone else should check this and find out if this causes problems.
My understanding is also that this extra line should not cause any problem for other Fastrak users. So I added it to the distribution. If it breaks something, we'll adjust when other users report it.
You can now update Brainstorm to get this fix.
Thank you for this contribution.
Hi everyone,
I'm encountering the same problem as discussed in this thread, but my setup uses the Patriot system instead of the Fastrak. I've reached out to Polhemus support regarding the issue, but they were not entirely sure about the cause. They did mention that the Patriot output is in binary format rather than ASCII.
In my current code, there's a section that handles the ASCII parsing for Fastrak. Should I similarly add a specific code block for Patriot? Or could it be that Brainstorm isn't designed to read binary data, and that's why I'm running into problems?
Any insights or suggestions on how to handle the binary format with Brainstorm would be greatly appreciated!
Thanks in advance,
Maxime
Hello Brainstorm Experts,
I am following up as I was able to fix the issue by changing the binary mode to ASCII. I can now successfully record positions with Polhemus through Brainstorm.
However, I am still uncertain about the precision of the recordings and continue to see some error messages in the MATLAB command window. Has anyone encountered similar issues or have suggestions on how to verify the accuracy of the recorded positions?
Thanks in advance for your help!
Best,
Maxime
Error reading data point. Try again.
If the problem persits, reset the serial connnection.
***** L1,1\r
Error reading data point. Try again.
If the problem persits, reset the serial connnection.
Error reading data point. Try again.
If the problem persits, reset the serial connnection.
Invalid Parameter!
Error reading data point. Try again.
If the problem persits, reset the serial connnection.
***** U,1\r
Error reading data point. Try again.
If the problem persits, reset the serial connnection.
@Marc.Lalancette, any thought on this?
Hello.
I was able to complete a full head digitization. I still encountered these errors when using the 2024 version, but everything seems to work fine in Legacy mode.
Best,
Maxime
Hi Maxime, that's difficult to diagnose remotely. I have only ever used the Fastrak here in the lab. When I converted to the new Matlab serial objects, I couldn't test Patriot. I don't have time to dig through the code now, but looks like it's not communicating properly with the Patriot. We'd have to compare the legacy version you modified (right?) and works to the 2024 version. The serial communication is done differently in both, so your fix might have to be applied slightly differently... Can you share what you changed?
My guess would be line termination. It seems there is a double CR.
The one in the configuration of the serial port for the case of Patriot, and the one in the message \r.
% Create connection
SerialConnection = serial(DigitizeOptions.ComPort, 'BaudRate', DigitizeOptions.ComRate);
if strcmp(DigitizeOptions.UnitType,'patriot')
SerialConnection.terminator = 'CR';
end
and
elseif strcmp(DigitizeOptions.UnitType,'patriot')
% request input from stylus
fprintf(SerialConnection,'%s\r','L1,1');
% Set units to centimeters
fprintf(SerialConnection,'%s\r','U1');
Also, the code for the Digitize panel indicates that the Patriot uses also ASCII configuration. Is that something you can change on your device?
elseif strcmp(DigitizeOptions.UnitType, 'patriot')
% This is patriot
% The factory default ASCII output record x-y-z-azimuth-elevation-roll is composed of
% 60 bytes (4 status bytes, 6 data words each 9 bytes long, and a CR LF terminator)
Hello Marc and Raymundo,
Thank you both for your help. I wanted to clarify that I did not modify any code in the Brainstorm panel_digitalization. Initially, I was unable to record anything, but I discovered that my serial port was configured in binary mode. I was able to resolve this by switching it to ASCII using PuTTY.
However, I’ve noticed an issue: when I use the legacy version of the digitizer, I don’t see any error codes in MATLAB. But when I use the 2024 version, I still encounter the same error code that I posted in my previous message.
Please let me know if you need more clarifications.
Best,
Maxime
Sorry it took me a long time to see this. I would tend to agree with Raymundo that's the next thing to try. If you're comfortable and willing, please try editing the code of file panel_digitize_2024.m
to remove the "\r". I checked and it's only found in the Patriot section on two lines, so you can search for and delete it, giving:
elseif strcmp(Digitize.Options.UnitType,'patriot')
% Request input from stylus
writeline(Digitize.SerialConnection,'L1,1'); % deleted '\r'
% Set units to centimeters
writeline(Digitize.SerialConnection,'U1'); % deleted '\r'
Let us know if that changes the errors. Unfortunately, we don't have a Patriot to do any testing ourselves.
Cheers
Hello Marc,
Thank you! The issue is now fixed.
All the best,
Maxime
@mperron8, did removing the '\r' solved the issue?
If so, to add the fix it in Brainstorm
@mperron8, any update regarding this question?
Yes, removing the '\r' solved the issue. Thanks again for your help!
@mperron8 and @Marc.Lalancette, These additional \r are now removed!
Commit: ff3ae10