


missingSeg2to1 : finds missing segment in regC.
Segments in regC are used that are close to the segment
between the two regions regR(1) and regR(2) in data_r.
if a segment is found that fits the requirements data_new is made with
the new cell_mask and success is returned as true. Else the same data is
returned and success is false.
INPUT :
data_c : current data (seg/err) file.
regC : numbers of region in current data that needs to be separated
data_r : reverse data (seg/err) file.
regR : numbers of regions in reverse data file
CONST : segmentation parameters
OUTPUT :
data_new : data_c with new segment in good_segs and modified cell mask
success : true if segment was found succesfully.
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/>.

0001 function [data_c, success] = splitAtBestSeg (data_c, regC, CONST) 0002 % missingSeg2to1 : finds missing segment in regC. 0003 % Segments in regC are used that are close to the segment 0004 % between the two regions regR(1) and regR(2) in data_r. 0005 % if a segment is found that fits the requirements data_new is made with 0006 % the new cell_mask and success is returned as true. Else the same data is 0007 % returned and success is false. 0008 % 0009 % INPUT : 0010 % data_c : current data (seg/err) file. 0011 % regC : numbers of region in current data that needs to be separated 0012 % data_r : reverse data (seg/err) file. 0013 % regR : numbers of regions in reverse data file 0014 % CONST : segmentation parameters 0015 % 0016 % OUTPUT : 0017 % data_new : data_c with new segment in good_segs and modified cell mask 0018 % success : true if segment was found succesfully. 0019 % 0020 % Copyright (C) 2016 Wiggins Lab 0021 % Written by Stella Stylianidou 0022 % University of Washington, 2016 0023 % This file is part of SuperSegger. 0024 % 0025 % SuperSegger is free software: you can redistribute it and/or modify 0026 % it under the terms of the GNU General Public License as published by 0027 % the Free Software Foundation, either version 3 of the License, or 0028 % (at your option) any later version. 0029 % 0030 % SuperSegger is distributed in the hope that it will be useful, 0031 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0032 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0033 % GNU General Public License for more details. 0034 % 0035 % You should have received a copy of the GNU General Public License 0036 % along with SuperSegger. If not, see <http://www.gnu.org/licenses/>. 0037 0038 success = 0; 0039 0040 [xx,yy] = getBBpad(data_c.regs.props(regC).BoundingBox,size(data_c.phase),4); 0041 mask = (data_c.regs.regs_label(yy,xx) == regC); 0042 segMask = (mask - data_c.segs.segs_3n(yy,xx) - data_c.segs.segs_good(yy,xx)) > 0; 0043 0044 badSegMask = logical(data_c.segs.segs_bad(yy,xx) .* segMask); 0045 labelMask = data_c.segs.segs_label(yy,xx); 0046 segIDs = unique(labelMask(badSegMask)); 0047 0048 highScores = data_c.segs.scoreRaw(segIDs) > 45; 0049 [~, maxID] = max(data_c.segs.scoreRaw(segIDs)); 0050 0051 splitIDs = segIDs(highScores); 0052 splitIDs = [splitIDs; segIDs(maxID)]; 0053 splitIDs = unique(splitIDs); 0054 0055 if regC == 53 0056 disp('test'); 0057 end 0058 0059 newMask = ones(numel(yy), numel(xx)); 0060 if numel(splitIDs) > 0 0061 for i = 1:numel(splitIDs) 0062 newMask = newMask .* (logical(data_c.mask_cell(yy,xx) .* segMask) & ~logical((labelMask == splitIDs(i)))); 0063 newMask = imdilate(imerode(newMask, ones(3)), ones(3)); 0064 end 0065 0066 % Successfully split into 2 regions 0067 if max(unique(bwlabel(newMask))) > 1 0068 fullMask = logical(newMask) + (~mask .* logical(data_c.mask_cell(yy,xx))); 0069 data_c.mask_cell(yy,xx) = logical(data_c.mask_cell(yy,xx)) & logical(fullMask); 0070 0071 success = 1; 0072 end 0073 end