IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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>
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
28IMPEM_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 */
35class 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,
75 DensityHeader &header) override;
76
77 //! Writes a map in Spider format from data and header.
78 /**
79 * \param[in] filename file to write
80 * \param[in] data pointer to the structure where data are stored
81 * \param[in] header DensityHeader class where the header info is stored
82 * data from the header.
83 */
84 void write(const char *filename, const float *data,
85 const DensityHeader &header) override;
86#endif
88};
89
90IMPEM_END_NAMESPACE
91
92#endif /* IMPEM_SPIDER_READER_WRITER_H */
Metadata for a density file.
Header for EM images. Compatible with Spider and Xmipp formats Copyright 2007-2022 IMP Inventors....
An abstract class for reading a map.
Functions to deal with very common math operations.
SpiderMapReaderWriter(String filename, bool skip_type_check, bool force_reversed, bool skip_extra_checkings)
Full constructor.
void read(const char *filename, float **data, DensityHeader &header) override
Reads a map in Spider format and transfers the data and header.
void write(const char *filename, const float *data, const DensityHeader &header) override
Writes a map in Spider format from data and header.
Functions to deal with byte order.
Exception definitions and assertions.
Functions to convert between ImageHeader and DensityHeader Copyright 2007-2022 IMP Inventors....
Logging and error reporting support.
std::string String
Basic string value.
Definition types.h:43
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.