trackOptiListNeighbor : creates a neighbors list for each cell. INPUT : dirname : seg folder eg. maindirectory/xy1/seg CONST : segmentation constants. header : string displayed with information OUTPUT : clist_temp : contains list of neighbors Copyright (C) 2016 Wiggins Lab Written by 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 [clist_tmp] = trackOptiListNeighbor(dirname,CONST,header) 0002 % trackOptiListNeighbor : creates a neighbors list for each cell. 0003 % 0004 % INPUT : 0005 % dirname : seg folder eg. maindirectory/xy1/seg 0006 % CONST : segmentation constants. 0007 % header : string displayed with information 0008 % OUTPUT : 0009 % clist_temp : contains list of neighbors 0010 % 0011 % Copyright (C) 2016 Wiggins Lab 0012 % Written by Paul Wiggins. 0013 % University of Washington, 2016 0014 % This file is part of SuperSegger. 0015 % 0016 % SuperSegger is free software: you can redistribute it and/or modify 0017 % it under the terms of the GNU General Public License as published by 0018 % the Free Software Foundation, either version 3 of the License, or 0019 % (at your option) any later version. 0020 % 0021 % SuperSegger is distributed in the hope that it will be useful, 0022 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0023 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0024 % GNU General Public License for more details. 0025 % 0026 % You should have received a copy of the GNU General Public License 0027 % along with SuperSegger. If not, see <http://www.gnu.org/licenses/>. 0028 0029 if ~exist('header','var') 0030 header = []; 0031 end 0032 0033 if(nargin<1 || isempty(dirname)) 0034 dirname = '.'; 0035 end 0036 dirname = fixDir(dirname); 0037 0038 % Get the track file names... 0039 contents=dir([dirname '*_err.mat']); 0040 if isempty(contents) 0041 disp('trackOptiListNeighbor : No files found'); 0042 clist_tmp.data = []; 0043 clist_tmp.def={}; 0044 clist_tmp.gate=[]; 0045 else 0046 data_c = loaderInternal([dirname,contents(end).name]); 0047 MAX_CELL = max(data_c.regs.ID) + 100; 0048 num_im = numel(contents); 0049 0050 if CONST.parallel.show_status 0051 h = waitbar( 0, 'Make Neighbor List.'); 0052 cleanup = onCleanup( @()( delete( h ) ) ); 0053 else 0054 h = []; 0055 end 0056 0057 clist_tmp = cell( 1, MAX_CELL ); 0058 0059 % loop through all the cells. 0060 for i = 1:num_im 0061 data_c = loaderInternal([dirname,contents(i ).name]); 0062 if CONST.parallel.show_status 0063 waitbar(i/num_im,h,['Make Neighbor List--Frame: ',num2str(i),'/',num2str(num_im)]); 0064 else 0065 disp([header, 'Make Neighbor List. frame: ',num2str(i),' of ',num2str(num_im)]); 0066 end 0067 0068 for j = 1:data_c.regs.num_regs 0069 ID = data_c.regs.ID(j); 0070 if ID 0071 neigh = data_c.regs.ID( makenat(data_c.regs.neighbors{j}) ); 0072 neigh = neigh(logical(neigh)); 0073 if ID > MAX_CELL 0074 clist_tmp{ ID } = [neigh]; 0075 else 0076 clist_tmp{ ID } = [clist_tmp{ID}, neigh]; 0077 end 0078 end 0079 end 0080 0081 0082 end 0083 0084 % save the updated err files. 0085 if CONST.parallel.show_status 0086 close(h); 0087 end 0088 0089 0090 end 0091 end 0092 0093 function data = loaderInternal( filename ) 0094 data = load( filename ); 0095 end