Zapit-Optostim / zapit

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

Zapit must log stimulus history #65

Closed raacampbell closed 1 year ago

raacampbell commented 1 year ago

The user will integrate zapit.pointer.sendSamples into their behavior code. So, for example, they can trigger presentation of a random stimulus by running hZP.sendSamples. It is now (ad63965ab39107ce179c74f28443ba0514bbb45c) possible to determine what the stimulus was and whether the laser was on:

[conditionNum, laserOn, waveforms] = hZP.sendSamples('laserOn',[]); % random laser on/off state

So it is possible for the user to write their own logging function. However, it's best if Zapit takes care of this. Issue #61 shows how this can be done in general. This issue is for adding a log file that will indicate which stimulus was presented when. We can maybe just append to the file that is already written and created (Issue #61). The format of each line could be something like: Time, Stim Index, Laser state, hardware triggered, duration [ms]

NOTE: we are proposing to add the ability log for how long the stimuli were on (to OS accuracy)

e.g.

2023-04-19 13:13:33, 4, 1, 1, 3244
raacampbell commented 1 year ago

If zapit.pointer.experimentPath is a valid directory (45b4b176cb7198f12fda5f77baa4da1d30e39929) then we will save log information in there when zapit.pointer.sendSamples runs. We will also create a log file there if none already exists.

The user can also do hZP.experimentPath='somePath' in order to script this. However, the onus will be on the user to ensure the path is valid if they do this.

raacampbell commented 1 year ago

Issue #61 now describes how the new logging argument works in zapit.pointer.sendSamples and we can piggy back off this to write a log file of stimulus presentations.

raacampbell commented 1 year ago

Done (f977ab4049790fe9e79facdf57727bc78c3c0efb) but not tested.

raacampbell commented 1 year ago

Working b1a691c43c81f8f660b360854adc7a0cce5ba3e2