remote control of OpenEphys

32 views
Skip to first unread message

Andrew Parker

unread,
Mar 19, 2025, 5:53:10 AMMar 19
to Open Ephys
Hello

I hope someone can help with the following issue about communication with Open ePhys through the http route.

I have several elements of this working perfectly according to the manual and helpful suggestions here. The openEphys is a 2022 working version on an up-to-date Windows computer.

I am using a MATLAB session to send http requests to openEphys. My goal is to insert a short text string into the openEphys data recording stream and let it acquire a timestamp marking the event. In practice the text string will be a unique filename for a single trial in a sequence of trials. Sending the trial filename allows us to identify sections of the openEphys recording. The accurate trial timing is then marked with recordings of onset/offset signals.

 When the MATLAB session is on the same computer as the openEphys session, this all works well. I can interrogate the state of openEphys with calls such as 

I can also send a text string with a call as suggested in the manual and find this string correctly in the recording/events/MessageCenter folder. So this pair of calls works fine:
out = webwrite(url, struct('text’,’MYFILE.name'), weboptions('RequestMethod','put','MediaType','application/json'));

When I try to do this remotely from another computer (Linux), I am finding that "read" requests work fine:
This returns correctly

However, "send" requests are rejected with a statement that 'put' is not an available option. I have turned off the Firewall and security on the Windows computer. 
*****
out = webwrite(url, struct('text’,’MYFILE.name'), weboptions('RequestMethod','put','MediaType','application/json'));
*****
These lines fail.

It seems that something is blocking my requests. Is there any experience within the group about additional changes to settings on a Windows computer that are required to make remote control of openEphys work properly?

One additional thing I should mention is that the other computer is Linux box with a somewhat outdated version of Ubuntu (v14) and MATLAB (2016). There’s not much I can do about that, without a lot of rearranging.

In anticipation.......


Amdrew Parker

Pavel Kulik

unread,
Mar 20, 2025, 7:30:22 PMMar 20
to Open Ephys
Hi Andrew,

We haven't seen this issue before. I just tested sending PUT requests to OpenEphys on my Windows machine from a MacBook and all is working. No special settings on my Windows machine.

Are both of your computers on the same network? Is there an error returned in MATLAB after you send the PUT request?

Andrew Parker

unread,
Mar 21, 2025, 8:49:12 AMMar 21
to Open Ephys
Pavel,

Thanks for these considerations. I can communicate OK under some circumstances but not others. From Linux/MATLAB to my MacDesktop/openEphys, all works fine. From LINUX/MATLAB to a different Windows/openEphys also fine. The one that is beating me is inevitably the one used in the lab. This should be Linux/MATLAB to Windows/openEphys. Two things are happening here. First I can make a status request and I receive back the usual "idle", "acquire", "record" flags, whichever is in flow on the Windows computer. Second, attempts to write a marker into the data stream with one of the approved calls from MATLAB fails with 

Expected RequestMethod to match one of these strings:
'auto', 'get', 'post'

The input 'put' does not match any of the valid strings.

Two things seem relevant.
(1) I must have some communication correctly configured, otherwise status requests would be rejected also.
(2) The same code for writing an event marker works fine over different communication channels.

It seems like something on the particular Windows computer is not letting 'put' requests through. As I am not really a Windows user, I am a bit lost as to what this block might be. As I mentioned in the first email, the firewall is off, because the computer is not connected to the wider internet.

Andrew

Pavel Kulik

unread,
Mar 21, 2025, 12:16:46 PMMar 21
to Open Ephys
Hi Andrew,

Thanks for the additional info. Sounds like MATLAB 2016 doesn't support 'PUT' requests in general? If upgrading MATLAB is not an option I just tested a workaround using Java in MATLAB. You can copy paste the code and replace localhost with your machine's IP to test. Let me know if that works!
import java.net.*
import java.io.*
% Define the URL and data
jsonData = '{"mode":"ACQUIRE"}';
% Create the Java URL and open a connection
urlObj = java.net.URL(url);
connection = urlObj.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod('PUT');
connection.setRequestProperty('Content-Type', 'application/json');
% Write the JSON data to the output stream
outputStream = connection.getOutputStream();
outputStream.write(uint8(jsonData));
outputStream.flush();
outputStream.close();
% Read the response
inputStream = connection.getInputStream();
reader = BufferedReader(InputStreamReader(inputStream));
response = '';
line = reader.readLine();
while ~isempty(line)
response = [response, char(line), newline]; %#ok<AGROW>
line = reader.readLine();
end
reader.close();
% Display the response
disp('Response from server:');
disp(response);
Reply all
Reply to author
Forward
0 new messages