sync_pulse_resting_state.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. function sync_pulse_resting_state(Hnd)
  2. %Written by Xing 18/7/17
  3. %Send sequence of pulses on randomly chosen pins to digital input ports on
  4. %NSPs. Allows post-hoc synchronization of data across NSPs.
  5. global pulseNo
  6. fn = input('Enter LOG file name (e.g. 20110413_B1), blank = no file\n','s');
  7. %Copy the run_stim script
  8. fnrs = [fn,'_','runstim.m'];
  9. cfn = [mfilename('fullpath') '.m'];
  10. copyfile(cfn,fnrs)
  11. %////YOUR STIMULATION CONTROL LOOP /////////////////////////////////
  12. ESC = false; %escape has not been pressed
  13. pulseNo=0;
  14. while ~ESC
  15. %Send sync pulse and record in NEV events files
  16. pulseNo = pulseNo+1
  17. %Assign code for trial identity, using sequence of random numbers
  18. bit = randi(8)-1;%0 to 7
  19. allBits(pulseNo)=bit;
  20. dasbit(bit,1);%set signal to high value
  21. pause(0.5);%add a time buffer between sending of bits
  22. dasbit(bit,0);%set signal to low value
  23. pause(0.5);%add a time buffer between sending of bits
  24. if pulseNo > 0
  25. mydir = 'C:\Users\Xing\L\resting_state\';
  26. path = [mydir,'sync_pulse_resting_state_',fn];
  27. save(path,'*');
  28. end
  29. end %WHILE_NOT_ESCAPED%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%