File: GeDtiRbHandler.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 (106 lines) | stat: -rw-r----- 2,426 bytes parent folder | download | duplicates (4)
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
/// GetDtiRbHandler.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 "GeDtiRbHandler.h"

using namespace jcs;

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


///
/**
*/ 
SeriesHandler::VolListType
GeDtiRbHandler::ReadVolIds(DicomFile& file)
{ 
  VolListType v = SeriesHandler::ReadVolIds(file);
  // Can't call default ReadVolId because of problem with trigger time.

  std::string acquisition_number;
  if (!file.Find("AcquisitionNumber", acquisition_number)) {
    wxLogError(_("Acquisition number not found"));
  }
  v.front().ids.push_back(acquisition_number);

  int image_number, number_of_slices;
  if (!file.Find("InstanceNumber", image_number)) {
    wxLogError(_("Instance number not found"));
  }

  Dictionary* Excite = Excite_Dictionary::Instance();
  if (!file.Find(Excite->Lookup("Locations_in_acquisition"), number_of_slices)) {
    wxLogError(_("Locations_in_acquisition not found"));
  }

  int vol_no = static_cast<int>(floor(static_cast<double>((image_number - 1))/number_of_slices) + 1);

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

  return v;

}


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

  int gradfileno;
  Dictionary* Excite = Excite_Dictionary::Instance();

  double bvalue;
  Find(Excite->Lookup("User_data_9"), bvalue);

  if (Find(Excite->Lookup("User_data_11"), gradfileno)) {
    wxString gradfilename = wxString::Format(_T("dwepi.%d.grads"), gradfileno);
    
    wxFileName gradfile(wxStandardPaths::Get().GetDataDir());
    gradfile.SetFullName(gradfilename);

    std::ifstream input((const char *) gradfile.GetFullPath());

    double value;
    input >> value;
    while (input.good()) {
      info.xGrads.push_back(value);
      input >> value;
      info.yGrads.push_back(value);
      input >> value;
      info.zGrads.push_back(value);
      info.values.push_back(bvalue);
      input >> value;
    }

    // GE -- do not correct
    // assuming one orientation in series
    //std::vector<double> r = orientations.at(0);
    //RotateGradInfo(info, r);

  }

  return info;
}