Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| post:labelthresholdevents.m [2020/05/27 18:18] – pseudomoaner | post:labelthresholdevents.m [2020/05/27 21:02] (current) – pseudomoaner | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| **Class:** Function | **Class:** Function | ||
| - | **Description: | + | **Description: |
| **Author:** Oliver J. Meacock | **Author:** Oliver J. Meacock | ||
| Line 20: | Line 20: | ||
| % | % | ||
| % it to all tracks. | % it to all tracks. | ||
| - | % -trtField: String defining the name of the field of procTracks you | + | % -tgtField: String defining the name of the field of procTracks you |
| % wish to apply threshold detection to. Can refer to any field, | % wish to apply threshold detection to. Can refer to any field, | ||
| % | % | ||
| Line 34: | Line 34: | ||
| % rises above endThresh. If endThresh < startThresh, | % rises above endThresh. If endThresh < startThresh, | ||
| % true. | % true. | ||
| - | % -eventLable: The integer you wish to use to label this set of | + | % -eventLabel: The integer you wish to use to label this set of |
| % | % | ||
| % | % | ||
| Line 40: | Line 40: | ||
| % | % | ||
| % ' | % ' | ||
| - | % | + | % |
| % | % | ||
| % | % | ||
| Line 50: | Line 50: | ||
| else | else | ||
| error(' | error(' | ||
| + | end | ||
| + | |||
| + | %Needed to ensure you don't overwrite pre-existing event data in procTracks | ||
| + | %later | ||
| + | if isfield(procTracks,' | ||
| + | preFlag = true; | ||
| + | else | ||
| + | preFlag = false; | ||
| end | end | ||
| for i = 1: | for i = 1: | ||
| currList = procTracks(i).(tgtField); | currList = procTracks(i).(tgtField); | ||
| - | if isfield(procTracks,' | + | |
| + | | ||
| currEvt = procTracks(i).event; | currEvt = procTracks(i).event; | ||
| 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 | + | |
| - | | + | futureRefs = [0, |
| - | nextInd | + | |
| - | currInd = nextInd; | + | |
| - | evtList = [evtList;nextInd]; | + | currInd = evtSwitch(diff(futureEvts) == 1); |
| + | evtList = [evtList;currInd]; | ||
| refState = true; | refState = true; | ||
| | | ||
| - | if sum(refSwitch > currInd) == 0 | + | if sum(refSwitch' |
| proceed = false; | proceed = false; | ||
| end | end | ||
| - | | + | |
| - | | + | currInd = refSwitch(diff(futureRefs) == 1); |
| - | nextInd | + | |
| - | currInd = nextInd; | + | |
| refState = false; | refState = false; | ||
| | | ||
| - | if sum(evtSwitch > currInd) == 0 | + | if sum(evtSwitch' |
| 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 | ||
| Line 144: | Line 153: | ||
| hold on | hold on | ||
| + | %Red dots indicate events of class 1 | ||
| plot(procTracks.times(procTracks(1).event == 1)*dt, | plot(procTracks.times(procTracks(1).event == 1)*dt, | ||
| + | |||
| + | %Black dots indicate events of class 2 | ||
| plot(procTracks.times(procTracks(1).event == 2)*dt, | plot(procTracks.times(procTracks(1).event == 2)*dt, | ||
| </ | </ | ||
| Line 150: | Line 162: | ||
| **Example output:** | **Example output:** | ||
| - | {{ :post:fluosplitexample.png? | + | {{ :post:eventlabelexample.png? |