IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
SpiderReaderWriter.h
Go to the documentation of this file.
1 /**
2  * \file IMP/em/SpiderReaderWriter.h
3  * \brief Management of Spider Headers Electron Microscopy. Compatible with
4  * Spider and Xmipp formats
5  * Copyright 2007-2018 IMP Inventors. All rights reserved.
6 */
7 
8 #ifndef IMPEM_SPIDER_READER_WRITER_H
9 #define IMPEM_SPIDER_READER_WRITER_H
10 
11 #include "IMP/em/em_config.h"
12 #include "IMP/em/ImageHeader.h"
14 #include "IMP/em/MapReaderWriter.h"
15 #include "IMP/em/DensityHeader.h"
16 #include <IMP/algebra/utility.h>
17 #include <IMP/algebra/endian.h>
18 #include <IMP/exception.h>
19 #include <IMP/log.h>
20 #include <typeinfo>
21 #include <complex>
22 #include <string>
23 #include <cstdio>
24 #include <iostream>
25 #include <fstream>
26 #include <cstring>
27 
28 IMPEM_BEGIN_NAMESPACE
29 
30 //! Class to read EM maps (3D) in Spider and Xmipp formats
31 /**
32  * \note: Compatible only with Xmipp 2.2 and Spider floating point maps
33  * \note: A DensityHeader class must be provided
34  */
35 class IMPEMEXPORT SpiderMapReaderWriter : public MapReaderWriter {
36  public:
37  String filename_;
38  bool skip_type_check_;
39  bool force_reversed_;
40  bool skip_extra_checkings_;
41 
42  //! Empty constructor. It does not force reversed header and does not
43  //! skip any of the tests
45  skip_type_check_ = false;
46  force_reversed_ = false;
47  skip_extra_checkings_ = false;
48  }
49 
50  //! Full constructor.
51  /**
52  * \param[in] filename file to read
53  * \param[in] skip_type_check if true, the check for type of image is skipped
54  * \param[in] force_reversed if true, the reverse mode is enforced
55  * for reading and writing
56  * \param[in] skip_extra_checkings if true, the most stringent
57  * tests for consistency of images are skipped when reading
58  */
59  SpiderMapReaderWriter(String filename, bool skip_type_check,
60  bool force_reversed, bool skip_extra_checkings) {
61  filename_ = filename;
62  skip_type_check_ = skip_type_check;
63  force_reversed_ = force_reversed;
64  skip_extra_checkings_ = skip_extra_checkings;
65  }
66 #if !defined(DOXYGEN) && !defined(SWIG)
67  //! Reads a map in Spider format and transfers the data and header.
68  /**
69  * \param[in] filename file to read
70  * \param[in] data pointer to the structure where to store the data
71  * \param[in] header DensityHeader class where to store the info
72  * from the header.
73  */
74  void read(const char *filename, float **data, DensityHeader &header);
75 
76  //! Writes a map in Spider format from data and header.
77  /**
78  * \param[in] filename file to write
79  * \param[in] data pointer to the structure where data are stored
80  * \param[in] header DensityHeader class where the header info is stored
81  * data from the header.
82  */
83  void write(const char *filename, const float *data,
84  const DensityHeader &header);
85 #endif
87 };
88 
89 IMPEM_END_NAMESPACE
90 
91 #endif /* IMPEM_SPIDER_READER_WRITER_H */
The base class to handle reading and writing of density maps.
Functions to convert between ImageHeader and DensityHeader Copyright 2007-2018 IMP Inventors...
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Metadata for a density file.
Exception definitions and assertions.
Class to read EM maps (3D) in Spider and Xmipp formats.
Functions to deal with byte order.
Functions to deal with very common math operations.
An abstract class for reading a map.
Header for EM images. Compatible with Spider and Xmipp formats Copyright 2007-2018 IMP Inventors...
Logging and error reporting support.
std::string String
Basic string value.
Definition: types.h:44
SpiderMapReaderWriter(String filename, bool skip_type_check, bool force_reversed, bool skip_extra_checkings)
Full constructor.