File: AchievaDtiHandler.cpp

package info (click to toggle)
mriconvert 1%3A2.1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,488 kB
  • sloc: cpp: 17,029; makefile: 11
file content (112 lines) | stat: -rw-r----- 2,507 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/// AchievaDtiHandler.cpp
/**
*/

#include <wx/filename.h>
#include <wx/stdpaths.h>

#include <algorithm>
#include <set>
#include <math.h>

#include "Dictionary.h"
#include "DicomFile.h"
#include "StringConvert.h"
#include "Volume.h"
#include "SeriesHandler.h"
#include "AchievaDtiHandler.h"

using namespace jcs;

///
/**
*/
AchievaDtiHandler::AchievaDtiHandler(const std::string& seriesUid)
: SeriesHandler(seriesUid)
{
}


///
/**
*/
SeriesHandler::VolListType
AchievaDtiHandler::ReadVolIds(DicomFile& file)
{ 
  VolListType v = SeriesHandler::ReadVolIds(file);
  Dictionary* Achieva = PhilipsMr_Dictionary::Instance();

  std::vector<double> g_value;
  std::string b_direction;

  double value;
  file.Find(Achieva->Lookup("Diffusion_B-Factor"), value);
  g_value.push_back(value);

  file.Find(Achieva->Lookup("Diffusion_Direction_RL"), value);
  g_value.push_back(value);

  file.Find(Achieva->Lookup("Diffusion_Direction_AP"), value);
  g_value.push_back(value);

  file.Find(Achieva->Lookup("Diffusion_Direction_FH"), value);
  g_value.push_back(value);

  int g_number;
  std::vector<std::vector <double> >::iterator pos;
  pos = find(gradients.begin(), gradients.end(), g_value);
  if (pos != gradients.end()) {
    g_number = distance(gradients.begin(), pos);
  }
  else {
    g_number = gradients.size();
    gradients.push_back(g_value);
  }

  v.front().ids.push_back(itos(g_number, 3));

  return v;
}


///
/**
*/
GradientInfo
AchievaDtiHandler::GetGradientInfo()
{
  GradientInfo info;

  Dictionary* Achieva = PhilipsMr_Dictionary::Instance();

  std::map<VolId, std::string> volFileMap = GetVolIdsAndFiles();
  std::map<VolId, std::string>::iterator it = volFileMap.begin();
  std::map<VolId, std::string>::iterator it_end = volFileMap.end();

  for (;it != it_end; it++) {

    //std::vector<std::string> test = it->first.ids;
    //for (int t = 0; t < test.size(); ++t)
    //  wxLogMessage(test[t].c_str());

    DicomFile file(it->second.c_str());

    double value;
    file.Find(Achieva->Lookup("Diffusion_B-Factor"), value);
    info.values.push_back(value);

    file.Find(Achieva->Lookup("Diffusion_Direction_RL"), value);
    info.xGrads.push_back(value);

    file.Find(Achieva->Lookup("Diffusion_Direction_AP"), value);
    info.yGrads.push_back(value);

    file.Find(Achieva->Lookup("Diffusion_Direction_FH"), value);
    info.zGrads.push_back(value);
  }

  std::vector<double> r = GetRotationMatrix(volFileMap.begin()->first);

  RotateGradInfo(info, r);
  return info;
}