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:
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
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!