I have made the following change (between the comment lines) at around line 4371 and also at 4706
mesh1 = model2mesh(cCell1,p.meshStep,p.meshTolerance,p.meshWidth);
mesh2 = model2mesh(cCell2,p.meshStep,p.meshTolerance,p.meshWidth);
%added by sean murray - prevent split if resultant cells are
%too small (mother is not reprocessed below, only daughter)
if length(mesh1)>1
cellarea1 = polyarea([mesh1(:,1);flipud(mesh1(:,3))],[mesh1(:,2);flipud(mesh1(:,4))]);
else cellarea1=0;
end
if length(mesh2)>1
cellarea2 = polyarea([mesh2(:,1);flipud(mesh2(:,3))],[mesh2(:,2);flipud(mesh2(:,4))]);
else cellarea2=0;
end
if(fitquality1>p.fitqualitymax || fitquality2>p.fitqualitymax || p.areaMin>cellarea1 || p.areaMin>cellarea2 || p.areaMax<cellarea1 || p.areaMax<cellarea2)
gdisp(['Tried to split cell ' num2str(cell) ' but failed']);
if(fitquality1>p.fitqualitymax || fitquality2>p.fitqualitymax) gdisp(['Fit qualities ' num2str(fitquality1) ' ' num2str(fitquality2) ' of daughter cells are too low']);end
if( p.areaMin>cellarea1 || p.areaMin>cellarea2) gdisp(['Areas ' num2str(cellarea1) ' ' num2str(cellarea2) ' of daughter cells are too low']);end
if( p.areaMax<cellarea1 || p.areaMax<cellarea2) gdisp(['Areas ' num2str(cellarea1) ' ' num2str(cellarea2) ' of daughter cells are too high']);end
else
% end of addition apart from 'end'
cellStruct1.algorithm = p.algorithm;
cellStruct2.algorithm = p.algorithm;
cellStruct1.birthframe = frame;
cellStruct2.birthframe = prevStruct.birthframe;
if size(pcCell1,2)==1, model=pcCell1'; else model=pcCell1; end