-
Notifications
You must be signed in to change notification settings - Fork 30
/
SpiderReaderWriter.h
92 lines (83 loc) · 2.85 KB
/
SpiderReaderWriter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* \file IMP/em/SpiderReaderWriter.h
* \brief Management of Spider Headers Electron Microscopy. Compatible with
* Spider and Xmipp formats
* Copyright 2007-2022 IMP Inventors. All rights reserved.
*/
#ifndef IMPEM_SPIDER_READER_WRITER_H
#define IMPEM_SPIDER_READER_WRITER_H
#include <IMP/em/em_config.h>
#include <IMP/em/ImageHeader.h>
#include <IMP/em/header_converters.h>
#include <IMP/em/MapReaderWriter.h>
#include <IMP/em/DensityHeader.h>
#include <IMP/algebra/utility.h>
#include <IMP/algebra/endian.h>
#include <IMP/exception.h>
#include <IMP/log.h>
#include <typeinfo>
#include <complex>
#include <string>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <cstring>
IMPEM_BEGIN_NAMESPACE
//! Class to read EM maps (3D) in Spider and Xmipp formats
/**
* \note: Compatible only with Xmipp 2.2 and Spider floating point maps
* \note: A DensityHeader class must be provided
*/
class IMPEMEXPORT SpiderMapReaderWriter : public MapReaderWriter {
public:
String filename_;
bool skip_type_check_;
bool force_reversed_;
bool skip_extra_checkings_;
//! Empty constructor. It does not force reversed header and does not
//! skip any of the tests
SpiderMapReaderWriter() {
skip_type_check_ = false;
force_reversed_ = false;
skip_extra_checkings_ = false;
}
//! Full constructor.
/**
* \param[in] filename file to read
* \param[in] skip_type_check if true, the check for type of image is skipped
* \param[in] force_reversed if true, the reverse mode is enforced
* for reading and writing
* \param[in] skip_extra_checkings if true, the most stringent
* tests for consistency of images are skipped when reading
*/
SpiderMapReaderWriter(String filename, bool skip_type_check,
bool force_reversed, bool skip_extra_checkings) {
filename_ = filename;
skip_type_check_ = skip_type_check;
force_reversed_ = force_reversed;
skip_extra_checkings_ = skip_extra_checkings;
}
#if !defined(DOXYGEN) && !defined(SWIG)
//! Reads a map in Spider format and transfers the data and header.
/**
* \param[in] filename file to read
* \param[in] data pointer to the structure where to store the data
* \param[in] header DensityHeader class where to store the info
* from the header.
*/
void read(const char *filename, float **data,
DensityHeader &header) override;
//! Writes a map in Spider format from data and header.
/**
* \param[in] filename file to write
* \param[in] data pointer to the structure where data are stored
* \param[in] header DensityHeader class where the header info is stored
* data from the header.
*/
void write(const char *filename, const float *data,
const DensityHeader &header) override;
#endif
IMP_OBJECT_METHODS(SpiderMapReaderWriter);
};
IMPEM_END_NAMESPACE
#endif /* IMPEM_SPIDER_READER_WRITER_H */