0001 function make_intermediate_results_from_temp_folder( param )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
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
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
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
0118
0119
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
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
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
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
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
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
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