labstreaminglayer / App-LabRecorder

An application for streaming one or more LSL streams to disk in XDF file format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to start recording LabRecorder from a shortcut?

BCIstorm opened this issue · comments

I think the title says it all but here goes:
I have written a config file to pre-load all the required streams (with argument -c config_filename.cfg) but I would also like LabRecorder to start recording as soon as it is called (from batch file).
Is it possible? What is program argument?

It's currently not possible as you describe.

Without changing LabRecorder, the best you can do is use the remote control socket control and send it a command to start recording via another application. I'll post a C# sample on how to do that when I find it a little later.

I think this is a worthwhile feature to have though. Rather, I would add a checkbox that enables automatic recording start when all required streams are found. This isn't too difficult to do but I don't have time to do it today. If you want to try to modify LabRecorder this way then I can direct you.

I should also mention that there is a command-line-interface (CLI) version of LabRecorder. Here is an example from @agricolab on controlling / configuring LabRecorder CLI from a Python program: https://github.com/pyreiz/pyliesl/blob/master/liesl/files/labrecorder/cli_wrapper.py

Here are a few snippets of C# code we use to control LabRecorder through the remote-control-server:

For setting filename:

using System.Net.Sockets;

private Socket lrSocket;
private IPEndPoint ipe;

ipe = new IPEndPoint(IPAddress.Parse(LRInIP), LRInPort);
lrSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
lrSocket.Connect(ipe);

For filename control:

            string msg = "filename ";
            if (LRStudyRoot != "")
                msg += "{root:" + LRStudyRoot + "}";
            if (currentExperiment != "")
                msg += "{task:" + currentExperiment + "}";
            if (patientID != "")
                msg += "{participant:" + patientID + "}";
            if (sessionID != "")
                msg += "{session:" + sessionID + "}";
            if (acquisitionParams != "")
                msg += "{acquisition:" + acquisitionParams + "}";
            msg += "{modality:" + bidsModality.ToString() + "}";
            msg += "\n";

            Byte[] bytesSend = Encoding.UTF8.GetBytes(msg);
            return lrSocket.Send(bytesSend);

To start / stop recording:

string msg = "start\n";  // Or "stop\n";
Byte[] bytesSend = Encoding.UTF8.GetBytes(msg);
return lrSocket.Send(bytesSend);

I think the way I would modify LabRecorder is as follows...

here, I would add an else block with the following:

refreshStreams();
if (missing.empty() && ui->check_autostart->isChecked()) {
    startRecording();
}

We'd still need to add that checkbox to the GUI (default unchecked) and then hook it up to some config file parameters, but that's mostly copy-paste-modify examples that are already there.