Home > SuperSegger > trainingConstants > intMakeRegs.m

intMakeRegs

PURPOSE ^

intMakeRegs : creates info for bad regions or makes new regions

SYNOPSIS ^

function data = intMakeRegs( data, CONST, mask_bad_regs, good_regs )

DESCRIPTION ^

 intMakeRegs : creates info for bad regions or makes new regions

 INPUT :
       data : cell file (seg/err file)
       CONST : segmentation constants
       mask_bad_regs : mask of bad regions (their score is set to 0)
       good_regs : if 1 all scores are set to 1
 OUTPUT : 
       data : cell file with region fields

 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 data = intMakeRegs( data, CONST, mask_bad_regs, good_regs )
0002 % intMakeRegs : creates info for bad regions or makes new regions
0003 %
0004 % INPUT :
0005 %       data : cell file (seg/err file)
0006 %       CONST : segmentation constants
0007 %       mask_bad_regs : mask of bad regions (their score is set to 0)
0008 %       good_regs : if 1 all scores are set to 1
0009 % OUTPUT :
0010 %       data : cell file with region fields
0011 %
0012 % Copyright (C) 2016 Wiggins Lab
0013 % Written by Stella Stylianidou & Paul Wiggins.
0014 % University of Washington, 2016
0015 % This file is part of SuperSegger.
0016 %
0017 % SuperSegger is free software: you can redistribute it and/or modify
0018 % it under the terms of the GNU General Public License as published by
0019 % the Free Software Foundation, either version 3 of the License, or
0020 % (at your option) any later version.
0021 %
0022 % SuperSegger is distributed in the hope that it will be useful,
0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 % GNU General Public License for more details.
0026 %
0027 % You should have received a copy of the GNU General Public License
0028 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0029 
0030 E = CONST.regionScoreFun.E;
0031 
0032 %sets all scores to 1
0033 if ~exist('good_regs','var') || isempty(good_regs)
0034     good_regs = false;
0035 end
0036 
0037 ss = size( data.mask_cell );
0038 NUM_INFO = CONST.regionScoreFun.NUM_INFO;
0039 data.regs.regs_label = bwlabel( data.mask_cell );
0040 data.regs.num_regs = max( data.regs.regs_label(:) );
0041 data.regs.props = regionprops( data.regs.regs_label, ...
0042     'BoundingBox','Orientation','Centroid','Area');
0043 data.regs.score  = ones( data.regs.num_regs, 1 );
0044 data.regs.scoreRaw = ones( data.regs.num_regs, 1 );
0045 data.regs.info = zeros( data.regs.num_regs, NUM_INFO );
0046 
0047 
0048 for ii = 1:data.regs.num_regs
0049     
0050     [xx,yy] = getBBpad( data.regs.props(ii).BoundingBox, ss, 1);
0051     mask = data.regs.regs_label(yy,xx)==ii;
0052     data.regs.info(ii,:) = CONST.regionScoreFun.props( mask, data.regs.props(ii) );
0053     
0054     if exist( 'mask_bad_regs', 'var' ) && ~isempty( mask_bad_regs )
0055         data.regs.scoreRaw(ii) = CONST.regionScoreFun.fun(data.regs.info(ii,:), E);
0056         data.regs.score(ii) = data.regs.scoreRaw(ii) > 0;
0057         mask_ = mask_bad_regs(yy,xx);
0058         if any( mask(mask_) )
0059             data.regs.score(ii) = 0;
0060         end
0061     end
0062     
0063 end
0064 
0065 if ~exist( 'mask_bad_regs', 'var' ) || isempty( mask_bad_regs )
0066     if good_regs
0067         data.regs.scoreRaw = CONST.regionScoreFun.fun(data.regs.info, E)';
0068         data.regs.score = ones( data.regs.num_regs, 1 );
0069     else
0070         data.regs.scoreRaw = CONST.regionScoreFun.fun(data.regs.info, E)';
0071         data.regs.score =   data.regs.scoreRaw>0;
0072     end
0073 end
0074 
0075 
0076 end

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