#include "mpi.h"
#include "emdata.h"
#include "alignoptions.h"
Include dependency graph for utilparse.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
int | ParseAlignOptions (MPI_Comm comm, AlignOptions &options, char *optionsfname, int nvoxels, EMData *&mask3D) |
|
Definition at line 8 of file utilparse.cpp. References AlignOptions::get_CTF(), EMAN::EMData::get_data(), AlignOptions::get_dtheta(), AlignOptions::get_first_ring(), AlignOptions::get_last_ring(), AlignOptions::get_maxit(), AlignOptions::get_ref_angle_type(), AlignOptions::get_ri(), AlignOptions::get_rstep(), AlignOptions::get_sirt_lam(), AlignOptions::get_sirt_maxit(), AlignOptions::get_sirt_tol(), AlignOptions::get_snr(), AlignOptions::get_step(), AlignOptions::get_symmetry(), AlignOptions::get_use_sirt(), AlignOptions::get_xrng(), AlignOptions::get_yrng(), ierr, EMAN::EMData::read_image(), AlignOptions::set_CTF(), AlignOptions::set_dtheta(), AlignOptions::set_first_ring(), AlignOptions::set_last_ring(), AlignOptions::set_mask3D(), AlignOptions::set_maxit(), AlignOptions::set_ref_angle_type(), AlignOptions::set_ri(), AlignOptions::set_rstep(), AlignOptions::set_sirt_lam(), AlignOptions::set_sirt_maxit(), AlignOptions::set_sirt_tol(), AlignOptions::set_snr(), AlignOptions::set_step(), AlignOptions::set_symmetry(), AlignOptions::set_use_sirt(), AlignOptions::set_xrng(), and AlignOptions::set_yrng(). Referenced by main(). 00010 { 00011 int ncpus, mypid, ierr; 00012 00013 MPI_Comm_size(comm,&ncpus); 00014 MPI_Comm_rank(comm,&mypid); 00015 00016 std::ifstream option_stream; 00017 std::string current_option; 00018 char option_buffer[100]; 00019 int int_option, parserr = 0; 00020 float float_option; 00021 00022 float * mask_data; 00023 if ( mypid == 0 ) { // read data from the options file 00024 option_stream.open(optionsfname); 00025 while ( option_stream >> current_option ) { 00026 if ( current_option == "maskfile" ) { 00027 option_stream >> current_option; 00028 mask3D = new EMData(); 00029 mask3D->read_image(current_option); 00030 options.set_mask3D(mask3D); 00031 } 00032 else if ( current_option == "inner_ring" ) { 00033 option_stream >> int_option; 00034 options.set_first_ring(int_option); 00035 std::cout << "first_ring = " << int_option << std::endl; 00036 } 00037 else if ( current_option == "outer_ring" ) { 00038 option_stream >> int_option; 00039 options.set_last_ring(int_option); 00040 std::cout << "last_ring = " << int_option << std::endl; 00041 } 00042 else if ( current_option == "rstep" ) { 00043 option_stream >> int_option; 00044 options.set_rstep(int_option); 00045 std::cout << "rstep = " << int_option << std::endl; 00046 } 00047 else if ( current_option == "radius" ) { // perhaps this is the same as outer_ring? 00048 option_stream >> int_option; 00049 options.set_ri(int_option); 00050 std::cout << "radius = " << int_option << std::endl; 00051 } 00052 else if ( current_option == "x_range" ) { 00053 option_stream >> float_option; 00054 options.set_xrng(float_option); 00055 std::cout << "x_range = " << float_option << std::endl; 00056 } 00057 else if ( current_option == "y_range" ) { 00058 option_stream >> float_option; 00059 options.set_yrng(float_option); 00060 std::cout << "y_range = " << float_option << std::endl; 00061 } 00062 else if ( current_option == "translation_step" ) { 00063 option_stream >> float_option; 00064 options.set_step(float_option); 00065 std::cout << "step = " << float_option << std::endl; 00066 } 00067 else if ( current_option == "theta_step" ) { 00068 option_stream >> float_option; 00069 options.set_dtheta(float_option); 00070 std::cout << "theta_step = " << float_option << std::endl; 00071 } 00072 else if ( current_option == "CTF" ) { 00073 option_stream >> current_option; 00074 if ( current_option == "true" ) { 00075 options.set_CTF(true); 00076 std::cout << "CTF = true" << std::endl; 00077 } 00078 else { // anything else sets it to false 00079 options.set_CTF(false); 00080 std::cout << "CTF = false" << std::endl; 00081 } 00082 } 00083 else if ( current_option == "snr" ) { 00084 option_stream >> float_option; 00085 options.set_snr(float_option); 00086 std::cout << "snr = " << float_option << std::endl; 00087 } 00088 else if ( current_option == "ref_a" ) { 00089 option_stream >> current_option; 00090 if ( current_option == "P" ) { 00091 options.set_ref_angle_type("P"); 00092 } 00093 else if ( current_option == "S" ){ // should add support for this 00094 std::cerr << "Currently only support Penczek-type reference angles..." << std::endl; 00095 options.set_ref_angle_type("P"); 00096 } 00097 else { // Currently default to "P", will eventually default to "S" 00098 } 00099 } 00100 else if ( current_option == "symmetry" ) { 00101 option_stream >> current_option; 00102 options.set_symmetry(current_option); 00103 std::cout << "symmetry = " << current_option << std::endl; 00104 } 00105 else if ( current_option == "use_sirt" ) { 00106 option_stream >> current_option; 00107 if ( current_option == "true" ) { 00108 options.set_use_sirt(true); 00109 std::cout << "use_sirt = true" << std::endl; 00110 } 00111 else { // anything else sets it to false 00112 options.set_use_sirt(false); 00113 std::cout << "use_sirt = false" << std::endl; 00114 } 00115 } 00116 else if ( current_option == "sirt_tol" ) { 00117 option_stream >> float_option; 00118 options.set_sirt_tol(float_option); 00119 std::cout << "sirt_tol = " << float_option << std::endl; 00120 } 00121 else if ( current_option == "sirt_lam" ) { 00122 option_stream >> float_option; 00123 options.set_sirt_lam(float_option); 00124 std::cout << "sirt_lam = " << float_option << std::endl; 00125 } 00126 else if ( current_option == "sirt_maxit" ) { 00127 option_stream >> int_option; 00128 options.set_sirt_maxit(int_option); 00129 std::cout << "sirt_maxit = " << int_option << std::endl; 00130 } 00131 else if ( current_option == "maxit" ) { 00132 option_stream >> int_option; 00133 options.set_maxit(int_option); 00134 std::cout << "maxit = " << int_option << std::endl; 00135 } 00136 else { // catch-all 00137 std::cerr << "Unsupported option " << current_option << "..." << std::endl; 00138 parserr = 1; 00139 } 00140 } 00141 option_stream.close(); 00142 if (parserr) { 00143 printf("The supported options are:\n"); 00144 printf(" maskfile \n"); 00145 printf(" inner_ring\n"); 00146 printf(" outer_ring\n"); 00147 printf(" rstep\n"); 00148 printf(" radius\n"); 00149 printf(" x_range\n"); 00150 printf(" y_range\n"); 00151 printf(" translation_step\n"); 00152 printf(" CTF\n"); 00153 printf(" snr\n"); 00154 printf(" ref_a\n"); 00155 printf(" S\n"); 00156 printf(" symmetry\n"); 00157 printf(" sirt_tol\n"); 00158 printf(" sirt_lam\n"); 00159 printf(" sirt_maxit\n"); 00160 printf(" maxit\n"); 00161 } 00162 } 00163 // Then broadcast all the data that was read 00164 ierr = MPI_Bcast(&mask3D, 1, MPI_INT, 0, comm); 00165 // if it's not NULL, need to allocate and bcast its data 00166 // NOTE: this is sending over the master's address for mask3D ONLY as a test to see if it's NULL or not. 00167 // DO NOT USE THIS POINTER ON ANY OTHER NODES EXCEPT FOR THIS TEST! 00168 if ( mask3D != NULL ) { 00169 if ( mypid != 0 ) { 00170 mask3D = new EMData(); 00171 } 00172 mask_data = mask3D->get_data(); 00173 ierr = MPI_Bcast(mask_data, nvoxels, MPI_FLOAT, 0, comm); 00174 options.set_mask3D(mask3D); 00175 } 00176 00177 int_option = options.get_first_ring(); 00178 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00179 options.set_first_ring(int_option); 00180 00181 int_option = options.get_last_ring(); 00182 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00183 options.set_last_ring(int_option); 00184 00185 int_option = options.get_rstep(); 00186 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00187 options.set_rstep(int_option); 00188 00189 int_option = options.get_ri(); 00190 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00191 options.set_ri(int_option); 00192 00193 float_option = options.get_xrng(); 00194 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00195 options.set_xrng(float_option); 00196 00197 float_option = options.get_yrng(); 00198 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00199 options.set_yrng(float_option); 00200 00201 float_option = options.get_step(); 00202 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00203 options.set_step(float_option); 00204 00205 float_option = options.get_dtheta(); 00206 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00207 options.set_dtheta(float_option); 00208 00209 int_option = options.get_CTF(); 00210 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00211 options.set_CTF(int_option); 00212 00213 float_option = options.get_snr(); 00214 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00215 options.set_snr(float_option); 00216 00217 current_option = options.get_ref_angle_type(); 00218 strcpy(option_buffer, current_option.c_str()); 00219 ierr = MPI_Bcast(option_buffer, current_option.size(), MPI_CHAR, 0, comm); 00220 options.set_ref_angle_type(option_buffer); 00221 00222 current_option = options.get_symmetry(); 00223 strcpy(option_buffer, current_option.c_str()); 00224 ierr = MPI_Bcast(option_buffer, current_option.size(), MPI_CHAR, 0, comm); 00225 options.set_symmetry(option_buffer); 00226 00227 int_option = options.get_use_sirt(); 00228 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00229 options.set_use_sirt(int_option); 00230 00231 float_option = options.get_sirt_tol(); 00232 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00233 options.set_sirt_tol(float_option); 00234 00235 float_option = options.get_sirt_lam(); 00236 ierr = MPI_Bcast(&float_option, 1, MPI_FLOAT, 0, comm); 00237 options.set_sirt_lam(float_option); 00238 00239 int_option = options.get_sirt_maxit(); 00240 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00241 options.set_sirt_maxit(int_option); 00242 00243 int_option = options.get_maxit(); 00244 ierr = MPI_Bcast(&int_option, 1, MPI_INT, 0, comm); 00245 options.set_maxit(int_option); 00246 00247 return 0; // ParseAlignOptions 00248 }
|