HasBlankEpoch.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435
  1. function [ blankBool ] = HasBlankEpoch( dataStruct )
  2. % if dataStruct is a stimParams struct, evaluates whether the stimParams
  3. % struct contains a blank bout. there is a blank bout by definition when
  4. % randomize is set to 1. there is also a blank bout when the first
  5. % condition specified is a blank.
  6. %
  7. % if dataStruct is a timingStruct struct, returns hasBlankEpoch field if
  8. % available. otherwise evaluates whether the timingStruct is for a stimulus
  9. % parameter file that included a blank condition. evaluates to true if the
  10. % timingStruct is the output of TrialAverageAll, which create a blank epoch.
  11. % evaluates to true if every other bout is epoch 0, which can occur when
  12. % randomize was set to 1, i.e. cycling between conditions and the blank.
  13. % there can be false positives using this last condition (2 bouts only of
  14. % randomize = 0, insufficiently many bouts of randomize = 2).
  15. if isfield( dataStruct, 'randomize' ) % if dataStruct is a stimParams struct
  16. blankBool = all( [dataStruct.randomize] == 1 ) || ...
  17. (dataStruct(1).stimtype == 11 && ...
  18. dataStruct(1).lum == 0.5 && ...
  19. dataStruct(1).contrast == 0 && ...
  20. dataStruct(1).spacing == 120 && ...
  21. dataStruct(1).duration == dataStruct(1).tau);
  22. elseif isfield( dataStruct, 'hasBlankEpoch' ) && isfield( dataStruct, 'stimParamFileName' )% if dataStruct is a timingStruct struct
  23. exceptionStimuli = {'FullField_ONOFF_1.0_2s_BG_0.5_4s_Weber_NonRand.txt'};
  24. if strcmp(dataStruct.stimParamFileName, exceptionStimuli)
  25. blankBool = 1;
  26. else
  27. blankBool = dataStruct.hasBlankEpoch;
  28. end
  29. elseif isfield( dataStruct, 'stimulusOutputRaw' ) % if dataStruct is a timingStruct struct but lacks hasBlankEpoch field
  30. blankBool = (isfield( dataStruct, 'isTrialAveraged' ) && dataStruct.isTrialAveraged) || ...
  31. all( dataStruct.boutEpochInds(1 : 2 : end) == 0 );
  32. end
  33. end