forked from kdharris101/iss
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconvert_iss_data.m
100 lines (90 loc) · 3.36 KB
/
convert_iss_data.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function o = convert_iss_data(oOld)
%% objNew = convert_iss_data(objOld);
% Converts data from iss_PixelBased branch on GitHub.
% oOld: iss object from issPixelBased branch on GitHub.
% o: iss object from iss_PixelBased class of current iss software.
% Note that you can still use the same LookupTable as made with old class.
%% Update all properties that exist for both classes.
DesiredClass = iss_PixelBased;
o = DesiredClass;
NewClassProp = metaclass(DesiredClass).PropertyList;
for k = 1:length(NewClassProp)
try
o.(NewClassProp(k).Name) = oOld.(NewClassProp(k).Name);
catch
...
end
end
%% Deal with differences in properties/property names
% Extract variables
o.StripHack = false; %Did not account for strips of zeros in raw data
%with old method.
o.ScoreBleedThroughContribution = false;
o.BleedMatrixEigMethod = 'Mean';
o.BleedThroughThresh = -inf; %Kept all bleed through with old method.
%% FindSpots output
%Change form of transform
if ~isempty(o.D) && ~isempty(o.A)
o.PointCloudMethod = 2; %Used PCR2 in this branch.
o.FindSpotsInfo.D_fromPCR2 = o.D;
D = zeros(3,2,size(o.TileOrigin,1),o.nRounds,o.nBP);
for t=1:size(o.TileOrigin,1)
for r=1:o.nRounds
for b=1:o.nBP
D(:,:,t,r,b) = o.A(b)*o.D(:,:,t,r);
end
end
end
o.D = D;
end
%% DotProduct outputs
o.dpNormSpotColors = oOld.cNormSpotColors;
o.dpSpotCodeNo = oOld.SpotCodeNo;
o.dpSpotColors = oOld.cSpotColors;
o.dpSpotCombi = oOld.SpotCombi;
o.dpSpotGlobalYX = oOld.SpotGlobalYX;
o.dpSpotIntensity = oOld.SpotIntensity;
o.dpSpotIsolated = oOld.cSpotIsolated;
o.dpSpotScore = oOld.SpotScore;
o.dpSpotScoreDev = oOld.SpotScoreDev;
if ~isempty(o.dpSpotColors)
%Normalisation to make Bleed Matrix
if strcmpi(o.BleedMatrixType,'Separate')
o.BledCodesPercentile = prctile(o.dpSpotColors, o.SpotNormPrctile);
elseif strcmpi(o.BleedMatrixType,'Single')
o.BledCodesPercentile = zeros(1,o.nBP,o.nRounds);
for b = 1:o.nBP
bSpotColors = o.dpSpotColors(:,b,:);
o.BledCodesPercentile(:,b,:) = prctile(bSpotColors(:), o.SpotNormPrctile);
end
end
o.dpLocalTile = o.get_local_tile(o.dpSpotGlobalYX);
end
%% Prob method outputs
o.pSpotColors = oOld.cSpotColors;
o.pSpotGlobalYX = oOld.SpotGlobalYX;
if ~isempty(o.pSpotCodeNo)
o.ProbMethod = 2; %Used old prob method in old branch.
o.ScoreScale = 1; %ProbMethod=2 requires ScoreScale=1.
x = min(o.pSpotColors(:))-1:max(o.pSpotColors(:))-1;
%Get background distribution by shifting Histogram so aligns with 0 of spot colors.
BackgroundGamma = dirac(x);
BackgroundGamma(BackgroundGamma==inf)=1;
o.BackgroundProb = zeros(length(x),o.nBP,o.nRounds);
for b=1:o.nBP
for r=1:o.nRounds
o.BackgroundProb(:,b,r) = conv(BackgroundGamma,o.HistProbs(:,b,r),'same');
end
end
o.pLocalTile = o.get_local_tile(o.pSpotGlobalYX);
end
%% Pixel method ouputs
if ~isempty(o.pxSpotGlobalYX)
o.pxLocalTile = o.get_local_tile(o.pxSpotGlobalYX);
end
%With some old versions, PCR did not include centering.
if isempty(o.TileCentre)
warning(['Old Data did not include TileCentre. ',...
'So Run find_spots2 again before re-running any call_spots algorithms.']);
o.TileCentre = 0.5*[o.TileSz+1,o.TileSz+1];
end