trackOptiFindFoci : Finds foci in cells. Note that this only runs if the number of foci to be fit is set in CONST.trackLoci.numSpots. It runs on the err.mat files and saves the new err.mat files with the found foci. This is done using the curve filter to find the foci in the image and then by fitting gaussians and and assigning the foci in all cells simultaneously. INPUT : dirname: is the seg directory in the xy directory CONST: are the segmentation constants. header : string displayed with information Copyright (C) 2016 Wiggins Lab Written by Stella Stylianidou & Paul Wiggins. University of Washington, 2016 This file is part of SuperSegger. SuperSegger 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. SuperSegger 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 SuperSegger. If not, see <http://www.gnu.org/licenses/>.
0001 function trackOptiFindFoci(dirname,CONST,header) 0002 % trackOptiFindFoci : Finds foci in cells. Note that this only 0003 % runs if the number of foci to be fit is set in CONST.trackLoci.numSpots. 0004 % It runs on the err.mat files and saves the new err.mat files with the 0005 % found foci. This is done using the curve filter to find the foci in the 0006 % image and then by fitting gaussians and and assigning the foci 0007 % in all cells simultaneously. 0008 % 0009 % INPUT : 0010 % dirname: is the seg directory in the xy directory 0011 % CONST: are the segmentation constants. 0012 % header : string displayed with information 0013 % 0014 % Copyright (C) 2016 Wiggins Lab 0015 % Written by Stella Stylianidou & Paul Wiggins. 0016 % University of Washington, 2016 0017 % This file is part of SuperSegger. 0018 % 0019 % SuperSegger is free software: you can redistribute it and/or modify 0020 % it under the terms of the GNU General Public License as published by 0021 % the Free Software Foundation, either version 3 of the License, or 0022 % (at your option) any later version. 0023 % 0024 % SuperSegger is distributed in the hope that it will be useful, 0025 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0026 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0027 % GNU General Public License for more details. 0028 % 0029 % You should have received a copy of the GNU General Public License 0030 % along with SuperSegger. If not, see <http://www.gnu.org/licenses/>. 0031 0032 if ~exist('header','var') 0033 header = []; 0034 end 0035 0036 dirname = fixDir( dirname ); 0037 0038 % Get the error data file names with the region information 0039 contents=dir([dirname,'*_err.mat']); 0040 num_im = numel(contents); 0041 0042 data_c = loaderInternal([dirname,contents(1).name]); 0043 nc = 0; 0044 tmp_fn = fieldnames(data_c); 0045 nf = numel(tmp_fn); 0046 0047 % goes through the fields in data_c and calculates the number of fluorescence channels 0048 for j = 1:nf; 0049 if numel(strfind(tmp_fn{j},'fluor')==1) && ~numel((strfind(tmp_fn{j},'fluor0'))) 0050 nc = nc+1; 0051 end 0052 end 0053 0054 if ~isfield( data_c, 'fluor1' ) || ~isfield( CONST.trackLoci, 'numSpots' ) ||... 0055 ~any(CONST.trackLoci.numSpots) 0056 disp ('No foci were fit. Set the constants if you want foci.'); 0057 return; 0058 end 0059 0060 0061 if CONST.parallel.show_status 0062 h = waitbar( 0, 'Find Loci.'); 0063 cleanup = onCleanup( @()( delete( h ) ) ); 0064 else 0065 h = []; 0066 end 0067 0068 for i = 1:num_im; % finding loci through every image 0069 intDoFoci( i, dirname, contents, nc, CONST); 0070 if CONST.parallel.show_status 0071 waitbar(i/num_im,h,['Find Loci--Frame: ',num2str(i),'/',num2str(num_im)]); 0072 else 0073 disp( [header, 'FindLoci: No status bar. Frame ',num2str(i), ... 0074 ' of ', num2str(num_im),'.']); 0075 end 0076 end 0077 0078 if CONST.parallel.show_status 0079 close(h); 0080 end 0081 0082 0083 end 0084 0085 function data = loaderInternal( filename ) 0086 data = load(filename); 0087 end 0088 0089 function intDoFoci( i, dirname, contents, nc, CONST) 0090 % intDoLoci : finds the foci in image i 0091 % 0092 % INPUT : 0093 % i : time frame number 0094 % dirname : seg directory path in xy folder 0095 % contents : seg/err data files 0096 % nc : number of channels 0097 % CONST : segmentation parameters 0098 0099 data_c = loaderInternal([dirname,contents(i).name]); 0100 0101 % Loop through the different fluorescence channels 0102 for channel_number = 1:nc 0103 if isfield( CONST.trackLoci, 'numSpots' ) && numel(CONST.trackLoci.numSpots)>=channel_number 0104 if CONST.trackLoci.numSpots(channel_number) 0105 % only runs if non zero number of foci are set in constants 0106 % Fits the foci 0107 data_c = intFindFociCurve( data_c, CONST, channel_number ); 0108 end 0109 end 0110 end 0111 0112 dataname = [dirname,contents(i).name]; 0113 save(dataname,'-STRUCT','data_c'); 0114 0115 end 0116