File: odinswi.cpp

package info (click to toggle)
odin 2.0.5-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,196 kB
  • sloc: cpp: 62,638; sh: 4,541; makefile: 779
file content (245 lines) | stat: -rw-r--r-- 7,595 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#include <odinseq/seqall.h>





class METHOD_CLASS : public SeqMethod {

 private:
  SeqPulsar exc;
  SeqPulsarReph exc_reph;
  SeqPulsarReph exc_reph_neg;


  SeqAcqRead acqread;
  SeqAcqRead negacqread; // need separate object since calling SeqAcqDeph on the same object with different polarity does not work
  SeqAcqDeph readdeph;
  SeqAcqDeph negreaddeph;

  SeqGradPhaseEncFlowComp pe;
  SeqGradPhaseEncFlowComp pe3d;

  SeqGradConstPulse crusher;

  SeqDelay exc2acq;
  SeqDelay relaxdelay;

  SeqObjList gradpart;
  SeqObjList scan;
  SeqObjList readout;

  SeqObjLoop peloop;
  SeqObjLoop peloop3d;
  SeqObjLoop reploop;

  SeqVecIter phaseiter;


  LDRfloat T1Ernst;


 public:
  METHOD_CLASS(const STD_string& label) : SeqMethod(label) {
    set_description("Fully flow-compensated FLASH sequence for Susceptibility Weighted Imaging. ");
  }

  void method_pars_init() {

    geometryInfo->set_Mode(voxel_3d);

    commonPars->set_MatrixSize(readDirection,256);
    commonPars->set_MatrixSize(phaseDirection,256,noedit);
    commonPars->set_RepetitionTime(50.0);
    commonPars->set_EchoTime(28.0);

    T1Ernst=1300.0;
    T1Ernst.set_minmaxval(0.0,5000.0).set_description("For optimum SNR, the flip angle will be set to the Ernst angle using this T1");
    append_parameter(T1Ernst,"T1Ernst");

//    fmapscan.init("fmapscan");
//    append_parameter(fmapscan.get_parblock(),"FieldMapPars");
  }


  void method_seq_init(){
    Log<Seq> odinlog(this,"method_seq_init");

    ///////////////// Pulses: /////////////////////

    // Excitation Pulse
    float spatres=3.0;
    float slicethick=geometryInfo->get_FOV(sliceDirection)-2.0*spatres;
    if(slicethick<spatres) slicethick=spatres;
    exc=SeqPulsarSinc("exc", slicethick, false, 4.0, commonPars->get_FlipAngle(), spatres, 512);
    exc.set_filter("Gauss");
    exc.set_freqoffset(systemInfo->get_gamma() * exc.get_strength() / (2.0*PII) *  geometryInfo->get_offset(sliceDirection) );
    exc.set_pulse_type(excitation);

//    ODINLOG(odinlog,significantDebug) << "exc.rel_magnetic_center/get_pulsduration" << exc.get_rel_magnetic_center() << "/" << exc.get_pulsduration() << STD_endl;
//    ODINLOG(odinlog,significantDebug) << "exc.get_Gz()" << exc.get_Gz() << STD_endl;

    // rephasing lobe for excitation pulse
    exc_reph=SeqPulsarReph("exc_reph",exc);

    exc_reph_neg=SeqPulsarReph("exc_reph",exc);
    exc_reph_neg.invert_strength();

    ////////////////// Geometry: /////////////////////////////////

    // calculate the resolution in the read Channel and set the number of phase encoding
    // steps so that we will obtain a uniform resolution in read and phase Channel:
    float resolution=secureDivision(geometryInfo->get_FOV(readDirection),commonPars->get_MatrixSize(readDirection));

    commonPars->set_MatrixSize(phaseDirection,int(secureDivision(geometryInfo->get_FOV(phaseDirection),resolution)+0.5),noedit);
    commonPars->set_MatrixSize(sliceDirection,int(secureDivision(geometryInfo->get_FOV(sliceDirection),resolution)+0.5),noedit);


    //////////////// Phase Encoding: //////////////////////////

    float t0=exc.get_duration()-exc.get_magnetic_center()+
                 exc_reph.get_duration()+
                 exc_reph.get_duration()+
                 exc_reph_neg.get_duration();

    pe=SeqGradPhaseEncFlowComp("pe", t0, commonPars->get_MatrixSize(phaseDirection), geometryInfo->get_FOV(phaseDirection),
                  phaseDirection, 0.25*systemInfo->get_max_grad(),
                  linearEncoding, noReorder, 1,
                  commonPars->get_ReductionFactor(), DEFAULT_ACL_BANDS, commonPars->get_PartialFourier());


    //////////////// Phase Encoding (3D): //////////////////////////

    pe3d=SeqGradPhaseEncFlowComp("pe3d", t0, commonPars->get_MatrixSize(sliceDirection),geometryInfo->get_FOV(sliceDirection),
                  sliceDirection, pe.get_strength(),
                  linearEncoding, noReorder, 1,
                  commonPars->get_ReductionFactor());


    //////////////// Readout: //////////////////////////////

    acqread=SeqAcqRead("acqread",commonPars->get_AcqSweepWidth(),commonPars->get_MatrixSize(readDirection),
                                 geometryInfo->get_FOV(readDirection),readDirection);

    negacqread=acqread;

    readdeph=SeqAcqDeph("readdeph", acqread);
    negreaddeph=SeqAcqDeph("negreaddeph", negacqread, spinEcho);

    //////////////// RF Spoiling: //////////////////////////////

    if(commonPars->get_RFSpoiling()) {

      exc.set_phasespoiling();
      acqread.set_phasespoiling();

      phaseiter=SeqVecIter("phaseiter");
      phaseiter.add_vector(exc.get_phaselist_vector());
      phaseiter.add_vector(acqread.get_phaselist_vector());
    }

    //////////////// Crusher: //////////////////////////////

    double crusher_strength=0.5*systemInfo->get_max_grad();
    double crusher_integral=4.0*fabs(readdeph.get_gradintegral().sum());
    double crusher_dur=secureDivision(crusher_integral, crusher_strength);
    crusher=SeqGradConstPulse("crusher",readDirection,crusher_strength,crusher_dur);


    //////////////// Field-map template: //////////////////////////////

//    fmapscan.build_seq(100.0, SeqObjList(), commonPars->get_RepetitionTime());


    //////////////// several padding delays ////////////////////

    exc2acq=SeqDelay("exc2acq");

    relaxdelay=SeqDelay("relaxdelay");


    //////////////// total sequence: //////////////////////////////

    gradpart=SeqObjList("gradpart");

    scan=SeqObjList("scan");

    readout=SeqObjList("readout");


    peloop=SeqObjLoop("peloop");

    peloop3d=SeqObjLoop("peloop3d");

    reploop=SeqObjLoop("reploop");

    gradpart = (negreaddeph+readdeph)/pe/pe3d;

    readout = exc + exc_reph + exc_reph + exc_reph_neg + gradpart + exc2acq + readdeph + acqread + crusher;

    if(commonPars->get_RFSpoiling()) readout += phaseiter;

//    scan += fmapscan + relaxdelay;

    scan+=  reploop(
              peloop3d(
                peloop(
                  readout + relaxdelay
                )[pe]
              )[pe3d]
            )[commonPars->get_NumOfRepetitions()];


    set_sequence( scan );
  }


  void method_rels(){

    // TE
    double minTE=exc.get_duration()-exc.get_magnetic_center()+
                 exc_reph.get_duration()+
                 exc_reph.get_duration()+
                 exc_reph_neg.get_duration()+
                 gradpart.get_duration()+
                 readdeph.get_duration()+
                 acqread.get_acquisition_center();

    if(commonPars->get_EchoTime()<minTE) commonPars->set_EchoTime(minTE);
    exc2acq=commonPars->get_EchoTime()-minTE;


    // TR
    // calculate relaxdelay to get the desired repetition time
    float readoutdur=readout.get_duration();
    if(readoutdur > commonPars->get_RepetitionTime()) commonPars->set_RepetitionTime(readoutdur);
    relaxdelay.set_duration( commonPars->get_RepetitionTime()-readoutdur );

    // calculate Ernst angle accordng to TR
    float flipangle=180.0/PII * acos( exp ( -secureDivision ( commonPars->get_RepetitionTime(), T1Ernst) ) );
    commonPars->set_FlipAngle( flipangle, noedit );
    exc.set_flipangle( flipangle );

  }


  void method_pars_set(){

    // inform the readout about the used phase encoding and slice vector (for automatic reconstruction)
    acqread.set_reco_vector(line,pe);
    acqread.set_reco_vector(line3d,pe3d);

    recoInfo->set_PreProc3D("swi");
    recoInfo->set_PostProc3D("mip");
//    recoInfo->set_CmdLineOpts("-ff CosSq -fp 0.5");
  }

};




// entry point for the sequence module
ODINMETHOD_ENTRY_POINT