Home > SuperSegger > batch > trackOptiPD.m

trackOptiPD

PURPOSE ^

trackOptiPD : Sets up directories and moves files for SuperSeggerOpti.

SYNOPSIS ^

function trackOptiPD(dirname, CONST)

DESCRIPTION ^

 trackOptiPD : Sets up directories and moves files for SuperSeggerOpti.
 It sets up directory structure for cell segmentation
 analysis and moves aligned images to their respective folders.

 INPUT : 
       dirname : directory that contains images
       CONST : segmentation constants

 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 trackOptiPD(dirname, CONST)
0002 % trackOptiPD : Sets up directories and moves files for SuperSeggerOpti.
0003 % It sets up directory structure for cell segmentation
0004 % analysis and moves aligned images to their respective folders.
0005 %
0006 % INPUT :
0007 %       dirname : directory that contains images
0008 %       CONST : segmentation constants
0009 %
0010 % Copyright (C) 2016 Wiggins Lab
0011 % Written by Stella Stylianidou
0012 % University of Washington, 2016
0013 % This file is part of SuperSegger.
0014 %
0015 % SuperSegger is free software: you can redistribute it and/or modify
0016 % it under the terms of the GNU General Public License as published by
0017 % the Free Software Foundation, either version 3 of the License, or
0018 % (at your option) any later version.
0019 %
0020 % SuperSegger is distributed in the hope that it will be useful,
0021 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0022 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0023 % GNU General Public License for more details.
0024 %
0025 % You should have received a copy of the GNU General Public License
0026 % along with SuperSegger.  If not, see <http://www.gnu.org/licenses/>.
0027 file_filter = '*.tif';
0028 
0029 if(nargin<1 || isempty(dirname))    
0030     dirname = uigetdir();
0031 end
0032 
0033 dirname = fixDir(dirname);
0034 
0035 % Make and move subdirs
0036 contents=dir([dirname file_filter]);
0037 
0038 if ~isempty(contents);
0039     
0040     num_im = numel(contents);
0041        
0042     nc  = zeros(1, num_im); % channel
0043     nxy = zeros(1, num_im); % xy
0044         
0045     for i = 1:num_im;
0046         % creates an array with the the numbers after the strings t,c,xy,z
0047         % for the filename of each image
0048         nameInfo = ReadFileName(contents(i).name);    
0049         nc(i)  = nameInfo.npos(2,1);
0050         nxy(i) = nameInfo.npos(3,1);
0051     end
0052     
0053     nc  = sort(unique(nc));
0054     nxy = sort(unique(nxy));
0055 
0056     num_xy = numel(nxy);
0057     num_c  = numel(nc);
0058     
0059     dirname_list = cell(1,num_xy);
0060     
0061     if nxy(1)==-1
0062         nxy = 1;
0063     end
0064     
0065     if nxy == 0
0066         xyPadSize = 1;
0067     else
0068         xyPadSize = floor(log(max(nxy))/log(10))+1;
0069     end
0070     
0071     padString = ['%0',num2str(xyPadSize),'d'];
0072     
0073     for i = 1:num_xy 
0074         % creates the needed xy directories with phase, fluor, seg and cell
0075         % sub-directories
0076         dirname_list{i} = [dirname,'xy',num2str(nxy(i), padString),filesep];
0077         mkdir(dirname_list{i});
0078         mkdir([dirname_list{i},'phase',filesep]);
0079         mkdir([dirname_list{i},'seg',filesep]);
0080         mkdir([dirname_list{i},'cell',filesep]);
0081         for j = 2:num_c
0082             mkdir( [dirname_list{i},'fluor',num2str(j-1),filesep] );
0083         end
0084     end
0085     
0086     if CONST.parallel.show_status
0087         h = waitbar(0, 'Moving Files');
0088         cleanup = onCleanup( @()( delete( h ) ) );
0089     else
0090         h = [];
0091     end
0092     
0093     for i = 1:num_im; % goes through all the images
0094         if CONST.parallel.show_status
0095             waitbar(i/num_im,h);
0096         end
0097         
0098         nameInfo = ReadFileName( contents(i).name );
0099         
0100         ic  = nameInfo.npos(2,1); % channel
0101         ixy = nameInfo.npos(3,1); % xy position
0102                
0103         if ixy == -1
0104             ii = 1;
0105         else
0106             ii = find(ixy==nxy);
0107         end
0108         
0109         if ic == -1
0110             ic  = 1;
0111         end
0112         
0113         
0114         if ic == 1
0115             tmp_target =  [dirname_list{ii},'phase', filesep];
0116         else
0117             tmp_target =  [dirname_list{ii},'fluor',num2str(ic-1),filesep];
0118         end
0119         
0120         tmp_source = [dirname,contents(i).name];
0121         movefile( tmp_source, tmp_target ,'f');
0122                 
0123     end
0124     if CONST.parallel.show_status
0125         close(h);
0126     end
0127     
0128 end
0129 end

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