Home > SuperSegger > frameLink > trackOpti.m

trackOpti

PURPOSE ^

trackOpti : calls the rest of the functions for segmentation

SYNOPSIS ^

function clist = trackOpti(dirname,skip,CONST, header, startEnd)

DESCRIPTION ^

 trackOpti : calls the rest of the functions for segmentation
 After each sub-function is called, is creates a file in the seg directory
 that begins with .trackOpti (they are hidden, you?ll have to use ?ls -a?
 to see these)  and then the function name, e.g. .trackOptiSetEr.mat.
 This is designed in case the segmentation dies somewhere in middle and you
 want to restart without having to recalculate everything;
 if these files exist, it won't rerun that particular function again.
 If you DO need to rerun one of these functions, you'll
 have to delete the respective .trackOpti file for it to work.

 INPUT :
       dirname : xy folder
       skip : frames to be skipped in segmentation, default is 1.
       CONST : Constants file
       header : information string
       startEnd : start and end stage
 OUTPUT :
       clist : list of cells with time-independent information about each

 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/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function clist = trackOpti(dirname,skip,CONST, header, startEnd) 
0002 % trackOpti : calls the rest of the functions for segmentation
0003 % After each sub-function is called, is creates a file in the seg directory
0004 % that begins with .trackOpti (they are hidden, you?ll have to use ?ls -a?
0005 % to see these)  and then the function name, e.g. .trackOptiSetEr.mat.
0006 % This is designed in case the segmentation dies somewhere in middle and you
0007 % want to restart without having to recalculate everything;
0008 % if these files exist, it won't rerun that particular function again.
0009 % If you DO need to rerun one of these functions, you'll
0010 % have to delete the respective .trackOpti file for it to work.
0011 %
0012 % INPUT :
0013 %       dirname : xy folder
0014 %       skip : frames to be skipped in segmentation, default is 1.
0015 %       CONST : Constants file
0016 %       header : information string
0017 %       startEnd : start and end stage
0018 % OUTPUT :
0019 %       clist : list of cells with time-independent information about each
0020 %
0021 % Copyright (C) 2016 Wiggins Lab
0022 % Written by Stella Stylianidou & Paul Wiggins
0023 % University of Washington, 2016
0024 % This file is part of SuperSegger.
0025 %
0026 % SuperSegger is free software: you can redistribute it and/or modify
0027 % it under the terms of the GNU General Public License as published by
0028 % the Free Software Foundation, either version 3 of the License, or
0029 % (at your option) any later version.
0030 %
0031 % SuperSegger is distributed in the hope that it will be useful,
0032 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0034 % GNU General Public License for more details.
0035 %
0036 % You should have received a copy of the GNU General Public License
0037 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0038 
0039 
0040 
0041 % if the CLEAN_FLAG does not exist, set it to true and remove all existing
0042 % files. This is the safer option.
0043 % if ~exist('CLEAN_FLAG') || isempty( CLEAN_FLAG )
0044 %     CLEAN_FLAG = true;
0045 % end
0046 
0047 if ~exist('header','var')
0048     header = 'trackOpti no header: ';
0049 end
0050 
0051 % turn skip off if skip isn't set.
0052 if ~exist('skip','var') || isempty(skip)
0053     skip = 1;
0054 end
0055 
0056 % directories' names
0057 if nargin < 1 || isempty( dirname );
0058     dirname = '.';
0059 end
0060 
0061 dirname = fixDir(dirname);
0062 dirname_seg  = [dirname,'seg',filesep];
0063 dirname_full = [dirname,'seg_full',filesep];
0064 dirname_cell = [dirname,'cell',filesep];
0065 
0066 if ~exist( dirname_cell, 'dir' )
0067     mkdir(  dirname_cell );
0068 end
0069 
0070 if ~exist( 'startEnd', 'var' ) || isempty( startEnd )
0071     startEnd = [1 20];
0072 end
0073 
0074 
0075 %% trackOptiStripSmall
0076 % removes small regions that are probably not real (bubbles, dust, or minicells)
0077 stamp_name = [dirname_seg,'.trackOptiStripSmall-Step1.mat'];
0078 if ~exist( stamp_name, 'file' ) && (startEnd(1) <= 3 && startEnd(2) >= 3)
0079     disp([header,'trackOpti - Step 1: Running trackOptiStripSmall.']);
0080     trackOptiStripSmall(dirname_seg, CONST);
0081     time_stamp = clock;
0082     save( stamp_name, 'time_stamp');
0083 else
0084     disp([header, 'trackOpti: trackOptiStripSmall already run.'] );
0085 end
0086 
0087 %% Link frames and do error resolution
0088 % Calculate the overlap between cells between subsequent frames.
0089 stamp_name = [dirname_seg,'.trackOptiLinkCell-Step2.mat'];
0090 if ~exist( stamp_name, 'file' ) && (startEnd(1) <= 4 && startEnd(2) >= 4)
0091     disp([header,'trackOpti - Step 2: Running trackOptiLinkCell.']);
0092     delete_old_err_files = 1;
0093     trackOptiLinkCellMulti(dirname_seg, delete_old_err_files, CONST, header);
0094     time_stamp = clock;
0095     save( stamp_name, 'time_stamp');
0096 else
0097     disp([header, 'trackOpti: trackOptiLinkCell already run.'] );
0098 end
0099 
0100 %% Skip Merge
0101 % If skip is bigger than 1, it takes care of merging all the frames skipped.
0102 % the merged skipped frames are placed in the seg_full dir
0103 if skip>1  && ( startEnd(1) <= 4 && startEnd(2) >= 4)
0104     dirname_seg  = dirname_full; % change dirname_seg to seg_all directory
0105     stamp_name = [dirname_seg,'.trackOptiSkipMerge-Step2merge.mat'];
0106     if ~exist( stamp_name, 'file' );
0107         disp([header,'trackOpti - Step 2, merge: Running trackOptiSkipMerge.']);
0108         trackOptiSkipMerge(dirname,skip,CONST, header);
0109         time_stamp = clock;
0110         save( stamp_name, 'time_stamp');
0111     else
0112         disp([header,'trackOpti: trackOptiSkipMerge already run.']);
0113     end
0114     
0115     % Relink and do error resolution for the skipped files
0116     stamp_name = [dirname_seg,'.trackOptiLinkCell-Step2merge.mat'];
0117     if ~exist( stamp_name, 'file' );
0118         disp([header,'trackOpti - Step 2, merge: Running trackOptiLinkCell.']);        
0119         trackOptiLinkCellMulti(dirname_seg, 1, CONST, header);
0120         time_stamp = clock;
0121         save( stamp_name, 'time_stamp');
0122     else
0123         disp([header,'trackOpti: trackOptiLink already run.']);
0124     end   
0125 end
0126 
0127 
0128 %% Cell Marker
0129 % trackOptiCellMarker marks complete cells cycles. clist contains a
0130 % list of cell statistics etc.
0131 stamp_name = [dirname_seg,'.trackOptiCellMarker-Step3.mat'];
0132 if ~exist( stamp_name, 'file' ) && (startEnd(1) <= 5 && startEnd(2) >= 5)
0133     disp([header,'trackOpti - Step 3: Running trackOptiCellMarker.']);        
0134     trackOptiCellMarker(dirname_seg, CONST, header);
0135     time_stamp = clock;
0136     save( stamp_name, 'time_stamp');
0137 else
0138     disp([header,'trackOpti: trackOptiCellMarker already run.']);
0139 end
0140 
0141 %% Fluor
0142 % Calculates Fluorescence Background
0143 stamp_name = [dirname_seg,'.trackOptiFluor-Step4.mat'];
0144 if ~exist( stamp_name, 'file' )  && (startEnd(1) <= 6 && startEnd(2) >= 6)
0145     disp([header,'trackOpti - Step 4: Running trackOptiFluor.']);  
0146     trackOptiFluor(dirname_seg,CONST, header);
0147     time_stamp = clock;
0148     save( stamp_name, 'time_stamp');
0149 else
0150     disp([header,'trackOpti: trackOptiFluor already run.']);
0151 end
0152 
0153 
0154 %% Make Cell
0155 % Computes cell characteristics and puts them in *err files under CellA{}
0156 stamp_name = [dirname_seg,'.trackOptiMakeCell-Step5.mat'];
0157 if ~exist( stamp_name, 'file' )  && (startEnd(1) <= 7 && startEnd(2) >= 7)
0158     disp([header,'trackOpti - Step 5: Running trackOptiMakeCell.']); 
0159     trackOptiMakeCell(dirname_seg, CONST, header);
0160     time_stamp = clock;
0161     save( stamp_name, 'time_stamp');
0162 else
0163     disp([header,'trackOpti: trackOptiMakeCell already run.']);
0164 end
0165 
0166 
0167 %% Finds loci in each fluorescent channel
0168 if sum(CONST.trackLoci.numSpots(:)) && (startEnd(1) <= 8 && startEnd(2) >= 8)
0169     stamp_name = [dirname_seg,'.trackOptiFindFoci-Step6.mat'];
0170     if ~exist( stamp_name, 'file' );
0171         disp([header,'trackOpti - Step 6: Running trackOptiFindFoci.']); 
0172         trackOptiFindFoci(dirname_seg, CONST, header);
0173         time_stamp = clock;
0174         save( stamp_name, 'time_stamp');
0175     else
0176         disp([header,'trackOpti: trackOptiFindFoci already run.']);
0177     end
0178 end
0179 
0180 
0181 %% Make the clist
0182 stamp_name = [dirname_seg,'.trackOptiClist-Step7.mat'];
0183 if ~exist( stamp_name, 'file' ) && (startEnd(1) <= 9 && startEnd(2) >= 9)
0184     disp([header,'trackOpti - Step 7: Running trackOptiClist.']);  
0185     
0186     [clist] = trackOptiClist(dirname_seg, CONST, header);
0187     
0188     if isfield( CONST, 'gate' )
0189         clist.gate = CONST.gate;
0190     end
0191     
0192     try
0193         save( [dirname,'clist.mat'],'-STRUCT','clist');
0194     catch ME
0195         printError(ME);
0196         disp([header,'trackOpti: Cell list error being saved.']);
0197     end
0198     time_stamp = clock;
0199     save( stamp_name, 'time_stamp');
0200 else
0201     disp([header,'trackOpti: trackOptiClist already run.']);
0202 end
0203 
0204 %% cell files
0205 % Organize data into cell files that contain all the time lapse data
0206 % for a single cell.
0207 stamp_name = [dirname_seg,'.trackOptiCellFiles-Step8.mat'];
0208 
0209 if ~exist( stamp_name, 'file' ) && (startEnd(1) <= 10 && startEnd(2) >= 10)
0210     disp([header,'trackOpti - Step 8: Running trackOptiCellFiles.']);  
0211     clist = load([dirname,'clist.mat']);
0212     if isfield( CONST, 'gate' )
0213         clist.gate = CONST.gate;
0214     end
0215     % delete old cell files
0216     delete ([dirname_cell,'cell*.mat']);
0217     delete ([dirname_cell,'Cell*.mat']);   
0218     trackOptiCellFiles(dirname_seg,dirname_cell,CONST, header, clist);
0219     time_stamp = clock;
0220     save( stamp_name, 'time_stamp');
0221 else
0222     disp([header,'trackOpti: trackOptiCellFiles already run.']);
0223 end
0224 
0225 warning('on','MATLAB:DELETE:Permission')
0226 
0227 end
0228 
0229

Generated on Thu 19-Jan-2017 13:55:21 by m2html © 2005