#include <reconstructor.h>
Public Member Functions | |
file_store (const string &filename, int npad, int write, bool CTF) | |
virtual | ~file_store () |
void | add_image (EMData *data, const Transform &tf) |
void | get_image (int id, EMData *padfft) |
void | restart () |
Private Attributes | |
shared_ptr< std::ifstream > | m_ihandle |
shared_ptr< std::ofstream > | m_bin_ohandle |
shared_ptr< std::ofstream > | m_txt_ohandle |
string | m_bin_file |
string | m_txt_file |
int | m_ctf |
int | m_npad |
int | m_prev |
int | m_x_out |
int | m_y_out |
int | m_z_out |
int | m_write |
std::istream::off_type | m_totsize |
float | m_Cs |
float | m_pixel |
float | m_voltage |
float | m_ctf_applied |
float | m_amp_contrast |
vector< float > | m_defocuses |
vector< float > | m_phis |
vector< float > | m_thetas |
vector< float > | m_psis |
|
Definition at line 4324 of file reconstructor.cpp. References m_ctf, m_npad, m_prev, and m_write. 04325 : m_bin_file(filename + ".bin"), 04326 m_txt_file(filename + ".txt") 04327 { 04328 m_ctf = ctf; 04329 m_prev = -1; 04330 m_npad = npad; 04331 m_write = write; 04332 }
|
|
Definition at line 4334 of file reconstructor.cpp. 04335 { 04336 }
|
|
Definition at line 4338 of file reconstructor.cpp. References checked_delete(), data, EMAN::Dict::get(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), m_amp_contrast, m_bin_file, m_bin_ohandle, m_Cs, m_ctf_applied, m_defocuses, m_npad, m_phis, m_pixel, m_psis, m_thetas, m_totsize, m_txt_file, m_txt_ohandle, m_voltage, m_write, m_x_out, m_y_out, m_z_out, EMAN::padfft_slice(), phi, and EMAN::Ctf::to_dict(). 04339 { 04340 04341 EMData* padfft = padfft_slice( emdata, tf, m_npad ); 04342 04343 float* data = padfft->get_data(); 04344 04345 if( m_write && m_bin_ohandle == NULL ) 04346 { 04347 m_bin_ohandle = shared_ptr< ofstream >( new ofstream(m_bin_file.c_str(), std::ios::out | std::ios::binary) ); 04348 m_txt_ohandle = shared_ptr< ofstream >( new ofstream(m_txt_file.c_str() ) ); 04349 if( m_ctf ) 04350 *m_txt_ohandle << "Cs pixel voltage ctf_applied amp_contrast defocus "; 04351 04352 *m_txt_ohandle << "phi theta psi" << std::endl; 04353 } 04354 04355 m_x_out = padfft->get_xsize(); 04356 m_y_out = padfft->get_ysize(); 04357 m_z_out = padfft->get_zsize(); 04358 m_totsize = m_x_out*m_y_out*m_z_out; 04359 04360 if( m_ctf ) 04361 { 04362 Ctf* ctf = padfft->get_attr( "ctf" ); 04363 Dict ctf_params = ctf->to_dict(); 04364 04365 m_ctf_applied = padfft->get_attr( "ctf_applied" ); 04366 04367 m_Cs = ctf_params["cs"]; 04368 m_pixel = ctf_params["apix"]; 04369 m_voltage = ctf_params["voltage"]; 04370 m_amp_contrast = ctf_params["ampcont"]; 04371 m_defocuses.push_back( ctf_params["defocus"] ); 04372 if(ctf) {delete ctf; ctf=0;} 04373 } 04374 04375 Dict params = tf.get_rotation( "spider" ); 04376 float phi = params.get( "phi" ); 04377 float tht = params.get( "theta" ); 04378 float psi = params.get( "psi" ); 04379 04380 04381 m_phis.push_back( phi ); 04382 m_thetas.push_back( tht ); 04383 m_psis.push_back( psi ); 04384 04385 if( m_write ) 04386 { 04387 m_bin_ohandle->write( (char*)data, sizeof(float)*m_totsize ); 04388 04389 if( m_ctf ) 04390 { 04391 *m_txt_ohandle << m_Cs << " "; 04392 *m_txt_ohandle << m_pixel << " "; 04393 *m_txt_ohandle << m_voltage << " "; 04394 *m_txt_ohandle << m_ctf_applied << " "; 04395 *m_txt_ohandle << m_amp_contrast << " "; 04396 *m_txt_ohandle << m_defocuses.back() << " "; 04397 } 04398 *m_txt_ohandle << m_phis.back() << " "; 04399 *m_txt_ohandle << m_thetas.back() << " "; 04400 *m_txt_ohandle << m_psis.back() << " "; 04401 *m_txt_ohandle << m_x_out << " "; 04402 *m_txt_ohandle << m_y_out << " "; 04403 *m_txt_ohandle << m_z_out << " "; 04404 *m_txt_ohandle << m_totsize << std::endl; 04405 } 04406 04407 checked_delete(padfft); 04408 04409 }
|
|
Definition at line 4411 of file reconstructor.cpp. References Assert, data, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), m_amp_contrast, m_Cs, m_ctf_applied, m_defocuses, m_ihandle, m_phis, m_pixel, m_psis, m_thetas, m_totsize, m_txt_file, m_voltage, m_x_out, m_y_out, m_z_out, phi, EMAN::EMData::set_attr(), EMAN::EMData::set_size(), theta, and EMAN::EMData::update(). 04412 { 04413 04414 if( m_phis.size() == 0 ) { 04415 ifstream m_txt_ifs( m_txt_file.c_str() ); 04416 04417 if( !m_txt_ifs ) 04418 { 04419 std::cerr << "Error: file " << m_txt_file << " does not exist" << std::endl; 04420 } 04421 04422 string line; 04423 std::getline( m_txt_ifs, line ); 04424 04425 float first, defocus, phi, theta, psi; 04426 04427 04428 04429 while( m_txt_ifs >> first ) { 04430 04431 if( m_ctf ) 04432 { 04433 m_Cs = first; 04434 m_txt_ifs >> m_pixel >> m_voltage; 04435 m_txt_ifs >> m_ctf_applied >> m_amp_contrast; 04436 m_txt_ifs >> defocus >> phi >> theta >> psi; 04437 m_defocuses.push_back( defocus ); 04438 } 04439 else 04440 { 04441 phi = first; 04442 m_txt_ifs >> theta >> psi; 04443 } 04444 04445 m_txt_ifs >> m_x_out >> m_y_out >> m_z_out >> m_totsize; 04446 m_phis.push_back( phi ); 04447 m_thetas.push_back( theta ); 04448 m_psis.push_back( psi ); 04449 } 04450 } 04451 04452 Assert( m_ihandle != NULL ); 04453 04454 std::istream::off_type offset = id*sizeof(float)*m_totsize; 04455 Assert( offset >= 0 ); 04456 04457 if( offset > 0 ) 04458 { 04459 m_ihandle->seekg(offset, std::ios::beg); 04460 } 04461 04462 if( m_ihandle->bad() ) 04463 { 04464 std::cout << "bad while fetching id, offset: " << id << " " << offset << std::endl; 04465 throw std::logic_error( "bad happen" ); 04466 } 04467 04468 if( m_ihandle->fail() ) 04469 { 04470 std::cout << "fail while fetching id, offset, curoff: " << id << " " << offset << std::endl; 04471 throw std::logic_error( "fail happen" ); 04472 } 04473 04474 if( m_ihandle->eof() ) 04475 { 04476 std::cout << "eof while fetching id, offset: " << id << " " << offset << std::endl; 04477 throw std::logic_error( "eof happen" ); 04478 } 04479 04480 if( padfft->get_xsize() != m_x_out || 04481 padfft->get_ysize() != m_y_out || 04482 padfft->get_zsize() != m_z_out ) 04483 { 04484 padfft->set_size(m_x_out, m_y_out, m_z_out); 04485 } 04486 04487 char* data = (char*)(padfft->get_data()); 04488 m_ihandle->read( data, sizeof(float)*m_totsize ); 04489 padfft->update(); 04490 04491 if( m_ctf ) 04492 { 04493 padfft->set_attr( "Cs", m_Cs ); 04494 padfft->set_attr( "Pixel_size", m_pixel ); 04495 padfft->set_attr( "voltage", m_voltage ); 04496 padfft->set_attr( "ctf_applied", m_ctf_applied ); 04497 padfft->set_attr( "amp_contrast", m_amp_contrast ); 04498 padfft->set_attr( "defocus", m_defocuses[id] ); 04499 } 04500 04501 padfft->set_attr( "padffted", 1 ); 04502 padfft->set_attr( "phi", m_phis[id] ); 04503 padfft->set_attr( "theta", m_thetas[id] ); 04504 padfft->set_attr( "psi", m_psis[id] ); 04505 04506 }
|
|
Definition at line 4508 of file reconstructor.cpp. References m_bin_file, and m_ihandle. 04509 { 04510 if( m_ihandle == NULL ) 04511 { 04512 m_ihandle = shared_ptr< ifstream >( new ifstream(m_bin_file.c_str(), std::ios::in | std::ios::binary) ); 04513 } 04514 04515 if( m_ihandle->bad() || m_ihandle->fail() || m_ihandle->eof() ) 04516 { 04517 m_ihandle->open( m_bin_file.c_str(), std::ios::binary ); 04518 } 04519 04520 m_ihandle->seekg( 0, std::ios::beg ); 04521 }
|
|
Definition at line 1565 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1551 of file reconstructor.h. Referenced by add_image(), and restart(). |
|
Definition at line 1549 of file reconstructor.h. Referenced by add_image(). |
|
Definition at line 1561 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1553 of file reconstructor.h. Referenced by file_store(). |
|
Definition at line 1564 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1566 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1548 of file reconstructor.h. Referenced by get_image(), and restart(). |
|
Definition at line 1554 of file reconstructor.h. Referenced by add_image(), and file_store(). |
|
Definition at line 1567 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1562 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1555 of file reconstructor.h. Referenced by file_store(). |
|
Definition at line 1569 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1568 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1560 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1552 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1550 of file reconstructor.h. Referenced by add_image(). |
|
Definition at line 1563 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1559 of file reconstructor.h. Referenced by add_image(), and file_store(). |
|
Definition at line 1556 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1557 of file reconstructor.h. Referenced by add_image(), and get_image(). |
|
Definition at line 1558 of file reconstructor.h. Referenced by add_image(), and get_image(). |