Home > SuperSegger > cell > trackOptiGateCellFiles.m

trackOptiGateCellFiles

PURPOSE ^

trackOptiGateCellFiles : moves cells not passing the gate to separate directory

SYNOPSIS ^

function trackOptiGateCellFiles(dirname_cell, clist )

DESCRIPTION ^

 trackOptiGateCellFiles : moves cells not passing the gate to separate directory
 the cells that pass the gate remain in the dirname_cell directory.
 For the clist passed, create a gate for the cells that you would like to move
 the outsideTheGate directory.

 INPUT :
       dirname_cell : directory with cell files
       clist : array with non time dependent information of cells

 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/>.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function trackOptiGateCellFiles(dirname_cell, clist )
0002 % trackOptiGateCellFiles : moves cells not passing the gate to separate directory
0003 % the cells that pass the gate remain in the dirname_cell directory.
0004 % For the clist passed, create a gate for the cells that you would like to move
0005 % the outsideTheGate directory.
0006 %
0007 % INPUT :
0008 %       dirname_cell : directory with cell files
0009 %       clist : array with non time dependent information of cells
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 
0030 if ~exist( 'clist', 'var') || isempty( clist) || isempty(clist.data)
0031     ID_LIST = [];
0032 else
0033     clist = gate(clist);
0034     ID_LIST = clist.data(:,1);
0035 end
0036 
0037 outsideTheGatedir = [dirname_cell,'outsideTheGate',filesep];
0038 
0039 if ~exist( outsideTheGatedir, 'dir' ) % create outsideTheGate directory
0040     mkdir(outsideTheGatedir(1:end-1));
0041 end
0042 
0043 contents = dir( [dirname_cell,'*ell*.mat'] );
0044 
0045 % all cell files are moved to the outsideTheGate directory
0046 if ~isempty( contents )
0047     movefile( [dirname_cell,'*ell*.mat'], outsideTheGatedir )
0048 end
0049 
0050 if isempty( contents ) % check gated directory - maybe it was gated already in the past
0051     contents = dir( [outsideTheGatedir,'*ell*.mat'] );
0052 end
0053 
0054 
0055 % move cell files in the ID_LIST from the outsideTheGate directory back to the original directory
0056 if ~isempty( contents )
0057     numPad = sum( ismember(contents(1).name,'0123456789')); % how many numbers in cell id's name
0058     nCells = numel( ID_LIST );
0059     for ii = 1:nCells % go through every cell
0060         numStr = num2str(  ID_LIST(ii), ['%0',num2str(numPad),'d'] );     
0061         nameC = [outsideTheGatedir,'Cell',numStr,'.mat'];
0062         namec = [outsideTheGatedir,'cell',numStr,'.mat'];
0063         if exist( nameC, 'file' )
0064             movefile( nameC, dirname_cell );
0065         elseif exist( namec, 'file' )
0066             movefile( namec, dirname_cell );
0067         end
0068 
0069     end
0070 end
0071 end

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