-
Notifications
You must be signed in to change notification settings - Fork 0
/
addLymphsFromOneMovieStructToAnother.m
64 lines (60 loc) · 2.22 KB
/
addLymphsFromOneMovieStructToAnother.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
%this function creates a new movie which holds the addition of the lymphs of movie2 in the given sties to movie1
function [movie]=addLymphsFromOneMovieStructToAnother(movie1,movie2,sites)
convIds=[-1,-1];
%first make sure maxLymphId is correct-assuming if max is not 0 its
%allright
movie=movie1;
if(movie.maxLymphId==0)
for i=1:length(movie.sites)
lymphs=movie.sites(i).lymphs;
for j=1:length(lymphs)
if(movie.maxLymphId<lymphs(j).id)
movie.maxLymphId=lymphs(j).id;
end
end
end
%in this case we will also change momDaughInd to the same value
% movie.momDaughInd=movie.maxLymphId;
end
%Second we add all cells
for s=1:length(sites)
site=sites(s);
oldlymphs=movie2.sites(site).lymphs;
newlymphs=[];
%first we add the mothers
for i=1:length(oldlymphs)
lymph=oldlymphs(i);
newid=movie.maxLymphId+1;
convIds(end+1,1:2)=[lymph.id,newid];
[newlymph,movie, siteind,lymphind]=createNewLymphNoGui(newid,site,[],movie);
[movie,newlymph]=addnewLymph(movie, lymph, newlymph);
end
%now we add the mother daughter mapping
for i=1:length(oldlymphs)
lymph=oldlymphs(i);
lymphind=find(convIds(:,1)==lymph.id);
newid=convIds(lymphind,2);
inds=find(movie2.momDaughTable(:,2)==lymph.id);
if(movie2.momDaughTable(inds(1),1)~=-1) %have mothers
for j=1:length(inds)
oldmomid=movie2.momDaughTable(inds(j),1);
momind=find(convIds(:,1)==oldmomid);
newmomid=convIds(momind,2);
movie=addMomDaughterCouple(movie, newmomid, newid);
end
% else
% movie=addMomDaughterCouple(movie, -1, newid);
end
end
end
function [movie, newlymph]= addnewLymph(movie, oldlymph, newlymph)
[lymph,siteind,lymphind]=getLymph(newlymph.id,movie);
newlymph.frames=oldlymph.frames;
newlymph.locations=oldlymph.locations;
newlymph.fluos=oldlymph.fluos;
newlymph.remark=oldlymph.remark;
% newlymph.fate=oldlymph.fate;
movie.sites(siteind).lymphs(lymphind)=newlymph;
if(movie.maxLymphId<newlymph.id) %this is new movie structure or new cell created
movie.maxLymphId=newlymph.id;
end