Zapit-Optostim / zapit

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

Add option for ephys-friendly waveforms #110

Open raacampbell opened 1 year ago

raacampbell commented 1 year ago

Describe the feature/solution you'd like Laser onsets and offsets are hard. This is OK for regular use but with an electrode this will cause artefacts. Please reply to this issue if you are interested in waveforms that are smoother and won't cause this issue as much.

raacampbell commented 1 year ago

Add untested code for doing this: a6a38b6765049004d1e40bd6b1cc0bb6aeadc795

The waveform is not totally smooth:

Screenshot 2023-08-28 at 14 23 18

So we might still want to work on this. But test it first.

The waveform is scaled for area. So the same number of photons are delivered compared to the unsmoothed.

raacampbell commented 3 months ago

The power correction which was applied above may no longer be correct, because laser power is re-calculated in sendSamples:

    % Set the voltage value in the laser waveform to yield the correct power. This will have
    % been specified by default by the user settings file. Otherwise manually as an
    % optional input argument.
    peakPower_mw = obj.stimConfig.laserPowerFromTrial(conditionNumber,laserPower_mw);
    laserControlVoltage = obj.laser_mW_to_control(peakPower_mw);
    waveforms(waveforms(:,3)>0,3) = 1; % Just in case the voltage waveform is not ones
    waveforms(:,3) = waveforms(:,3)*laserControlVoltage;

Yeah, definitely the above will break stuff.

raacampbell commented 3 months ago

Is now better (c6731b25f1fd645cf6f18085b8897167c9e506cb): image

Ephys waveforms should now have a better shape and be produced correctly. BUT the higher laser power is produced assuming the power curve is linear and does not take max control voltage into account. OK for lower powers/fewer positions with Obis for testing.