PostEddyAlignShellsFunctions.h 6.76 KB
Newer Older
wangkx1's avatar
init  
wangkx1 committed
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151

#ifndef PostEddyAlignShellsFunctions_h
#define PostEddyAlignShellsFunctions_h

#include "EddyHelperClasses.h"
#include "ECScanClasses.h"
#include "DiffusionGP.h"
#include "b0Predictor.h"
#include "EddyUtils.h"
#include "EddyCommandLineOptions.h"

namespace EDDY {

/****************************************************************//**
*
* \brief This class does Post Eddy Alignment of Shells (PEAS)
*
* 
*
********************************************************************/ 

class PEASUtils
{
public:
  /// Attempts to align the shells after eddy has done all within shell alignments
  static void PostEddyAlignShells(// Input
				  const EddyCommandLineOptions&   clo,
				  bool                            upe, // Update parameter estimates or not
				  // Input/Output
				  ECScanManager&                  sm);
  /// Aligns shells through PE-direction translation _only_
  static void PostEddyAlignShellsAlongPE(// Input
					 const EddyCommandLineOptions&   clo,
					 bool                            upe, // Update parameter estimates or not
					 // Input/Output
					 ECScanManager&                  sm);
  /// Generate text file with MI values for different movement parameters. For debugging purposes only.
  static void WritePostEddyBetweenShellMIValues(// Input
						const EddyCommandLineOptions&     clo,
						const ECScanManager&              sm,
						const std::vector<unsigned int>&  n,
						const std::vector<double>&        first,
						const std::vector<double>&        last,
						const std::string&                bfname);
private:
  static NEWIMAGE::volume<float> get_mean_scan(// Input
					       const EddyCommandLineOptions&     clo,      
					       const ECScanManager&              sm,
					       const std::vector<unsigned int>&  indx,
					       // Output
					       NEWIMAGE::volume<float>&          mask);

  static void get_mean_scan_wrapper(unsigned int                      first_index,
				    unsigned int                      last_index,
				    const ECScanManager&              sm,
				    const std::vector<unsigned int>&  indx,
				    bool                              very_verbose,
				    // Output
				    NEWIMAGE::volume<float>&          mean,
				    NEWIMAGE::volume<float>&          mask);

  static NEWMAT::ColumnVector register_volumes(// Input
					       const NEWIMAGE::volume<float>& ref,
					       const NEWIMAGE::volume<float>& ima,
					       const NEWIMAGE::volume<float>& mask,
					       // Output
					       NEWIMAGE::volume<float>&       rima);

  static NEWMAT::ColumnVector register_volumes_along_PE(// Input
							const NEWIMAGE::volume<float>& ref,
							const NEWIMAGE::volume<float>& ima,
							const NEWIMAGE::volume<float>& mask,
							unsigned int                   pe_dir,
							// Output
							NEWIMAGE::volume<float>&       rima);

  static void register_volumes_wrapper(// Input
				       unsigned int                                     first_reg,
				       unsigned int                                     last_reg,
				       const std::vector<std::pair<int,unsigned int> >& regs,
				       bool                                             pe_only,
				       unsigned int                                     pe_dir,
				       const NEWIMAGE::volume<float>&                   b0,
				       const std::vector<NEWIMAGE::volume<float> >&     dwis,
				       const NEWIMAGE::volume<float>&                   mask,
				       const std::vector<double>&                       grpb,
				       bool                                             vv,
				       // Output
				       std::vector<NEWMAT::ColumnVector>&               mov_par,
				       std::vector<std::vector<NEWMAT::ColumnVector> >& cmov_par);

  static std::string format_mp(const NEWMAT::ColumnVector& mp);

  static std::vector<NEWMAT::ColumnVector> collate_mov_par_estimates_for_use(const std::vector<NEWMAT::ColumnVector>&                mp,
									     const std::vector<std::vector<NEWMAT::ColumnVector> >&  cmp,
									     const NEWIMAGE::volume<float>&                          ima);

  static void write_post_eddy_align_shells_report(const std::vector<NEWMAT::ColumnVector>&                mi_dmp,
						  const std::vector<NEWMAT::ColumnVector>&                mi_ump,
						  const std::vector<std::vector<NEWMAT::ColumnVector> >&  mi_cmp,
						  const std::vector<NEWMAT::ColumnVector>&                b0_dmp,
						  const std::vector<NEWMAT::ColumnVector>&                b0_ump,
						  const std::vector<double>&                              grpb,
						  bool                                                    upe,
						  const EddyCommandLineOptions&                           clo);

  static void write_post_eddy_align_shells_along_PE_report(const std::vector<NEWMAT::ColumnVector>&                mi_dmp,
							   const std::vector<NEWMAT::ColumnVector>&                mi_ump,
							   const std::vector<std::vector<NEWMAT::ColumnVector> >&  mi_cmp,
							   const std::vector<double>&                              grpb,
							   bool                                                    upe,
							   const EddyCommandLineOptions&                           clo);

  static void update_mov_par_estimates(// Input
				       const NEWMAT::ColumnVector&       mp,
				       const std::vector<unsigned int>&  indx,
				       // Input/output
				       ECScanManager&                    sm);

  static void align_shells_using_MI(// Input
				    const EddyCommandLineOptions&                      clo,
				    bool                                               pe_only,
				    // Input/Output
				    ECScanManager&                                     sm,
				    // Output
				    std::vector<double>&                               grpb,
				    std::vector<NEWMAT::ColumnVector>&                 mov_par,
				    std::vector<std::vector<NEWMAT::ColumnVector> >&   cmov_par,
				    std::vector<NEWMAT::ColumnVector>&                 mp_for_updates);

  static void write_between_shell_MI_values(const NEWIMAGE::volume<float>&    b0_mean,
					    const NEWIMAGE::volume<float>&    dwi_means,
					    const NEWIMAGE::volume<float>&    mask,
					    const std::string&                fname,
					    const std::vector<unsigned int>&  n,
					    const std::vector<double>&        first,
					    const std::vector<double>&        last);

  static void align_shells_using_interspersed_B0_scans(// Input
						       const EddyCommandLineOptions&                      clo,
						       // Input/Output
						       ECScanManager&                                     sm,
						       // Output
						       std::vector<double>&                               grpb,
						       std::vector<NEWMAT::ColumnVector>&                 mov_par,
						       std::vector<NEWMAT::ColumnVector>&                 mp_for_updates);
}; // End of class PEASUtils

} // End namespace EDDY

#endif // end #ifndef PostEddyAlignShellsFunctions_h