Developer documentation
Version 3.0.3-105-gd3941f44
list.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __formats_list_h__
18#define __formats_list_h__
19
20#include "header.h"
21
22#define DECLARE_IMAGEFORMAT(format, desc) \
23 class format : public Base { NOMEMALIGN \
24 public: \
25 format () : Base (desc) { } \
26 virtual std::unique_ptr<ImageIO::Base> read (Header& H) const; \
27 virtual bool check (Header& H, size_t num_axes) const; \
28 virtual std::unique_ptr<ImageIO::Base> create (Header& H) const; \
29 }
30
31namespace MR
32{
33
35 namespace Formats
36 {
37
39
43 public:
44 Base (const char* desc) : description (desc) { }
45 virtual ~Base() { }
46
47 const char* description;
48
62 virtual std::unique_ptr<ImageIO::Base> read (Header& H) const = 0;
63
76 virtual bool check (Header& H, size_t num_axes) const = 0;
77
85 virtual std::unique_ptr<ImageIO::Base> create (Header& H) const = 0;
86 };
87
88#ifdef MRTRIX_AS_R_LIBRARY
89 DECLARE_IMAGEFORMAT (RAM, "RAM buffer");
90#endif
91
92 DECLARE_IMAGEFORMAT (Pipe, "Internal pipe");
95 DECLARE_IMAGEFORMAT (MRtrix_GZ, "MRtrix (GZip compressed)");
98 DECLARE_IMAGEFORMAT (NIfTI1_GZ, "NIfTI-1.1 (GZip compressed)");
99 DECLARE_IMAGEFORMAT (NIfTI2_GZ, "NIfTI-2 (GZip compressed)");
100 DECLARE_IMAGEFORMAT (MRI, "MRTools (legacy format)");
103 DECLARE_IMAGEFORMAT (MGZ, "MGZ (compressed MGH)");
104 DECLARE_IMAGEFORMAT (PAR, "Philips PAR/REG");
105#ifdef MRTRIX_TIFF_SUPPORT
106 DECLARE_IMAGEFORMAT (TIFF, "TIFF");
107#endif
108#ifdef MRTRIX_PNG_SUPPORT
109 DECLARE_IMAGEFORMAT (PNG, "PNG");
110#endif
111 DECLARE_IMAGEFORMAT (MRtrix_sparse, "MRtrix WIP sparse image data format");
112
114 extern const char* known_extensions[];
115
117 extern const Base* handlers[];
118
119
120
122 extern MRtrix mrtrix_handler;
124
125 }
126}
127
128
129
130#endif
the interface for classes that support the various image formats.
Definition: list.h:42
virtual ~Base()
Definition: list.h:45
virtual bool check(Header &H, size_t num_axes) const =0
check whether the Image::Header H can be created using this handler.
const char * description
a short human-readable description of the image format
Definition: list.h:47
virtual std::unique_ptr< ImageIO::Base > read(Header &H) const =0
read image file(s) and fill the Image::Header H with the appropriate information.
virtual std::unique_ptr< ImageIO::Base > create(Header &H) const =0
create the image corresponding to the Image::Header H.
Base(const char *desc)
Definition: list.h:44
#define DECLARE_IMAGEFORMAT(format, desc)
Definition: list.h:22
#define NOMEMALIGN
Definition: memory.h:22
const Base * handlers[]
const char * known_extensions[]
Definition: base.h:24
Eigen::MatrixXd H