Skip to content
Snippets Groups Projects
Commit ce616eb0 authored by Mark Winter's avatar Mark Winter
Browse files

Added read/write code samples from LEVer.

parent 5171cd21
Branches
No related tags found
No related merge requests found
% [objTracks gConnect] = SampleReadTrackData(DatasetDir, DatasetName) - Sample LEVer track data writer.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2013 Andrew Cohen, Eric Wait and Mark Winter
%
% This file is part of LEVer - the tool for stem cell lineaging. See
% http://bioimage.coe.drexel.edu for details
%
% LEVer is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% LEVer is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with LEVer in file "gnu gpl v3.txt". If not, see
% <http://www.gnu.org/licenses/>.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [objTracks gConnect] = SampleReadTrackData(DatasetDir, DatasetName)
global CellHulls
bValidCell = ~[CellHulls.deleted];
backMap = find(bValidCell);
objTracks = struct('Label',cell(1,length(CellHulls)), 'ccc',cell(1,length(CellHulls)),...
'outID',{0}, 'inID',{0});
fname = fullfile(DatasetDir,['Tracked_' DatasetName '.txt']);
fid=fopen(fname,'rt');
bDone=0;
TrackList=[];
while ~bDone
dd=fscanf(fid,'%d,%d,%d\n',3);
if -1==dd(1)
bDone=1;
break
end
TrackList=[TrackList;dd'];
end
bDone=0;
InList=[];
dd=textscan(fid,'%f,%f,%f');
InList=[dd{1},dd{2},dd{3}];
fclose(fid);
for i=1:size(TrackList,1)
o1 = backMap(TrackList(i,2));
o2 = backMap(TrackList(i,3));
objTracks(o1).Label=TrackList(i,1);
objTracks(o2).Label=TrackList(i,1);
objTracks(o1).outID=o2;
objTracks(o2).inID=o1;
end
nLabel=max([objTracks.Label])+1;
for n=1:length(objTracks)
if (objTracks(n).Label>0)
continue;
end
objTracks(n).Label = nLabel;
nLabel=nLabel+1;
end
gConnect=sparse(InList(:,2),InList(:,1),InList(:,3),length(CellHulls),length(CellHulls));
end
\ No newline at end of file
% SampleWriteSegData(DatasetDir, DatasetName) - Sample LEVer segmentation data writer.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2013 Andrew Cohen, Eric Wait and Mark Winter
%
% This file is part of LEVer - the tool for stem cell lineaging. See
% http://bioimage.coe.drexel.edu for details
%
% LEVer is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% LEVer is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with LEVer in file "gnu gpl v3.txt". If not, see
% <http://www.gnu.org/licenses/>.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function SampleWriteSegData(DatasetDir, DatasetName)
global CONSTANTS CellHulls
sz = CONSTANTS.imageSize;
th = max([CellHulls.time]);
hashedHulls = cell(th,1);
% reset tracking info
for n=1:length(CellHulls)
hashedHulls{CellHulls(n).time} = [hashedHulls{CellHulls(n).time}; n];
end
fname = fullfile(DatasetDir, ['SegObjs_Test_' DatasetName '.txt']);
fid=fopen(fname,'wt');
fprintf(fid, '%d %d\n', sz(2), sz(1));
fprintf(fid, '%d %d\n\n', th, length(CellHulls));
for t=1:length(hashedHulls)
fprintf(fid, '%d\n', length(hashedHulls{t}));
for i=1:length(hashedHulls{t})
[r c]=ind2sub(sz,CellHulls(hashedHulls{t}(i)).indexPixels);
COM = mean([c r], 1);
fprintf(fid, '%f %f %d:', COM(1), COM(2), length(r));
for k=1:length(r)
fprintf(fid, ' (%d,%d)', c(k), r(k));
end
fprintf(fid,'\n');
end
end
fclose(fid);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment