Zapit-Optostim / zapit

General purpose optostimulation system
GNU Lesser General Public License v2.1
6 stars 1 forks source link

Smooth transitions between trial start locations to reduce noise with sendSamples #91

Open raacampbell opened 1 year ago

raacampbell commented 1 year ago

The only noise the scanners make during an experiment is a subtle click when the beam goes to the start of the next trial.

Is there a way to make this go away? We know where the scanners are at the end of a trial. So we could log this to zapit.pointer.lastXgalvoVoltage and lastYgalvoVoltage at the end of stopOptoStim. Then we move to the next location when sendSamples is next run. Especially if we are using the hardware trigger the latency involved in doing this is negligible.

raacampbell commented 1 year ago

Another way would be for stopOptoStim to send the scanners to 0/0 on the last buffer update. They can slowly go there during that in a ramp. Then we know we always start each trial from 0,0. I think I like this option.

raacampbell commented 1 year ago

The DAQ writeAnalogData method logs the last written waveform to a property

% If this is a long waveform we cache it
if size(waveforms,1)>1
     obj.lastWaveform = waveforms;
end

so we could take the last row from this and populate zapit.pointer.lastXgalvoVoltage and lastYgalvoVoltage from there. This way we don't need to do it specifically at the end of `stopOptoStim. It will work equally well if we have written a fixed duration waveform.

raacampbell commented 3 months ago

There is a pointer.slewScanners method now. This is not tested and not being used by anything yet.