function [topsum,botsum,leftsum,ritsum] = hemiadd(MB,rcd,ccd) %HEMIADD inputs a 3D image matrix and centroid location and finds the difference of %the sums of the top half, bottom half, left half and right half at each time %compared to their means over that time %round coordinates of centroid rc=round(rcd); cc=round(ccd); %subtract approximate background M=abs(MB-mean(mean(min(MB)))); %initialize values [rn,cn,tn]=size(M); t=1; topsum=[]; botsum=[]; leftsum=[]; ritsum=[]; %sum each half-plane for each image while t<(tn+1) topM=M(1:(rc-1),:,t); botM=M((rc+1):rn,:,t); lftM=M(:,1:(cn-1),t); ritM=M(:,(cc+1):cn,t); topsum=cat(1,topsum,sum(sum(topM))); botsum=cat(1,botsum,sum(sum(botM))); leftsum=cat(1,leftsum,sum(sum(lftM))); ritsum=cat(1,ritsum,sum(sum(ritM))); t=t+1; end topsum=topsum-mean(topsum); botsum=botsum-mean(botsum); leftsum=leftsum-mean(leftsum); ritsum=ritsum-mean(ritsum); %Plot and Label subplot(2,1,1) plot(topsum) hold; plot(botsum,'Color','Red') hold; subplot(2,1,2) plot(leftsum) hold; plot(ritsum,'Color','Red') hold; subplot(2,1,1) title('Intensity Deviation of Top/Bottoms Halves') xlabel('Time(arb. units)') ylabel('Diff. of intensity from mean (arb units)') legend('Top Half','Bottom Half') subplot(2,1,2) title('Intensity Deviation of Left/Right Halves') xlabel('Time(arb. units)') ylabel('Diff. of intensity from mean (arb units)') legend('Left Half', 'Right Half') end