adding random function to stand-alone program menu

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
adding random function to stand-alone program menu
#1
I apologize if this is question/request overly simplistic, but I only use the Pulse Pal as a stand-alone device and I was wondering if there is anyway to add a random function to the programming menu. For example, I would like a simple way to program in a random time for the pulse duration within a defined range (a random 0.5 to 3 second pulse duration). I would like to incorporate such random time ranges to the other commands in the menu (eg., pulse interval, train duration, etc.)

Is this possible or is there a workaround (please keep in mind I know nothing of programming in Matlab, python, c++)?


Thanks,

Chris
Reply
#2
Hi Chris

Thanks for writing in! 
Unfortunately, adding new menu functions to the firmware is not trivial as it is currently written - we'll have major improvements in this domain for the upcoming touch-screen interface of Pulse Pal 3 (shhhh!)
In the meantime, here is a snippet of MATLAB code that does roughly what you have in mind:

Code:
PulsePal; % Start Pulse Pal
nTrials = 100; % Set number of trials (this example has 1 pulse per trial)
pulseWidthMin = 0.5; % Set minimum of pulse width distribution (uniform probability)
pulseWidthMax = 3.5; % Set maximum of pulse width distribution
% Compute pulse widths for individual trials:
PulseWidths = (rand(1,nTrials)*(pulseWidthMax-pulseWidthMin))+pulseWidthMin;
PulseWidths = round(PulseWidths*10000)/10000; % Make pulse widths multiples of shortest possible pulse
for i = 1:nTrials
   ProgramPulsePalParam(1, 'Phase1Duration', PulseWidths(i)); % Set this trial's pulse width
   ProgramPulsePalParam(1, 'PulseTrainDuration', PulseWidths(i)+0.001); % Set pulse train to just longer than 1 pulse
   TriggerPulsePal(1); % Trigger this trial's pulse train
   pause(PulseWidths(i)+0.5); % Make sure the pulse finished
end

The only catch here is that while pulse duration is precise, the interval between pulses is controlled by the PC - so depending on your application, this may not work.

Another workaround (also requiring some coding) is to use Pulse Pal's WaveformGenerator firmware. The MATLAB API allows you to load up to 40,000 samples, which can be played back on trigger at sampling rates up to 50kHz. You can then create pulses of different durations by setting different numbers of sequential samples to the pulse amplitude, where inter-pulse intervals are set to 0V. Unfortunately, we haven't documented WaveformGenerator yet, and depending on the timing resolution you need, the limited sample memory may be a limitation. If you need more resolution, the Bpod analog output module can store and play 64 unique custom waveforms of up to 1M samples, at sampling rates up to 100kHz.

I hope this helps!
-Josh
Reply
#3
thanks for getting back to me.  I'll use your code as an example and see if it works for me.

chris
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)