Example #1
0
IMPEM_BEGIN_INTERNAL_NAMESPACE

void MRCHeader::FromDensityHeader(const DensityHeader &h)
{
  std::string empty;

  nz=h.get_nz();   ny=h.get_ny();  nx=h.get_nx(); // map size
  // mode
  if(h.get_data_type()==0) // data type not initialized
    mode = 2;
     if(h.get_data_type()==1)
    mode=0; // 8-bits
     else if(h.get_data_type()==2)
    mode=1;// 16-bits
     else if(h.get_data_type()==5)
    mode=2;// 32-bits

  // number of first columns in map (default = 0)
  nxstart=h.nxstart ; nystart=h.nystart ; nzstart=h.nzstart;

  mx=h.mx ; my=h.my ; mz=h.mz; // Number of intervals along each dimension
  xlen=h.xlen ; ylen=h.ylen ; zlen=h.zlen; // Cell dimensions (angstroms)
  alpha=h.alpha ; beta=h.beta ; gamma=h.gamma; // Cell angles (degrees)
  /* Axes corresponding to columns (mapc), rows (mapr) and sections (maps)
     (1,2,3 for x,y,z) */
  mapc=h.mapc;
  mapr=h.mapr;
  maps=h.maps;
  /* Minimum, maximum and mean density value */
  dmin=h.dmin;
  dmax=h.dmax;
  dmean=h.dmean;
  ispg=h.ispg; // Sapce group number 0 or 1 (default 0)
  nsymbt=h.nsymbt; // Number of bytes used for symmetry data (0 or 80)
  // extra space used for anything - 0 by default
  for(int i=0;i<IMP_MRC_USER;i++)
    user[i]=h.user[i];
  strcpy(map,"MAP\0"); // character string 'MAP ' to identify file type
  // Origin used for transforms
  xorigin=h.get_xorigin() ; yorigin=h.get_yorigin() ; zorigin=h.get_zorigin();
  // machine stamp (0x11110000 bigendian, 0x44440000 little)
  machinestamp=h.machinestamp;
  rms=h.rms; // RMS deviation of map from mean density
  nlabl=h.nlabl; // Number of labels being used
  // Copy comments
  for(int i=0;i<nlabl;i++)
    strcpy(labels[i],h.comments[i]);
  // Fill empty coments with null character
  const char *c="\0";
  empty.resize(IMP_MRC_LABEL_SIZE,*c);
  for(int i=nlabl;i<IMP_MRC_NUM_LABELS;i++)
    strcpy(labels[i],empty.c_str());
}
//! Function to transfer the (compatible) information content from DensityHeader
//! to ImageHeader
void  DensityHeader_to_ImageHeader(const DensityHeader& dh,ImageHeader& h) {
  // map size
  h.set_number_of_slices(dh.get_nz());
  h.set_number_of_rows(dh.get_ny());
  h.set_number_of_columns(dh.get_nx());
  // mode
  switch (dh.get_data_type()) {
  case 1:
    h.set_image_type(ImageHeader::VOL_BYTE);
    break;
  case 2:
    h.set_image_type(ImageHeader::VOL_INT);
    break;
  case 5:
    h.set_image_type(ImageHeader::VOL_IMPEM);
    break;
  }
  // Reversed image?
  if(algebra::get_is_big_endian()) {
    h.set_reversed(dh.lswap!=1);
  } else {
    h.set_reversed(dh.lswap==1);
  }
  // Origins and pixel size
  h.set_origin(algebra::Vector3D(dh.get_xorigin(),
                                 dh.get_yorigin(),
                                 dh.get_zorigin()) );
  h.set_object_pixel_size(dh.get_spacing());
  // Statistical values. There is no field in DensityHeader to guarantee that
  // they are computed or correct, so they are ignored
  h.set_fImami(0.);
  h.set_fFmax(0.);
  h.set_fFmin(0.);
  h.set_fAv(0.);
  h.set_fSig(0.);
  // These fields don't have an equivalent in DensityHeader
  h.set_Scale(1.);
  h.set_fAngle1(0.);
  h.set_Weight(1.);
  h.set_Flip(0.);
  h.set_fNrec(0.);
  h.set_fNlabel(0.);
  h.set_fIhist(0.);
  h.set_fLabrec(0.);
  h.set_fIangle(0.);
  h.set_fLabbyt(0.);
  h.set_fLenbyt(0.);
  h.set_fFlag(0.); // Ignore all the Euler angles for the Spider Image
  // Set time and date
  h.set_date();
  h.set_time();
}