Home > SuperSegger > settings > loadConstants.m

loadConstants

PURPOSE ^

loadConstants : loads the parameters for the superSegger/trackOpti package.

SYNOPSIS ^

function CONST = loadConstants( res, PARALLEL_FLAG, dispText )

DESCRIPTION ^

 loadConstants : loads the parameters for the superSegger/trackOpti package.
 If you want to customize the constants DO NOT CHANGE
 THIS FILE! Rename this file loadConstantsMine.m and
 put in somehwere in the path.
 That file will load automatically rather than this one.
 When you make loadConstantsMine.m, change
 disp( 'loadConstants: Initializing.')
 to loadConstantsMine to avoid confusion.

 INPUT :
   res : name of constants file in the settings folder (without the .mat) to be loaded.
         If you use a number (60 or 100) it loads the 60X or 100X for E. coli
   PARALLEL_FLAG : 1 if you want to use parallel computation
                   0 for single core computation
   dispText : to display the name of the constants that are loaded.


 Copyright (C) 2016 Wiggins Lab
 Written by Stella Stylianidou
 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 CONST = loadConstants( res, PARALLEL_FLAG, dispText )
0002 % loadConstants : loads the parameters for the superSegger/trackOpti package.
0003 % If you want to customize the constants DO NOT CHANGE
0004 % THIS FILE! Rename this file loadConstantsMine.m and
0005 % put in somehwere in the path.
0006 % That file will load automatically rather than this one.
0007 % When you make loadConstantsMine.m, change
0008 % disp( 'loadConstants: Initializing.')
0009 % to loadConstantsMine to avoid confusion.
0010 %
0011 % INPUT :
0012 %   res : name of constants file in the settings folder (without the .mat) to be loaded.
0013 %         If you use a number (60 or 100) it loads the 60X or 100X for E. coli
0014 %   PARALLEL_FLAG : 1 if you want to use parallel computation
0015 %                   0 for single core computation
0016 %   dispText : to display the name of the constants that are loaded.
0017 %
0018 %
0019 % Copyright (C) 2016 Wiggins Lab
0020 % Written by Stella Stylianidou
0021 % University of Washington, 2016
0022 % This file is part of SuperSegger.
0023 %
0024 % SuperSegger is free software: you can redistribute it and/or modify
0025 % it under the terms of the GNU General Public License as published by
0026 % the Free Software Foundation, either version 3 of the License, or
0027 % (at your option) any later version
0028 %
0029 % SuperSegger is distributed in the hope that it will be useful,
0030 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0031 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0032 % GNU General Public License for more details.
0033 %
0034 % You should have received a copy of the GNU General Public License
0035 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0036 
0037 % gets the list of all possible constants in the settings folder
0038 [possibleConstants, list, filepath] = getConstantsList();
0039 
0040 CONST = [];
0041 if nargin < 1 || isempty( res )
0042    disp ('No constant chosen. Possible constants are : ');
0043    disp(list');
0044    return;
0045 end
0046 
0047 if ~exist('PARALLEL_FLAG','var') || isempty( PARALLEL_FLAG )
0048     PARALLEL_FLAG = false;
0049 end
0050 
0051 if ~exist('dispText','var') || isempty( dispText )
0052     dispText = true;
0053 end
0054 
0055 
0056 
0057 % default values for numbers
0058 resFlag = [];
0059 if isa(res,'double' ) && res == 60
0060     res = '60XEc';
0061 elseif isa(res,'double' ) && res == 100
0062     res = '100XEc';
0063 end
0064 
0065 %% Parameters that are the same for all constants
0066 % Settings for alignment in different channels - modify for your microscope
0067 CONST.imAlign.DAPI    = [-0.0354   -0.0000    1.5500   -0.3900];
0068 CONST.imAlign.mCherry = [-0.0512   -0.0000   -1.1500    1.0000];
0069 CONST.imAlign.GFP     = [ 0.0000    0.0000    0.0000    0.0000];
0070 
0071 CONST.imAlign.out = {CONST.imAlign.GFP, ...   % c1 channel name
0072     CONST.imAlign.GFP,...  % c2 channel name
0073     CONST.imAlign.GFP,...  % c3 channel name
0074     CONST.imAlign.GFP};    % c4 channel name
0075 
0076 CONST.imAlign.AlignToFirst = false; % align all images to first image
0077 CONST.imAlign.AlignChannel = 1; % channel to use for alignment
0078 CONST.imAlign.medFilt = false; % use median filter during alignment
0079 CONST.align.ALIGN_FLAG = 1; % align images (boolean)
0080 
0081 % segmenation default parameters
0082 CONST.superSeggerOpti.segmenting_fluorescence = false;
0083 CONST.superSeggerOpti.remove_debris = true;
0084 CONST.superSeggerOpti.INTENSITY_DIF = 0.15;
0085 CONST.superSeggerOpti.PEBBLE_CONST = 3;
0086 CONST.superSeggerOpti.remove_microcolonies = true;
0087 
0088 % region optimization parameters
0089 CONST.regionOpti.MAX_NUM_RESOLVE = 10000; % no region optimization above this number of segments
0090 CONST.regionOpti.MAX_NUM_SYSTEMATIC = 8; % max number of segments for systematic
0091 CONST.regionOpti.CutOffScoreHi = 10; % cut off score for segments
0092 CONST.regionOpti.CutOffScoreLo = -10; % cut off score for segments
0093 CONST.regionOpti.Nt = 500; % max number of steps in simulated anneal
0094 CONST.regionOpti.minGoodRegScore = 10; % regions with score below this are optimized.
0095 CONST.regionOpti.neighMaxScore = 10; % max score for neighbor to be optimized with a bad region
0096 CONST.regionOpti.ADJUST_FLAG = 1; % adjusts simulated anneal with number of segs
0097 CONST.regionOpti.DE_norm = 0.5000; % segments' weight for global region opti scoring
0098 
0099 % trackOpti : general constants
0100 CONST.trackOpti.NEIGHBOR_FLAG = 0; % finds cell neighbors
0101 
0102 % trackOpti : linking constants
0103 CONST.trackOpti.OVERLAP_LIMIT_MIN = 0.0800;
0104 CONST.trackOpti.DA_MAX = 0.3; % maximum area change in linking from r->c
0105 CONST.trackOpti.DA_MIN = -0.2; % minimum area change in linking from r->c
0106 CONST.trackOpti.LYSE_FLAG = 0; % not working anymore.
0107 CONST.trackOpti.REMOVE_STRAY = 0; % deletes stray regions and their children
0108 CONST.trackOpti.MIN_CELL_AGE = 5; % minimum cell age for full cell cycle
0109 CONST.trackOpti.linkFun = @multiAssignmentSparse; % function used for linking cells
0110 CONST.trackOpti.SMALL_AREA_MERGE = 55; % in the linking phase, this regions with this area are merged with the ones next to them.
0111 CONST.trackOpti.MIN_AREA_NO_NEIGH = 30; % regions with area below this and no neighbors are discarded;
0112 CONST.trackOpti.MIN_AREA = 5; % minimum area a cell region can have, otherwise it is discarded.
0113 
0114 % Fluorescence calculations : locates foci and caclulates fluorescence
0115 % statistics.
0116 CONST.trackLoci.numSpots = []; % needs to be set to the number of spots per channel to find foci
0117 CONST.trackLoci.fluorFlag = 1; % to calculate fluorescence statistics
0118 
0119 %  you can set an initial gate here
0120 CONST.trackLoci.gate  = [];
0121 
0122 
0123 % pixelsize in um
0124 if all(ismember('100X',res)) % 60 nm per pixel
0125     CONST.getLocusTracks.PixelSize        = 6/60;
0126 elseif all(ismember('60X',res)) % 100 nm per pixel
0127     CONST.getLocusTracks.PixelSize        = 6/100;
0128 else
0129     CONST.getLocusTracks.PixelSize        = [];
0130 end
0131 
0132 % getLocusTracks Constants
0133 CONST.getLocusTracks.FLUOR1_MIN_SCORE = 3; % only foci above this score are shown in the viewer
0134 CONST.getLocusTracks.FLUOR2_MIN_SCORE = 3;
0135 CONST.getLocusTracks.FLUOR1_REL       = 0.3;
0136 CONST.getLocusTracks.FLUOR2_REL       = 0.3;
0137 CONST.getLocusTracks.TimeStep         = 1; % used for time axis when towers and kymos are made
0138 
0139 % view constants
0140 CONST.view.showFullCellCycleOnly = false; % only uses full cell cycle for analysis tools
0141 CONST.view.orientFlag = true; % to orient the cells along the horizontal axis for the analysis tools
0142 CONST.view.falseColorFlag = false;
0143 CONST.view.fluorColor = {'g','r','b','c','o','y'}; % order of channel colors to be used for display
0144 CONST.view.LogView = false;
0145 CONST.view.filtered = 1;
0146 CONST.view.maxNumCell = []; % maximum number of cells used for analysis tools
0147 
0148 
0149 % super resolution constants - not used in released version
0150 % Const for findFocusSR
0151 CONST.findFocusSR.MAX_FOCUS_NUM = 8;
0152 CONST.findFocusSR.crop          = 4;
0153 CONST.findFocusSR.gaussR        = 1;
0154 CONST.findFocusSR.MAX_TRACE_NUM = 1000;
0155 CONST.findFocusSR.WS_CUT        = 50;
0156 CONST.findFocusSR.MAX_OFF       = 3;
0157 CONST.findFocusSR.I_MIN         = 150;
0158 CONST.findFocusSR.mag           = 16;
0159 CONST.findFocusSR.MIN_TRACE_LEN = 0;
0160 CONST.findFocusSR.R_LINK        = 2;
0161 CONST.findFocusSR.R_LINK        = 2;
0162 CONST.findFocusSR.SED_WINDOW    = 10;
0163 CONST.findFocusSR.SED_P         = 10;
0164 CONST.findFocusSR.A_MIN         =  6;
0165 
0166 % Const for SR - not used in released version
0167 CONST.SR.opt =  optimset('MaxIter',1000,'Display','off', 'TolX', 1e-8);
0168 
0169 % for image processing
0170 CONST.SR.GausImgFilter_HighPass = fspecial('gaussian',141,10);
0171 CONST.SR.GausImgFilter_LowPass3 = fspecial('gaussian',21,3);
0172 CONST.SR.GausImgFilter_LowPass2 = fspecial('gaussian',21,2);
0173 CONST.SR.GausImgFilter_LowPass1 = fspecial('gaussian',7,1.25);
0174 CONST.SR.maxBlinkNum = 2;
0175 
0176 % pad size for cropping regions for fitting
0177 CONST.SR.pad = 8;
0178 CONST.SR.crop = 4;
0179 CONST.SR.Icut = 1000;
0180 CONST.SR.rcut = 10; % maximum distance between frames for two PSFs
0181 % to be considered two seperate PSFs.
0182 CONST.SR.Ithresh = 2; % threshold intensity in std for including loci in analysis
0183 
0184 %% Loading the constant
0185 % constants file is loaded here using input 'res'
0186 indexConst = find(strcmpi({possibleConstants.name},[res,'.mat']));
0187 if ~isempty(indexConst)
0188      constFilename = possibleConstants(indexConst).name;
0189      ConstLoaded = load ([filepath,filesep,constFilename]);
0190      CONST.ResFlag = constFilename(1:end-4);
0191      if dispText
0192         disp(['loading Constants : ', constFilename]);
0193      end
0194 elseif exist(res, 'file')
0195     ConstLoaded = load(res);
0196     CONST.ResFlag = res;
0197 else
0198     errordlg('loadConstants: Constants not loaded : no match found. Aborting. ');
0199     disp(['Possible constants']);
0200     disp(list');
0201     CONST = [];
0202     return;
0203 end
0204 
0205 
0206 
0207 
0208 
0209 %% Parameters overwritten separately for each constant :
0210 % Set by the loaded constant. - you can add here values that you have changed
0211 % from the default and should be loaded from your constants file.
0212 
0213 % segmentation parameters
0214 
0215 % removes debris using the texture of the colonies, and the intensity
0216 % difference of the halo and inside the cells
0217 
0218 % updated values
0219 if isfield (ConstLoaded.superSeggerOpti,'remove_debris')
0220     CONST.superSeggerOpti.remove_debris = ConstLoaded.superSeggerOpti.remove_debris;
0221 end
0222 
0223 if isfield (ConstLoaded.superSeggerOpti,'INTENSITY_DIF')
0224    CONST.superSeggerOpti.INTENSITY_DIF = ConstLoaded.superSeggerOpti.INTENSITY_DIF;
0225 end
0226 
0227 if isfield (ConstLoaded.superSeggerOpti,'PEBBLE_CONST')
0228   CONST.superSeggerOpti.PEBBLE_CONST = ConstLoaded.superSeggerOpti.PEBBLE_CONST;
0229 end
0230 
0231 if isfield (ConstLoaded.superSeggerOpti,'segmenting_fluorescence')
0232     CONST.superSeggerOpti.segmenting_fluorescence = ConstLoaded.superSeggerOpti.segmenting_fluorescence;
0233 end
0234 
0235 % removes false microcolonies if using the mean intensity
0236 if isfield (ConstLoaded.superSeggerOpti,'remove_microcolonies')
0237     CONST.superSeggerOpti.remove_microcolonies = ConstLoaded.superSeggerOpti.remove_microcolonies;
0238 end
0239 
0240 % max number of total segments for segmentation
0241 CONST.superSeggerOpti.MAX_SEG_NUM = 50000;
0242 
0243 CONST.superSeggerOpti.dIcellNonCell = 0.2;
0244 
0245 % objects with less area than this are removed from the mask
0246 CONST.superSeggerOpti.MIN_BG_AREA = ConstLoaded.superSeggerOpti.MIN_BG_AREA;
0247 
0248 % intensity thresholds for initial mask creation
0249 CONST.superSeggerOpti.THRESH1= ConstLoaded.superSeggerOpti.THRESH1;
0250 CONST.superSeggerOpti.THRESH2 = ConstLoaded.superSeggerOpti.THRESH2;
0251 
0252 % radius of minimum/magic filter - should be about the width of the cell
0253 CONST.superSeggerOpti.MAGIC_RADIUS = ConstLoaded.superSeggerOpti.MAGIC_RADIUS;
0254 
0255 % intensity used to find halos in the magic contrast image
0256 CONST.superSeggerOpti.CUT_INT= ConstLoaded.superSeggerOpti.CUT_INT;
0257 
0258 % intensities below this are set to 0 to remove variation in intesnity within a cell region.
0259 CONST.superSeggerOpti.MAGIC_THRESHOLD = ConstLoaded.superSeggerOpti.MAGIC_THRESHOLD;
0260 
0261 % width of gaussian blur in phase image
0262 CONST.superSeggerOpti.SMOOTH_WIDTH= ConstLoaded.superSeggerOpti.SMOOTH_WIDTH;
0263 
0264 % cells with width bigger than this are iteratively added more segments
0265 CONST.superSeggerOpti.MAX_WIDTH= ConstLoaded.superSeggerOpti.MAX_WIDTH;
0266 
0267 % max area for micro-colonies to be filled
0268 CONST.superSeggerOpti.Amax = ConstLoaded.superSeggerOpti.Amax;
0269 
0270 % erosion size of disk at the creation of the background mask
0271 CONST.superSeggerOpti.crop_rad = ConstLoaded.superSeggerOpti.crop_rad;
0272 CONST.superSeggerOpti.A = ConstLoaded.superSeggerOpti.A; % neural network for segment scoring
0273 CONST.superSeggerOpti.NUM_INFO= ConstLoaded.superSeggerOpti.NUM_INFO; % number of parameters used
0274 
0275 CONST.seg = ConstLoaded.seg; % defines segments scoring functions
0276 
0277 % region optimizing parameters parameters
0278 % regions with smaller length than min_length are optimized by using all segments surrounding them
0279 CONST.regionOpti.MIN_LENGTH = ConstLoaded.regionOpti.MIN_LENGTH ;
0280 CONST.regionScoreFun = ConstLoaded.regionScoreFun; % defines region scoring functions
0281 
0282 if isfield (ConstLoaded.trackOpti,'SMALL_AREA_MERGE')
0283 CONST.trackOpti.SMALL_AREA_MERGE = ConstLoaded.trackOpti.SMALL_AREA_MERGE; % in the linking phase, this regions with this area are merged with the ones next to them.
0284 end
0285 
0286 if isfield (ConstLoaded.trackOpti,'MIN_AREA_NO_NEIGH')
0287 CONST.trackOpti.MIN_AREA_NO_NEIGH = ConstLoaded.trackOpti.MIN_AREA_NO_NEIGH; % regions with area below this and no neighbors are discarded;
0288 end
0289 
0290 if isfield (ConstLoaded.trackOpti,'MIN_AREA')
0291 CONST.trackOpti.MIN_AREA = ConstLoaded.trackOpti.MIN_AREA;  % minimum area a cell region can have, otherwise it is discarded.
0292 end
0293 
0294 %% Parallel processing on multiple cores settings :
0295 if PARALLEL_FLAG
0296     poolobj = gcp('nocreate'); % If no pool, do not create new one.
0297     if isempty(poolobj)
0298         poolobj = parpool('local');
0299     end
0300     poolobj.IdleTimeout = 360; % close after idle for 3 hours
0301     CONST.parallel.parallel_pool_num = poolobj.NumWorkers;
0302 else
0303     CONST.parallel.parallel_pool_num = 0;
0304 end
0305 
0306 CONST.parallel.xy_parallel = 0;
0307 CONST.parallel.PARALLEL_FLAG = PARALLEL_FLAG;
0308 CONST.parallel.show_status = ~(CONST.parallel.parallel_pool_num);
0309 CONST.parallel.verbose = 1;
0310 
0311 % orders the fields alphabetically
0312 CONST = orderfields(CONST);
0313 
0314 end

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