Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving Data From SoftCode Handler
#1
Hi,

I am wondering if there is a way to save data in a variable during a state? In our setup we have several different sounds being driven by the soft code handler and each of these sounds have 100 variations of jitter. I am trying to save which variation is being played when the first state of a new trial is initiated. I already have a global variable made which sends the data from the soft code handler to the protocol but right now I am only able to save the last iteration of the jitter since every 0.8 seconds a new variation is triggered by the code and the only way I can think of saving it is after the state matrix is complete. Let me know if you have any suggestions of what I can do here. I appreciate it!

Thanks,
Kevin
Reply
#2
Hi Kevin,

I'm not sure I understand what your soft code handler is doing. Which piece of code is triggering the new jitter variation?
In general, whenever you have access to global variable BpodSystem, you can save anything to BpodSystem.Data.YourFieldOfChoice, and it will be added to your data file when the current trial ends. YourFieldOfChoice could be an array of jitter variations.

-Josh
Reply
#3
(08-09-2018, 02:48 PM)Josh Wrote: Hi Kevin,

I'm not sure I understand what your soft code handler is doing. Which piece of code is triggering the new jitter variation?
In general, whenever you have access to global variable BpodSystem, you can save anything to BpodSystem.Data.YourFieldOfChoice, and it will be added to your data file when the current trial ends. YourFieldOfChoice could be an array of jitter variations.

-Josh

Hi Josh,

In our case the soft code handler is telling our TDT RZ6 to play a sound and it selects at random a jitter variety from our set of sounds. However, during a trial, multiple jitter varieties can be used depending on how long the trial goes for. What I need is to only save the first jitter variety from each new trial. When I was attempting to get this I was only able to save the final variation once the state matrix concluded. Basically what I am wondering is if it is possible to save a variable within a state matrix?

Thanks for the help!
Kevin
Reply
#4
Hi Kevin,

If a soft code handler function is receiving bytes from the state, you can store your data on the line after you trigger TDT.
You don't need a global variable to move data from the soft code handler to your protocol for storage. simply do:
Code:
function My_SoftCodeHandler(inByte)
global BpodSystem
MyJitterVariant = calculateMyJitterVariant(); % where calculcateMyJitterVariant is a function you wrote
triggerMyTDT(MyJitterVariant); % where triggerMyTDT is a function you wrote to trigger TDT
BpodSystem.Data.JitterVariants(BpodSystem.Data.nTrials) = MyJitterVariant;

Any field you add to BpodSystem.Data (for instance, a vector of jitter variants) will be stored with your session data.

I hope this helps!
Reply


Forum Jump: