-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFRETDataHCS.m
More file actions
128 lines (99 loc) · 4.09 KB
/
getFRETDataHCS.m
File metadata and controls
128 lines (99 loc) · 4.09 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function getFRETDataHCS(position,bgdir,rawdir,datadir,threshold)
%function getFRETDataHCS( row,col,site )
% image processing for FRET data analysis
% row=3;col=3;site=2;
% Input: CFP/FRET images, background images, and alignment parameters for
% CFP/FRET images.
%
% Generates first a mask for background subtraction, subtracts background,
% and calculates a refined mask before taking a ratio between background-
% subtracted CFP and FRET images. Bleaching correction assumes constant
% mean FRET values per frame across the entire time-lapse series.
%
% Output:
%
% maskFinal Cell array with binary mask for each frame
%
% cellCoors Cell array with centroid x,y coordinates of detected
% objects and object size in pixels
%
% imRatioraw Cell array with masked raw ratio values, before bleaching
% correction
%
% imRatio Cell array with bleaching-corrected masked ratio values
%
% imFRETOUtline_row_col.tif
% RGB tif stack of FRET channel images with outlined detected
% objects
%
% imRatio_row_col_colorRangeLow_colorRangeHigh.tif
% RGB tif stack with false-colored (jet-black) scaled ratio
% images, bleaching corrected.
%
% Used non built-in subfunctions:
%
% dualviewAlignFromFittedSurface
% getBGMask
% subBG
% getCellMask
% DrawMaskOutline
% ratio2RGB
% vect
%
% Arnold, 24 May 2015
key=[datadir,filesep,position,'_RatioData_raw.mat'];
if ~exist(key)
%%%%%% Set up
load([bgdir,filesep,'alignment parameters pX pY.mat'],'pX','pY');
%%%%%% Call background images
binning=1; % relevant if alingment images and data images were acquired using distinct binning settings
CFPbg_raw=double(imread([bgdir,filesep,'AVG_bgCFP.tif']));
FRETbg_raw=double(imread([bgdir,filesep,'AVG_bgFRET.tif']));
bg1(:,:,1)=CFPbg_raw; bg1(:,:,2)=FRETbg_raw;
bg2=dualviewAlignFromFittedSurfaceCrop(bg1,pX,pY,binning);
CFPbg=bg2(:,:,1);
FRETbg=bg2(:,:,2);
CFP_files=dir([rawdir,filesep,position,'_CFP_*']);
%%%%%% Loop through frames
imRatio_raw={};maskFinal={};cellCoors={}; imFRETOutline = {};
for frameNum=1:length(CFP_files)
disp([position,'__',num2str(frameNum)]);
imCFP_raw=double(imread([rawdir,filesep,position,'_CFP_',num2str(frameNum),'.tif']));
imFRET_raw=double(imread([rawdir,filesep,position,'_FRET_',num2str(frameNum),'.tif']));
%%%%%% Align CFP/FRET images
imstack(:,:,1)=imCFP_raw; imstack(:,:,2)=imFRET_raw;
imaligned=dualviewAlignFromFittedSurfaceCrop(imstack,pX,pY,1);
imCFP_raw=imaligned(:,:,1);
imFRET_raw=imaligned(:,:,2);
%
%%%%%% Background-subtract CFP/FRET images
bgmask=getBGMask(imCFP_raw+imFRET_raw);
imCFPbg=subBG(imCFP_raw,bgmask,CFPbg);
imFRETbg=subBG(imFRET_raw,bgmask,FRETbg);
%%%%%% Get mask from raw FRET image
[mask cellCoorsTemp]=getCellMaskCyto_2(imFRETbg,1000, frameNum, position, threshold); %+imCFPbg
maskFinal{frameNum}=mask;
cellCoors{frameNum}=cellCoorsTemp;
%%%%%% Detrmine ratio
imFRETbg(~mask)=nan;
imFRET=ndnanfilter(imFRETbg,fspecial('disk',3),'replicate');
imCFPbg(~mask)=nan;
imCFP=ndnanfilter(imCFPbg,fspecial('disk',3),'replicate');
imRatio_raw{frameNum}=imFRET./imCFP;
imRatio_raw{frameNum}(~mask)=nan;
CFP_raw{frameNum}=imCFP;
FRET_raw{frameNum}=imFRET;
%%%%%% Generate and write files for raw ratio and outlined objects
% tempRATIO=ratio2RGB(imRatio_raw{frameNum},colorRange);
imFRETOutline{frameNum}=DrawMaskOutline(imFRET_raw,mask);
imwrite(imFRETOutline{frameNum},[datadir,filesep,position,'_Outline_prelim.tif'],'WriteMode','append','Compression','none');
end
%%%%%% Bleaching correction: Detrmine linear fit parameters for FRET/CFP decay
bleach_1=nanmean(vect(imRatio_raw{1}));
%bleach_raw = {}; bleach_raw_mRuby = {};
for frameNum=1:length(imRatio_raw)
bleach_raw(frameNum)=nanmean(vect(imRatio_raw{frameNum}));
end
save([datadir,filesep,position,'_RatioData_raw.mat'],'maskFinal','cellCoors','imRatio_raw','imFRETOutline','-v7.3');
save([datadir,filesep,position,'_Bleach_raw.mat'],'bleach_raw', 'CFP_raw','FRET_raw');
end