post:labelthresholdevents.m

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
post:labelthresholdevents.m [2020/05/27 18:29] – pseudomoanerpost:labelthresholdevents.m [2020/05/27 21:02] (current) – pseudomoaner
Line 40: Line 40:
 %       -procTracks: Equal to the input procTracks, but either with the %       -procTracks: Equal to the input procTracks, but either with the
 %       'event' field updated, or (if not already present) added, with the %       'event' field updated, or (if not already present) added, with the
-%       appropriate events added.+%       appropriate events marked.
 % %
 %   Author: Oliver J. Meacock, (c) 2020 %   Author: Oliver J. Meacock, (c) 2020
Line 50: Line 50:
 else else
     error('Thresholds do not appear to be numerical.')     error('Thresholds do not appear to be numerical.')
 +end
 +
 +%Needed to ensure you don't overwrite pre-existing event data in procTracks
 +%later
 +if isfield(procTracks,'event')
 +    preFlag = true;
 +else
 +    preFlag = false;
 end end
  
 for i = 1:size(procTracks,2) for i = 1:size(procTracks,2)
     currList = procTracks(i).(tgtField);     currList = procTracks(i).(tgtField);
-    if isfield(procTracks,'event')+     
 +    if preFlag
         currEvt = procTracks(i).event; %Get pre-existing event list for this track (if it exists)         currEvt = procTracks(i).event; %Get pre-existing event list for this track (if it exists)
     else     else
Line 91: Line 100:
         evtList = [];         evtList = [];
         while proceed %I.e. while there are still events to test         while proceed %I.e. while there are still events to test
-            if ~refState %If event is permitted, detect next and switch to refractory state +            futureEvts = [0,evtSwitch' > currInd]; 
-                futureEvts = [0,evtSwitch > currInd]; +            futureRefs = [0,refSwitch' > currInd]; 
-                nextInd = evtSwitch(diff(futureEvts) == 1); +             
-                currInd = nextInd; +            if ~refState && sum(futureEvts) > 0 %If event is permitted, detect next and switch to refractory state 
-                evtList = [evtList;nextInd];+                currInd = evtSwitch(diff(futureEvts) == 1); 
 +                evtList = [evtList;currInd];
                 refState = true;                 refState = true;
                                  
-                if sum(refSwitch > currInd) == 0+                if sum(refSwitch' > currInd) == 0
                     proceed = false;                     proceed = false;
                 end                 end
-            else %If event is not permitted, detect next refractory period end and switch to 'excitable' state +            elseif refState && sum(futureRefs) > 0 %If event is not permitted, detect next refractory period end and switch to 'excitable' state 
-                futureRefs = [0,refSwitch > currInd]; +                currInd = refSwitch(diff(futureRefs) == 1);
-                nextInd = refSwitch(diff(futureRefs) == 1); +
-                currInd = nextInd;+
                 refState = false;                 refState = false;
                                  
-                if sum(evtSwitch > currInd) == 0+                if sum(evtSwitch' > currInd) == 0
                     proceed = false;                     proceed = false;
                 end                 end
 +            else
 +                proceed = false;
             end             end
         end         end
                  
-        currEvt(evtList) = eventLabel;+        currEvt(evtList+1) = eventLabel;
     end     end
-     
     procTracks(i).event = currEvt;     procTracks(i).event = currEvt;
 end end
  • post/labelthresholdevents.m.1590600589.txt.gz
  • Last modified: 2020/05/27 18:29
  • by pseudomoaner