Developer documentation
Version 3.0.3-105-gd3941f44
generated_track.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_tractography_tracking_generated_track_h__
18#define __dwi_tractography_tracking_generated_track_h__
19
20
21#include "types.h"
22
24
25
26namespace MR
27{
28 namespace DWI
29 {
30 namespace Tractography
31 {
32 namespace Tracking
33 {
34
35
36
37 class GeneratedTrack : public vector<Eigen::Vector3f>
39
40
41 public:
42
43 using BaseType = vector<Eigen::Vector3f>;
44
45 enum class status_t { INVALID, SEED_REJECTED, TRACK_REJECTED, ACCEPTED };
46
47 GeneratedTrack() : seed_index (0), status (status_t::INVALID) { }
48 void clear() { BaseType::clear(); seed_index = 0; status = status_t::INVALID; }
49 size_t get_seed_index() const { return seed_index; }
50 status_t get_status() const { return status; }
51 void reverse() { std::reverse (begin(), end()); seed_index = (size()-1) - seed_index; }
52 void set_seed_index (const size_t i) { seed_index = i; }
53 void set_status (const status_t i) { status = i; }
54
55 float length (const float step_size) const
56 {
57 // Only in the context of a track being generated is it safe to
58 // exploit knowledge of the step size in order to calculate
59 // streamline length more efficiently; however we must consider
60 // the possibility of truncation of the final segment at either
61 // endpoint of the streamline
62 // If this is not a safe assumption, Tractography::length() should
63 // instead be used
64 switch (size()) {
65 case 0: return NaN;
66 case 1: return ((*this)[1] - (*this)[0]).norm();
67 default:
68 return ((step_size * (size() - 2)) +
69 ((*this)[1]-(*this)[0]).norm() +
70 ((*this)[size()-1] - (*this)[size()-2]).norm());
71 }
72 }
73
74 friend inline std::ostream& operator<< (std::ostream& stream, GeneratedTrack& tck)
75 {
76 stream << str(tck.size()) << " vertices, seed index " << str(tck.seed_index) << ", status ";
77 switch (tck.status) {
78 case status_t::INVALID: stream << "INVALID"; break;
79 case status_t::SEED_REJECTED: stream << "SEED_REJECTED"; break;
80 case status_t::TRACK_REJECTED: stream << "TRACK_REJECTED"; break;
81 case status_t::ACCEPTED: stream << "ACCEPTED"; break;
82 }
83 return stream;
84 }
85
86 private:
87 size_t seed_index;
88 status_t status;
89
90 };
91
92
93 }
94 }
95 }
96}
97
98#endif
99
friend std::ostream & operator<<(std::ostream &stream, GeneratedTrack &tck)
Definition: base.h:24
std::string str(const T &value, int precision=0)
Definition: mrtrix.h:247
constexpr default_type NaN
Definition: types.h:230
#define MEMALIGN(...)
Definition: types.h:185