Developer documentation
Version 3.0.3-105-gd3941f44
file.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 __dwi_directions_load_h__
18#define __dwi_directions_load_h__
19
20#include "math/sphere.h"
21
22namespace MR {
23 namespace DWI {
24 namespace Directions {
25
26 Eigen::MatrixXd load_spherical (const std::string& filename);
27 Eigen::MatrixXd load_cartesian (const std::string& filename);
28
29 template <class MatrixType>
30 inline void save_cartesian (const MatrixType& directions, const std::string& filename)
31 {
32 if (directions.cols() == 2)
33 save_matrix (Math::Sphere::spherical2cartesian (directions), filename);
34 else
35 save_matrix (directions, filename);
36 }
37
38 template <class MatrixType>
39 inline void save_spherical (const MatrixType& directions, const std::string& filename)
40 {
41 if (directions.cols() == 3)
42 save_matrix (Math::Sphere::cartesian2spherical (directions), filename);
43 else
44 save_matrix (directions, filename);
45 }
46
47 template <class MatrixType>
48 inline void save (const MatrixType& directions, const std::string& filename, bool cartesian)
49 {
50 if (cartesian)
51 save_cartesian (directions, filename);
52 else
53 save_spherical (directions, filename);
54 }
55
56
57 }
58 }
59}
60
61#endif
62
void save_cartesian(const MatrixType &directions, const std::string &filename)
Definition: file.h:30
Eigen::MatrixXd load_spherical(const std::string &filename)
Eigen::MatrixXd load_cartesian(const std::string &filename)
void save(const MatrixType &directions, const std::string &filename, bool cartesian)
Definition: file.h:48
void save_spherical(const MatrixType &directions, const std::string &filename)
Definition: file.h:39
std::enable_if< VectorType1::IsVectorAtCompileTime, void >::type spherical2cartesian(const VectorType1 &az_el_r, VectorType2 &&xyz)
convert spherical coordinates to Cartesian coordinates
Definition: sphere.h:40
std::enable_if< VectorType1::IsVectorAtCompileTime, void >::type cartesian2spherical(const VectorType1 &xyz, VectorType2 &&az_el_r)
convert Cartesian coordinates to spherical coordinates
Definition: sphere.h:83
Definition: base.h:24
void save_matrix(const MatrixType &M, const std::string &filename, const KeyValues &keyvals=KeyValues(), const bool add_to_command_history=true)
write the matrix M to file
Definition: math.h:136