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

Reading continuous data with cbpy #88

Closed
jsv13 opened this issue May 12, 2018 · 9 comments
Closed

Reading continuous data with cbpy #88

jsv13 opened this issue May 12, 2018 · 9 comments

Comments

@jsv13
Copy link

jsv13 commented May 12, 2018

I manage to retrieve events from nPlayServer with cbpy, but I cannot get continuous data. Streaming continuous data is on, e.g. I can get them via the cbSDK.
Can anyone provide an example showing how to get continuous data in cbpy?
thanks!

@cboulay
Copy link
Collaborator

cboulay commented May 12, 2018

I wrote a convenience class for myself that wraps cbpy that I use in a few different applications.
You can see how I get continuous data here.

@zeeMonkeez
Copy link

@cboulay how do you match sample times between events and continuous data in this use case? cbMex returns a common time base, but it's not clear to me how cbpy might expose that...

@cboulay
Copy link
Collaborator

cboulay commented May 14, 2018

@zeeMonkeez Hi Jonas. Sorry I can't look into it right now. (going to Asilomar? I am nowhere near ready)

Anyway, there's a recently contributed get_data function in the 7.0 branch here. This fetches events and continuous data together in one function after a reset. The timestamps of the events should be offset from the 0th sample of the continuous data.

I haven't had a need for this because my I'm either looking at these things independently, or I'm looking at them offline loaded from .nev/.nsx files, but I think that's going to change.

@zeeMonkeez
Copy link

@cboulay Hey Chad, thanks I'll have a look. No, Asilomar didn't fit in my schedule. I'll be in Minneapolis in June, though, will you be there? Seems like you're up to doing some cool things, it'd be cool to chat...

@cboulay
Copy link
Collaborator

cboulay commented Nov 12, 2018

@jsv13 Very late reply, but in case anyone else encounters this, I've noticed that channels coming from the Analog Inputs aren't replayed by nPlayServer.

@stinos
Copy link
Contributor

stinos commented Dec 17, 2018

I've noticed that channels coming from the Analog Inputs aren't replayed by nPlayServer.

According to Blackrock support this is a known bug in the current version 7, a fix is upcoming, and it should also not happen in nPlayServer versions 6.5.4 and below.

@cboulay
Copy link
Collaborator

cboulay commented Dec 17, 2018

Closing. Use #97

@cboulay cboulay closed this as completed Dec 17, 2018
@agamemnonc
Copy link

agamemnonc commented Jul 19, 2019

I am also trying to read continuous data only using cbpy and have encountered the following issue.

I have a main program which queries the device for new data continuously (i.e., no sleep commands in-between). I have set the continuous_length in buffer_parameter to the desired samples I want to read per every read operation.

from cerebus import cbpy
samples_per_read = 100

buffer_parameter = {
    'double': True,
    'continuous_length': samples_per_read 
}
result, _ = cbpy.trial_config(
    reset=True,
    buffer_parameter=buffer_parameter)

def read():
    result, trial = cbpy.trial_continuous(reset=True)
    data = process(trial)
    return data

Now, ideally I would want to continuously read data in a loop, such that execution is blocked until the new data become available, something like:

while True:
   data = read()

I would expect program execution to be blocked until data become available since continuous_length is set to the desired number of samples per read operation, but what I rather observe is that a smaller number of samples is read and after a little bit, when no samples are available , an exception is raised. Is this expected behaviour?

Alternatively, I could set the number of samples per read to 1 and internally check if the desired samples have been read, but querying the device sample by sample sounds a bit like an overkill.

Any ideas? Thanks.

@cboulay
Copy link
Collaborator

cboulay commented Jul 19, 2019

It would be a non-trivial amount of work to add a timeout parameter to SdkGetTrialData. It's tricky to do correctly and I don't have time for that right now.

The simplest solution is to buffer the data on the client side. Or, better yet, have your analysis pipeline be flexible to the number of samples it receives (ultimately that usually means buffering at some stage).

If you want to make an argument for a blocking call to fetch data or you want to propose a way to do that then please open a new issue.

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

5 participants