diff --git a/README.md b/README.md index 0f99409..985dadd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ `runAll('the_video.avi',[],[]);` or `runAll('the_video.avi',leftMask,rightMask);` -* Make sure to add the Inscribed_Rectangle folder to Paths on Matlab \ No newline at end of file +* Make sure to add the Inscribed_Rectangle folder to Paths in Matlab \ No newline at end of file diff --git a/displayEars.m b/displayEars.m index cd3d605..e1d4c6d 100644 --- a/displayEars.m +++ b/displayEars.m @@ -12,23 +12,27 @@ newVideo.Quality = 100; newVideo.FrameRate = 20; open(newVideo); + + meanLeft = zeros(video.NumberOfFrames,2); + meanRight = zeros(video.NumberOfFrames,2); - %there is still no checking on whether or not 3 indexes even exist: if - %all points were crap, this will error out right now - samplePoints = 3; + % now that most variables undergo thresholding, we can plot all the + % indexes that appear at this stage for i=1:video.NumberOfFrames disp(['Writing video...' num2str(i)]) im = read(video,i); - meanLeft = mean(leftAllPoints(leftMaxIndexes(1:samplePoints),:,i)); - im = insertShape(im,'Circle',[meanLeft 4],'Color','green'); - meanRight = mean(rightAllPoints(rightMaxIndexes(1:samplePoints),:,i)); - im = insertShape(im,'Circle',[meanRight 4],'Color','green'); - for j=1:samplePoints; %how many points to plot + meanLeft(i,:) = mean(leftAllPoints(leftMaxIndexes,:,i)); + im = insertShape(im,'Circle',[meanLeft(i,:) 4],'Color','green'); + meanRight(i,:) = mean(rightAllPoints(rightMaxIndexes,:,i)); + im = insertShape(im,'Circle',[meanRight(i,:) 4],'Color','green'); + for j=1:size(leftMaxIndexes,1) %how many points to plot im = insertShape(im,'FilledCircle',[leftAllPoints(leftMaxIndexes(j),:,i) 2]); + end + for j=1:size(rightMaxIndexes,1) %how many points to plot im = insertShape(im,'FilledCircle',[rightAllPoints(rightMaxIndexes(j),:,i) 2]); end writeVideo(newVideo,im); - %imshow(im) + imshow(im) end close(newVideo); end \ No newline at end of file diff --git a/pointCompute.m b/pointCompute.m index 387e4f4..cbbe4f9 100644 --- a/pointCompute.m +++ b/pointCompute.m @@ -33,8 +33,7 @@ figure; hold on; for i=1:size(allPointsDist,1) %points rows - diffDistance = diff(allPointsDist(i,:)); %change in distance - diffDistances(i,:) = diffDistance(1,:); + diffDistances(i,:) = diff(allPointsDist(i,:)); %change in distance %plot(diffDistance); plot(allPointsDist(i,:)) end @@ -62,10 +61,10 @@ hold on; for i=1:size(allPointsPhase,1) %points rows maxDiffPhases(i,:) = max(abs(diff(allPointsPhase(i,:)))); - plot(allPointsPhase(i,:)); % plot this... - %plot(diff(allPointsPhase(i,:))); % or this, not together + %plot(allPointsPhase(i,:)); % plot this... + plot(diff(allPointsPhase(i,:))); % or this, not together end - plot(1:size(allPointsPhase,2),avgPhase,'*','Color','green'); %along with this... + %plot(1:size(allPointsPhase,2),avgPhase,'*','Color','green'); %along with this... hold off; % if thresholds or points are too aggressive, this will error out @@ -74,12 +73,12 @@ % threshold for large abberations maxIndexes = maxIndexes(diffValue < 15); % remove large phase changes, value from observation - thresholdDiffPhasesIndexes = find(maxDiffPhases<.012); + thresholdDiffPhasesIndexes = find(maxDiffPhases<.01); maxIndexes = maxIndexes(ismember(maxIndexes,thresholdDiffPhasesIndexes)); %remove anything that has a disimilar angle, value from observation. %This should not be too aggressive, if points lie above/below the angle %of interest they will get caught. Mainly to make sure the point is not %traveling sideways or backwards - thresholdPhasesIndexes = find(abs(avgPhase-mean(allPointsPhase,2))<.2); + thresholdPhasesIndexes = find(abs(avgPhase-mean(allPointsPhase,2))<.05); maxIndexes = maxIndexes(ismember(maxIndexes,thresholdPhasesIndexes)); %remove phase abberations end \ No newline at end of file diff --git a/pointCompute.m~ b/pointCompute.m~ deleted file mode 100644 index d6b5988..0000000 --- a/pointCompute.m~ +++ /dev/null @@ -1,82 +0,0 @@ -% Runs some computation on the points. Gets the distances between each -% point frame-by-frame, then computes the difference or delta of each point -% distance between frames (large spikes in this show when a significant -% even occurs). - -function [maxIndexes,allPointsDist,allPointsPhase,diffDistances,diffRanges]=pointCompute(allPoints) - disp('Computing points...') - - % could possibly use the 'distmat' library - %allPointsDist = zeros(size(allPoints,1),size(allPoints,3)-1); - allPointsDist = zeros(size(allPoints,1),size(allPoints,3)); - allPointsPhase = zeros(size(allPoints,1),size(allPoints,3)); - - % when you change this, the phase diff will change too, make sure to check thresholds below - % these were chosen based on observing the average phase of 2 videos - % which was 72-degrees. This point is where that angle meets the - % midline (y=300). - refPoint = [( 300]; - - for i=1:size(allPointsDist,1) %rows of points - for j=1:size(allPointsDist,2) %frames - % euclidean dist for each point and frame relative to arbitrary point - allPointsDist(i,j) = pdist([allPoints(i,1,j) allPoints(i,2,j);refPoint]); - % phase relationship between each point relative to arbitrary - % point. This is the angle between the vertical line made - % between the point and the hypotenuse from the ref to the - % point. - allPointsPhase(i,j) = atan((refPoint(1)-allPoints(i,1,j))/(refPoint(2)-allPoints(i,2,j))); - end - end - - diffDistances = zeros(size(allPointsDist,1),size(allPointsDist,2)-1); - figure; - hold on; - for i=1:size(allPointsDist,1) %points rows - diffDistance = diff(allPointsDist(i,:)); %change in distance - diffDistances(i,:) = diffDistance(1,:); - %plot(diffDistance); - plot(allPointsDist(i,:)) - end - hold off; - - % it will be important to only use the points that actually deflect (or - % change), so they need to be ordered into a list of max deflection. - % This measures peak-to-peak of a point. - diffRanges = zeros(size(diffDistances,1),1); - for i=1:size(diffDistances,1) %diffVect points - diffRanges(i,1) = range(diffDistances(i,:)); - end - - % Knowing the average angle identifies a center of the target (the - % ear). Since this area is already highly masked, it is only mildly - % instructive to use this metric, since points can be found on the top - % or bottom of the ear. Given the other criteria, it does help make - % sure that a point is moving in the same direction as all the others, - % since one that moves "backwards" could meet critera for distance and - % phase stability. - - avgPhase = mean(mean(allPointsPhase)); %this locates a central angle for all points - maxDiffPhases = zeros(size(allPointsPhase,1),1); - figure; - hold on; - for i=1:size(allPointsPhase,1) %points rows - maxDiffPhases(i,:) = max(abs(diff(allPointsPhase(i,:)))); - %plot(allPointsPhase(i,:)); % plot this... - plot(diff(allPointsPhase(i,:))); % or this, not together - end - %plot(1:size(allPointsPhase,2),avgPhase,'*','Color','green'); %along with this... - hold off; - - % if thresholds or points are too aggressive, this will error out - % order by max distance range first - [diffValue,maxIndexes]=sort(diffRanges,'descend'); - % threshold for large abberations - maxIndexes = maxIndexes(diffValue < 15); - % remove large phase changes, value from observation - thresholdDiffPhasesIndexes = find(maxDiffPhases<.012); - maxIndexes = maxIndexes(ismember(maxIndexes,thresholdDiffPhasesIndexes)); - %remove anything that has a disimilar angle, value from observation - thresholdPhasesIndexes = find(abs(avgPhase-mean(allPointsPhase,2))<.2); - maxIndexes = maxIndexes(ismember(maxIndexes,thresholdPhasesIndexes)); %remove phase abberations -end \ No newline at end of file diff --git a/sessions/NO_PPN BBN Trial 4_30032014_1351.mat b/sessions/NO_PPN BBN Trial 4_30032014_1351.mat deleted file mode 100644 index 476e66d..0000000 Binary files a/sessions/NO_PPN BBN Trial 4_30032014_1351.mat and /dev/null differ diff --git a/sessions/NO_PPN BBN Trial 4_30032014_1842.mat b/sessions/NO_PPN BBN Trial 4_30032014_1842.mat new file mode 100644 index 0000000..069776b Binary files /dev/null and b/sessions/NO_PPN BBN Trial 4_30032014_1842.mat differ diff --git a/sessions/NO_PPN BBN Trial 8_30032014_1343.mat b/sessions/NO_PPN BBN Trial 8_30032014_1343.mat deleted file mode 100644 index dd72865..0000000 Binary files a/sessions/NO_PPN BBN Trial 8_30032014_1343.mat and /dev/null differ diff --git a/sessions/NO_PPN BBN Trial 8_30032014_1909.mat b/sessions/NO_PPN BBN Trial 8_30032014_1909.mat new file mode 100644 index 0000000..fd7dbb7 Binary files /dev/null and b/sessions/NO_PPN BBN Trial 8_30032014_1909.mat differ