17#ifndef __dwi_tractography_act_tissues_h__
18#define __dwi_tractography_act_tissues_h__
23#define TISSUE_SUM_THRESHOLD 0.5
31 namespace Tractography
40 Tissues () : cgm (0.0), sgm (0.0), wm (0.0), csf (0.0), path (0.0), is_valid (
false) { }
42 Tissues (
const float cg,
const float sg,
const float w,
const float c,
const float p) :
49 set (cg, sg, w, c, p);
52 template <
class ImageType>
61 set<ImageType> (data);
71 is_valid (that.is_valid) { }
79 is_valid (that.is_valid) { }
81 bool set (
const float cg,
const float sg,
const float w,
const float c,
const float p) {
82 if (std::isnan (cg) || std::isnan (sg) || std::isnan (w) || std::isnan (c) || std::isnan (p)) {
83 cgm = sgm = wm = csf = path = 0.0;
84 return ((is_valid =
false));
86 cgm = (cg < 0.0) ? 0.0 : ((cg > 1.0) ? 1.0 : cg);
87 sgm = (sg < 0.0) ? 0.0 : ((sg > 1.0) ? 1.0 : sg);
88 wm = (w < 0.0) ? 0.0 : ((w > 1.0) ? 1.0 : w );
89 csf = (c < 0.0) ? 0.0 : ((c > 1.0) ? 1.0 : c );
90 path = (p < 0.0) ? 0.0 : ((p > 1.0) ? 1.0 : p );
94 template <
class ImageType>
95 bool set (ImageType& data)
97 data.index(3) = 0;
const float cg = data.value();
98 data.index(3) = 1;
const float sg = data.value();
99 data.index(3) = 2;
const float w = data.value();
100 data.index(3) = 3;
const float c = data.value();
101 data.index(3) = 4;
const float p = data.value();
102 return set (cg, sg, w, c, p);
106 cgm = sgm = wm = csf = path = 0.0;
110 bool valid()
const {
return is_valid; }
112 float get_cgm()
const {
return cgm; }
113 float get_sgm()
const {
return sgm; }
114 float get_wm ()
const {
return wm; }
115 float get_csf()
const {
return csf; }
116 float get_path()
const {
return path; }
118 float get_gm ()
const {
return (cgm + sgm); }
120 bool is_cgm()
const {
return ((cgm >= sgm) && (cgm >= wm ) && (cgm > csf) && (cgm > path)); }
121 bool is_sgm()
const {
return ((sgm > cgm) && (sgm >= wm ) && (sgm > csf) && (sgm > path)); }
122 bool is_wm ()
const {
return ((wm > cgm) && (wm > sgm) && (wm > csf) && (wm > path)); }
123 bool is_csf()
const {
return ((csf >= cgm) && (csf >= sgm) && (csf >= wm ) && (csf >= path)); }
124 bool is_path()
const {
return ((path >= cgm) && (path >= sgm) && (path >= wm ) && (path > csf )); }
126 bool is_gm()
const {
return ((get_gm() >= wm) && (get_gm() > csf) && (get_gm() > path)); }
129 float cgm, sgm, wm, csf, path;
137 stream <<
"[ " << t.get_cgm() <<
" " << t.get_sgm() <<
" " << t.get_wm() <<
" " << t.get_csf() <<
" " << t.get_path() <<
" ]";
std::ostream & operator<<(std::ostream &stream, const Tissues &t)
#define TISSUE_SUM_THRESHOLD