Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampling frequency #2

Open
mariaf3s opened this issue Feb 22, 2023 · 3 comments
Open

sampling frequency #2

mariaf3s opened this issue Feb 22, 2023 · 3 comments

Comments

@mariaf3s
Copy link

mariaf3s commented Feb 22, 2023

Hello,
In the vernier graphical analysis app there is a way to increase the sampling frequency, but is there a way to do this through python for use with LSL? Thank you!

@agricolab
Copy link
Collaborator

Hey @mariaf3s, because the app wraps godirect-py, theoretically, yes: https://github.com/VernierST/godirect-py/blob/main/godirect/device.py#L141

I found that this would work not very reliably on the devices i tested a couple of years ago. I therefore did not implement a CLI option to configure the sampling rate of the device - but that should not be too difficult to implement.

I currently have no longer any access to a Vernier device, which i would need to test and develop. Therefore you might to try to implement this functionality yourself.

@mariaf3s
Copy link
Author

thanks for responding! OK, that may be a little outside of my experience level but I'm open to try, any idea of where to point me to get started?

@agricolab
Copy link
Collaborator

agricolab commented Feb 23, 2023

Certainly.

According to godirect-py, one can give a period argument to device.start (see https://github.com/VernierST/godirect-py/blob/main/godirect/device.py#L141)

This method is called in verniersl during the starting of the Outlet: https://github.com/labstreaminglayer/app-vernier/blob/master/verniersl/__main__.py#L153

If you add a CLI argument like

        "--rate",
        type=int,
        default=-1,
        help="""Sets the sampling rate of the device, defaults to -1 (which takes the typical data rate for this device)""",
    )

and give this to the Outlet instantiation as an additional argument https://github.com/labstreaminglayer/app-vernier/blob/master/verniersl/__main__.py#L281
like

rate = device.get_default_period() if args.rate <0 else args.rate
o = Outlet(device=device, enable=enable, rate=rate)

In Outlets init, store the rate as self.rate and in https://github.com/labstreaminglayer/app-vernier/blob/master/verniersl/__main__.py#L152 it is then passed over to

stream = device_to_stream(device, self.rate)
device.start(self.rate)

(obviously, adapt device_to_stream to accomodate the new sampling rate (which is currently set to irregular, as - i mentioned earlier - i found it to be not as stable as i expected.

Good Luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants