-
Notifications
You must be signed in to change notification settings - Fork 22
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
cbmex 'trialdata' returns 'digin' times but NOT values #103
Comments
Is the channel sampling set in Central? |
I believe so. In the 'Hardware Configuration' panel of Central, when I click on 'Digital In', it gives me one channel called 'digin', set to '16-bit on rising edge'. With the old v4 firmware and cbmex, this setting resulted in digin times and values being returned by cbmex( 'trialdata' , ... ). |
Can you explicitly set the buffer params in trial_config_params = {
'buffer_parameter' : {
'double' : True,
'continuous_length' : 35000,
'event_length' : 35000,
'absolute' : True,
}
}
cbpy.trial_config(**trial_config_params) I wonder if |
Sorry, Dude. No Python, here. Though I could get that running for testing purposes. Can the same be achieved in Matlab with something like: |
I think you should not use |
Okay, I tried both of these:
But I still have the same problem. I can confirm that the .nev files created by Central's 'File Storage' application contain the digital input times AND values. So, it would seem that something is being lost by cbmex. We seem to be getting normal behaviour with the front-end channels. |
Thanks for the edit. I was just about to ask that. Can you confirm that the latest nPlayServer plays back digital channels (known bug: it doesn't play back front panel analog input channels)? If it does then can you please attach a small dataset that has the digital data? If that works then I can try to debug from here without going through the hassle of connecting to my NSP and setting up a digital input. |
Er ... nPlayServer dies on me. That will take some fiddling. In the meantime, here is the test file I made with digital input. It steps through uint16 values 1 to 255 on the first 8 bits, then it steps through 1 to 255 again, but bitshifted up to the last 8 bits. You should get something like this:
In the meantime, if there's any other tests that I can run on our NSP then please let me know. |
I'm running the data through nPlayServer. Using cbpy, I see spikes on channels 1-128 and a set of 1021 events on channel 151, but all that's there is the timestamps. I'll spend a few minutes seeing if I can track down where the digital values should go, but @jsdpag I will wait to hear from you about whether or not you have the latest firmware before I do much more digging. |
I forgot to say that I had the Neural Signal Stimulator plugged in. So, Front End channels 1 to 128 will have spikes. Interesting that there are 1021 digital events. I guess your setup is counting any bit change as an event ; I got 510 but with "16-bit on rising edge" as the setting for the digin channel. Anyway, we're all up to date with firmware v7.0.4, the latest one available from the Blackrock Micro. website. Older versions v7.0.0 and v7.0.2 of the firmware had bugs with digital events, but Blackrock support says that 7.0.4 should be fine. I'm afraid that it looks like CereLink is the culprit. If there's any code testing I can do to help then please let me know. |
I'm looking at the Python code because I don't have Matlab on this machine... Here is where the 'events' field should get filled in. In the data returned by nPlayServer, Here is the bit of code inside cbsdk.cpp that assigns the channel number. I don't know what the Before I replace it with How about |
Just to verify, shall I test that edit on lines 2215/2216 of cbsdk.cpp? |
Please go ahead. I'm doing it here too but I'm also doing 3 other things and I have to leave in 30 minutes. |
Well, I made that edit to my local git project and rebuilt cbmex. But I still don't get digital input values. Would you recommend keeping that edit anyway? It appears to be more portable than the old version. |
Yes, it's probably correct. |
Okay, thanks for checking. If there's anything else I can do then let me know ... though I'll have to head out now, it's late on this side of the sea. |
I suggest you contact Blackrock, unfortunately I can only test with nPlayServer which seems to be not helpful. In the weekend I will look at the nPlayServer code to see if it plays back digin |
Blackrock said that the firmware had a bug that disrupted digital value transfer in versions v7.0.0 and v7.0.2. But they also said that the bug was fixed in v7.0.3 and the current v7.0.4. I guess I can ask them if this applies to our model of NSP. If there's any code changes you want tested with an NSP then I can try them out for you. |
I wrote a little test utility to help me to debug and pushed to master. Using NPlayServer and the (clinical) NSP both gave the same results: the channel number in the packet is wrong for both the digital and serial inputs. The channel number is wrong as early as ProcessIncomingPacket. This doesn't seem to be a CereLink problem. |
I commend your tidy piece of detective work, there. So, what is the culprit – the firmware? Does Blackrock know? |
On March 29 2019, I replied with the above information to the support ticket you opened with so I guess they know now. |
Thanks! Now let's hope that they take notice ... |
Blackrock answered with some example code for identifying digital or serial channels based on channel capabilities. I'll put together a PR. |
I fell down a bit of a hole while working on this. It looks like we have to abandon the idea of checking channel number and instead use (some proxy of) channel type. The channel type can be learned from first using The problem is that this is a bit expensive to do for every single packet. It would have to be done when the packet is directed along different code paths. It would have to be done again within certain code paths. It would have to be done yet again within the language wrappers. Instead of inferring channel type 3+ times per packet, it would be nice to calculate each channel's type ONCE, and then just use that stored info. I'm thinking of adding an @dashesy , where would be a good place to fill this channel-type array? As far as I can tell, the only data structure that I need initialized is I'll have to define some new consts for channel types, write a new function in cbsdk that returns this array, and then the python wrapper for that function. Then we should be able to do something like Does that all sound reasonable? |
@jsdpag I'm almost there, I think. My test util is now printing out the following digital values, each row is an update iteration, and each value is the digital in value. Does this look correct to you? There are some missing values (e.g. 74). I don't know what happened there.
|
Work-in-progress: https://github.com/dashesy/CereLink/tree/parse_by_caps |
I am curious how Blackrock handles digin channels. |
The new modifications to |
In #104 I describe the problem with dropping event samples. I've fixed it with one approach, but I think I'd prefer the other approach I mention. Here's some Python code I used to test: from cerebus import cbpy
TESTCHAN = 151
if __name__ == '__main__':
con_params = cbpy.defaultConParams()
result, connect_info = cbpy.open(instance=0, connection='default', parameter=con_params)
cbpy.trial_config(instance=0, reset=True, buffer_parameter={'event_length': 10000},
nocontinuous=True, nocomment=True)
try:
n_events = 0
while True:
result, data = cbpy.trial_event(instance=0, reset=True)
for d in data:
if d[0] == TESTCHAN:
timestamps = d[1]['timestamps'][0]
events = d[1]['events']
n_events += len(events)
print(n_events, len(events), timestamps, events)
except KeyboardInterrupt:
print('Shutting Down!')
cbpy.close(instance=0) Edit: Removed wheel. See pull request instead. |
Here is a printout from the above script, with each row formatted as
Notice how the timestamps jump around between something that seems to make sense and 0.
This looks better. So I don't really understand what resetting the clock during InitTrial is doing or why it might be desirable. At best it's inconsistent. I'll modify the Python wrapper so resetting the clock during InitTrial is a separate option and is False by default. |
Hi Chad, |
I put python wheels for windows and Linux on the release page. Let me know how it goes for you! |
Greetings Sirs and Sirsettes,
I'm having issues with v7 of cbmex getting the 'digin' values from cbmex( 'trialconfig' ). The NSP's digin port is set for 16-bits any rising edge. I've then run a test where I flip the digital inputs on and off 1000 times in a row.
The pseudo-code:
cbmex( 'trialconfig' , 1 , 'absolute' , 'nocontinuous' )
for i = 1 : 1000
Flip digin channels on
Flip digin channels off
end
d = cbmex( 'trialdata' , 1 ) ;
You see that the 1000 time stamps are there. But the values are not. I'm not sure if this is an issue with cbmex.cpp or one of the cb* functions that it calls ... I'm still trying to decipher the code.
If you have any suggestions then I'm happy to give 'em a try!
Cheers,
js
The text was updated successfully, but these errors were encountered: