Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
876db5d0ce
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 76 lines (60 sloc) 1.95 KB
% Compares two videotrack partitions:
% * One contains a experimental record.
% * One is considered to be a record of the extent of "trials".
%
% This program counts how many "active" frames in the experiment are
% included in each one of the trial periods
%
%
% INPUT
%
% experiment : computed partition of freezing fragments
% Class: mbvid.videotrack.fragmentSet
%
% trials : given partition of trials
% Class: mbvid.videotrack.fragmentSet
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% OUTPUT
%
% A mbtools outout structure with some additional fields
% The screen output gets coded as 'report' field
%
% Further fields:
% 'percentages'
% 'trialRange'
% 'framesInTrial'
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% SYNTAX
%
% o = trialPercentages(r,rtrials);
%
% percentage of occupation on each trial
%
%
function o = trialPercentages(rexperimental,rtrial)
o = mbparse.output();
o.addprop('framesInTrial');
o.addprop('trialRange');
o.addprop('percentage');
X = rexperimental.getArray();
activeFrames = find(X>0);
for i=1:length(rtrial.fragments);
f = rtrial.fragments{i};
o.echo('Trial %d',i);
o.trialRange{i} = f.range;
totalFrames = f.range(end)-f.range(1)+1;
totalsSeconds = rtrial.video.frames2seconds(totalFrames);
o.echo(' extent %d frames, %5.2f seconds',{totalFrames,totalsSeconds});
indicesOfFramesOfExperimentInTrial = find( (activeFrames>=f.range(1)).*(activeFrames<=f.range(2)));
o.framesInTrial{i} = activeFrames(indicesOfFramesOfExperimentInTrial);
NActiveFrames = length(o.framesInTrial{i});
o.echo(' experimental frames active in this period: %d',{NActiveFrames});
percentageActiveFrames = 100*NActiveFrames/ totalFrames;
o.percentage(i) = percentageActiveFrames;
o.echo(' fraction of active frames: %5.2f%%',percentageActiveFrames);
end