Home > cellorganizer > utilities > make_intermediate_results_from_temp_folder.m

make_intermediate_results_from_temp_folder

PURPOSE ^

MAKE_INTERMEDIATE_RESULTS_FROM_TEMP_FOLDER Helper method that takes files

SYNOPSIS ^

function make_intermediate_results_from_temp_folder( param )

DESCRIPTION ^

MAKE_INTERMEDIATE_RESULTS_FROM_TEMP_FOLDER Helper method that takes files
from the temp folder to make the intermediate results

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function make_intermediate_results_from_temp_folder( param )
0002 %MAKE_INTERMEDIATE_RESULTS_FROM_TEMP_FOLDER Helper method that takes files
0003 %from the temp folder to make the intermediate results
0004 
0005 % Copyright (C) 2007-2013  Murphy Lab
0006 % Carnegie Mellon University
0007 %
0008 % This program is free software; you can redistribute it and/or modify
0009 % it under the terms of the GNU General Public License as published
0010 % by the Free Software Foundation; either version 2 of the License,
0011 % or (at your option) any later version.
0012 %
0013 % This program is distributed in the hope that it will be useful, but
0014 % WITHOUT ANY WARRANTY; without even the implied warranty of
0015 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016 % General Public License for more details.
0017 %
0018 % You should have received a copy of the GNU General Public License
0019 % along with this program; if not, write to the Free Software
0020 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0021 % 02110-1301, USA.
0022 %
0023 % For additional information visit http://murphylab.web.cmu.edu or
0024 % send email to murphy@cmu.edu
0025 
0026 
0027 %temp files directories
0028 temp_files_directory = [ pwd filesep 'temp' ];
0029 
0030 if param.dimensionality == '2D'
0031     preprocessed_files_directory = [ temp_files_directory filesep ...
0032         'preprocessed' ];
0033     cellcodes_directory = [ temp_files_directory filesep ...
0034         'cellcodes' ];
0035     protein_model_temp_files_directory = [ temp_files_directory filesep ...
0036         'protein' ];
0037 else
0038     preprocessed_files_directory = [ temp_files_directory filesep ...
0039         'preprocessing' ];
0040     cellcodes_directory = [ temp_files_directory filesep ...
0041         'cell_shape_eigen' ];
0042     protein_model_temp_files_directory = [ temp_files_directory filesep ...
0043         'protein_objects_gaussian' ];
0044 end
0045 
0046 intermediate_results_folder = [ pwd filesep 'intermediate_results' ];
0047 if ~exist( intermediate_results_folder )
0048     mkdir( intermediate_results_folder )
0049 end
0050 
0051 %get the number of files
0052 files = dir( [  preprocessed_files_directory filesep '*.mat' ] );
0053 
0054 for index=1:1:length( files )
0055     if param.verbose && param.debug
0056         disp( ['Building intermediate results for image: ' num2str( index )] );
0057         tic
0058     end
0059     
0060     file = files(index).name;
0061     
0062     try
0063         temporary_filename = [ preprocessed_files_directory filesep file ];
0064         cell.preprocessed = load( temporary_filename );
0065     catch
0066         warning( ['Unable to load: ' temporary_file ] );
0067     end
0068     clear temporary_filename
0069     
0070     if strcmpi( param.train.flag, 'all' ) || strcmpi( param.train.flag, 'framework' )
0071         if strcmpi( param.nucleus.type, 'diffeomorphic' )
0072             diffeomorphic_temp_files = [ temp_files_directory ...
0073                 filesep 'diffeomorphic' ];
0074             
0075             if ~exist( [ intermediate_results_folder filesep ...
0076                     'diffeomorphic' ] )
0077                 mkdir( [ intermediate_results_folder filesep ...
0078                     'diffeomorphic' ] );
0079             end
0080             
0081             copyfile( diffeomorphic_temp_files, [ intermediate_results_folder ...
0082                 filesep 'diffeomorphic' ] );
0083             rmdir( [ intermediate_results_folder filesep ...
0084                 'diffeomorphic' filesep 'distances' ], 's' );
0085         else
0086             
0087             if strcmpi( param.dimensionality, '2d' )
0088                 temporary_file = [ cellcodes_directory filesep ...
0089                     'cell_' num2str(index) '.mat' ];
0090             else
0091                 temporary_file = [ cellcodes_directory filesep ...
0092                     'cellcodes_' num2str(index) '.mat' ];
0093             end
0094             
0095             try
0096                 cell = load( temporary_file );
0097             catch
0098                 warning( ['Unable to load: ' temporary_file ] );
0099             end
0100             clear temporary_file
0101             
0102             %nuclear features
0103             if strcmpi( param.dimensionality, '3d' )
0104                 temporary_file  = [ pwd filesep 'temp' filesep ...
0105                     'nuclearfeats' filesep 'nuclearfeats' num2str(index) '.mat' ];
0106                 
0107                 try
0108                     cell.nucleus.features = load( temporary_file );
0109                 catch
0110                     warning( ['Unable to load: ' temporary_file ] );
0111                 end
0112                 clear temporary_file
0113             end
0114         end
0115         
0116         if strcmpi( param.train.flag, 'all' )
0117             %icaoberg
0118             %the file structure of the temporary files from the vesicle model
0119             %is different between dimensionalities
0120             if strcmpi( param.dimensionality, '2D' )
0121                 search_string = [ protein_model_temp_files_directory ...
0122                     filesep 'mixture_' num2str(index) '*.mat' ];
0123                 mixtures_temp_files = dir( search_string );
0124                 
0125                 if ~isempty( mixtures_temp_files )
0126                     mixtures = {};
0127                     
0128                     for index2 = 1:1:length( mixtures_temp_files )
0129                         mixture_file = [ protein_model_temp_files_directory filesep ...
0130                             mixtures_temp_files(index2).name ];
0131                         
0132                         try
0133                             mixtures{index2} = load( mixture_file );
0134                         catch
0135                             warning( ['Unable to load: ' mixture_file ] );
0136                         end
0137                         clear mixture_file
0138                     end
0139                 end
0140                 
0141                 cell.protein.mixtures = mixtures;
0142             end
0143         else
0144             %object gaussians
0145             temporary_file  = [ protein_model_temp_files_directory ...
0146                 filesep 'object_gaussians' filesep 'gaussobjs_' ...
0147                 num2str(index) '.mat' ];
0148             
0149             try
0150                 cell.protein.gaussian_objects = load( temporary_file );
0151             catch
0152                 warning( ['Unable to load: ' temporary_file ] );
0153             end
0154             clear temporary_file
0155             
0156             %object positions
0157             temporary_file  = [ protein_model_temp_files_directory ...
0158                 filesep 'object_positions' filesep num2str(index) ...
0159                 '_Beta.mat' ];
0160             
0161             try
0162                 cell.protein.object_positions = load( temporary_file );
0163             catch
0164                 warning( ['Unable to load: ' temporary_file ] );
0165             end
0166             clear temporary_file
0167             
0168             %object sizes
0169             temporary_file  = [ protein_model_temp_files_directory ...
0170                 filesep 'object_sizes' filesep 'sizefits_' ...
0171                 num2str(index) '.mat' ];
0172             
0173             try
0174                 cell.protein.object_sizes = load( temporary_file );
0175             catch
0176                 warning( ['Unable to load: ' temporary_file ] );
0177             end
0178             clear temporary_file
0179             
0180             %object statistics
0181             temporary_file  = [ protein_model_temp_files_directory ...
0182                 filesep 'object_stats' filesep 'gaussobjs_' ...
0183                 num2str(index) '.mat' ];
0184             
0185             try
0186                 cell.protein.object_stats = load( temporary_file );
0187             catch
0188                 warning( ['Unable to load: ' temporary_file ] );
0189             end
0190             clear temporary_file
0191             
0192             %original objects
0193             temporary_file  = [ protein_model_temp_files_directory ...
0194                 filesep 'original_objects' filesep 'obj' ...
0195                 num2str(index) '.mat' ];
0196             
0197             try
0198                 cell.protein.original_objects = load( temporary_file );
0199             catch
0200                 warning( ['Unable to load: ' temporary_file ] );
0201             end
0202             clear temporary_file
0203             
0204             %compartment stats
0205             temporary_file  = [ pwd filesep 'temp' filesep ...
0206                 'compartment_stats' filesep ...
0207                 'comparts' num2str(index) '.mat' ];
0208             
0209             try
0210                 cell.compartments.stats = load( temporary_file );
0211             catch
0212                 warning( ['Unable to load: ' temporary_file ] );
0213             end
0214             clear temporary_file
0215         end
0216         
0217         output_file = [ intermediate_results_folder filesep ...
0218             'cell_' num2str(index) '.mat' ];
0219         save( output_file, 'cell' )
0220         clear cell
0221     end
0222     
0223     
0224     if param.verbose && param.debug
0225         toc
0226     end
0227 end

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