Home > cellorganizer > syn2projection.m

syn2projection

PURPOSE ^

SYN2PROJECTION Makes projections from a set of images synthesized by

SYNOPSIS ^

function answer = syn2projection( imgfolder, outputfolder, param )

DESCRIPTION ^

SYN2PROJECTION Makes projections from a set of images synthesized by 
CellOrganizer

 Inputs       Description
 ------       -----------
 imgfolder    a folder of synthesized images by CellOrganizer
 outputfolder the path where you wish to save the generated files

 Parameter structure description
 Parameter   Description
 ---------   -----------
 method      (optional) either a sum or mean. default is sum
 verbose     (optional) verbose flag that displays progress
 debug       (optional) flag that displays debugging messages. default is false
 
 Outputs
 -------
 answer      true if it saves all projections to disk

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function answer = syn2projection( imgfolder, outputfolder, param )
0002 %SYN2PROJECTION Makes projections from a set of images synthesized by
0003 %CellOrganizer
0004 %
0005 % Inputs       Description
0006 % ------       -----------
0007 % imgfolder    a folder of synthesized images by CellOrganizer
0008 % outputfolder the path where you wish to save the generated files
0009 %
0010 % Parameter structure description
0011 % Parameter   Description
0012 % ---------   -----------
0013 % method      (optional) either a sum or mean. default is sum
0014 % verbose     (optional) verbose flag that displays progress
0015 % debug       (optional) flag that displays debugging messages. default is false
0016 %
0017 % Outputs
0018 % -------
0019 % answer      true if it saves all projections to disk
0020 
0021 % Author: Ivan E. Cao-Berg
0022 %
0023 % Copyright (C) 2012 Murphy Lab
0024 % Lane Center for Computational Biology
0025 % School of Computer Science
0026 % Carnegie Mellon University
0027 %
0028 % This program is free software; you can redistribute it and/or modify
0029 % it under the terms of the GNU General Public License as published
0030 % by the Free Software Foundation; either version 2 of the License,
0031 % or (at your option) any later version.
0032 %
0033 % This program is distributed in the hope that it will be useful, but
0034 % WITHOUT ANY WARRANTY; without even the implied warranty of
0035 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0036 % General Public License for more details.
0037 %
0038 % You should have received a copy of the GNU General Public License
0039 % along with this program; if not, write to the Free Software
0040 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0041 % 02110-1301, USA.
0042 %
0043 % For additional information visit http://murphylab.web.cmu.edu or
0044 % send email to murphy@cmu.edu
0045 
0046 %icaoberg june 19, 2012
0047 %step 0: check input arguments
0048 answer = false;
0049 
0050 if nargin > 3
0051     error('Wrong number of input arguments');
0052 end
0053 
0054 if nargin == 2
0055    param = struct([])
0056 end
0057 
0058 try
0059    verbose = param.verbose;
0060    if ~islogical( verbose )
0061      verbose = false;
0062    end
0063 catch
0064    verbose = false;
0065 end
0066 
0067 try
0068    debug = param.debug;
0069    if ~islogical( debug )
0070       debug = false;
0071    end
0072 catch
0073    debug = false;
0074 end
0075 
0076 try
0077    method = param.method;
0078 catch
0079    method = 'sum';
0080 end
0081 
0082 try
0083    compression = param.compression;
0084    if ~strcmpi( compression, 'none' ) && ...
0085     ~stcmpi( compression, 'lzw' );
0086       compression = 'none';
0087    end
0088 catch
0089    compression = 'none';
0090 end
0091 
0092 if isempty( imgfolder )
0093     if debug
0094        warning('Input argument imgfolder cannot be empty')
0095     end
0096     return
0097 end
0098 
0099 if ~exist( imgfolder )
0100     if debug
0101        warning('Input argument imgfolder does not exist');
0102     end
0103     return
0104 end
0105 
0106 if isempty( outputfolder )
0107     if debug
0108         warning('Input argument savefile cannot be empty');
0109     end
0110     return
0111 end
0112 
0113 if ~exist( outputfolder )
0114     if debug
0115         warning('Input argument outputfolder does not exist')
0116     end
0117     return
0118 end
0119 
0120 %step 1: find all the generated tiff file in imgfolder
0121 files = ml_dir( [ imgfolder filesep '*.tif' ] );
0122 
0123 %step 2: make object files
0124 for index=1:1:length(files)
0125    file = files{index};
0126    img = tif2img( file );
0127    savefile = [ outputfolder filesep file ];
0128    if verbose
0129      disp( [ 'Making projection of ' file ] );
0130    end
0131    try
0132        projection = im2projection( img, param );
0133        img2tif( projection, savefile, compression );
0134    catch
0135        disp(['Unable to make ' savefile ]);
0136    end
0137 end
0138 
0139 answer = true;

Generated on Sun 29-Sep-2013 18:44:06 by m2html © 2005