This file is indexed.

/usr/share/odin/sequences/odinquant.cpp is in odin 1.8.4-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
#include <odinseq/seqall.h>


#define T2_CPMG_ECHO_FACTOR 2.5
#define T1_IR_FACTOR 1.2

class METHOD_CLASS : public SeqMethod {

 public:
  METHOD_CLASS(const STD_string& label);

  void method_pars_init();
  void method_seq_init();
  void method_rels();
  void method_pars_set();
  unsigned int numof_testcases() const {return 4;}

 private:

  JDXenum   Mode;
  JDXdouble ExpectedT1;
  JDXdouble ExpectedT2;
  JDXdouble MinEchoTime;
  JDXdouble MaxEchoTime;
  JDXint    NumOfEchoes;
  JDXint    NumOfDummyEchoes;
  JDXdoubleArr EchoTimes;
  JDXdouble B1PulseDur;

  SeqPulsar exc;
  SeqPulsar refoc;
  SeqPulsar inv;
  SeqAcqRead acqread;
  SeqDelay acqdummy;
  SeqAcqDeph readdeph;
  SeqObjLoop echoloop;
  SeqObjLoop dummyecholoop;
  SeqObjLoop peloop;
  SeqGradConstPulse spoiler1;
  SeqGradVectorPulse spoiler2;

  // objects for fieldmap scan
  SeqAcqEPI epi;
  SeqAcqDeph epideph;

  SeqVector echovec; // index vector for echoes

  SeqDelay excdelay;
  SeqDelay echodelay1;
  SeqDelay echodelay2;
  SeqDelay invdelay;
  SeqGradPhaseEnc pe1;
  SeqGradPhaseEnc pe2;
  SeqObjList echopart;
  SeqObjList grechpart;
  SeqObjList dummyechopart;
  SeqObjList kernel;
  SeqObjList slicepart;
  SeqDelay relaxdelay;
  SeqDelay dummype;
  SeqObjLoop sliceloop;
  SeqObjLoop acculoop;
  SeqObjLoop fliploop;

  SeqObjList postexc;
  SeqObjList postrefoc;
  SeqObjList postrefoctmpl;
  SeqObjList postinv;
  SeqObjList baselinepart;


  SeqGradEcho grech;

  fvector b1flips;

};

//////////////////////////////////////////////////////////////////////////////////////////

METHOD_CLASS::METHOD_CLASS (const STD_string& label)
                                   : SeqMethod(label) {
  set_description("A method to measure proton density, T1, T2, and frequency offset. "
                  "T1 maps and proton density maps are acquired using a Look-Locher sequence. "
                  "T2 maps are acquired using a CPMG sequence whereby each echo train acquires one line in k-space for all TEs. "
                  "Field maps are acquired using a spoiled gradient-echo sequence with different TEs. "
                  "B1 maps are acquired as described in Dowell et al., Magn Reson Med 58 (2007). "
                  "Maps are generated automatically by the reco method in this sequence module. ");
}


void METHOD_CLASS::method_pars_init() {
  Log<Seq> odinlog(this,"method_pars_init");

  Mode.add_item("T2_CPMG");
  Mode.add_item("T1_LookLocker");
  Mode.add_item("FIELD_MAP");
  Mode.add_item("B1");
  Mode.set_actual(get_current_testcase()); // alternative default settings for sequence test
  Mode.set_description("The quantitiy (and sequence) to measure.");

  ExpectedT1.set_minmaxval(10.0,10000.0);
  ExpectedT1=1300.0;
  ExpectedT1.set_description("The T1 which is expected. The TR and inversion-recovery timing will be optimized for this value.");
  ExpectedT1.set_unit(ODIN_TIME_UNIT);

  ExpectedT2.set_minmaxval(10.0,10000.0);
  ExpectedT2=90.0;
  ExpectedT2.set_description("The T2 which is expected. The CPMG timing will be optimized for this value.");
  ExpectedT2.set_unit(ODIN_TIME_UNIT);

  commonPars->set_MatrixSize(readDirection,128);
  commonPars->set_FlipAngle(90.0);


  NumOfEchoes=8;
  NumOfDummyEchoes=1;
  
  B1PulseDur=6.4; // use 30.0 for 7 Tesla;

  EchoTimes.resize(NumOfEchoes);

  append_parameter(Mode,"Mode");

  append_parameter(ExpectedT1,"ExpectedT1");
  append_parameter(ExpectedT2,"ExpectedT2");

  append_parameter(MinEchoTime,"MinEchoTime",noedit);
  append_parameter(MaxEchoTime,"MaxEchoTime",noedit);
  append_parameter(NumOfEchoes,"NumOfEchoes");
  append_parameter(NumOfDummyEchoes,"NumOfDummyEchoes");

  append_parameter(EchoTimes,"EchoTimes");

  append_parameter(B1PulseDur,"B1PulseDur");


}



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

  if(NumOfEchoes<2) NumOfEchoes=2;

  // adjust echo timings
  if(Mode=="T2_CPMG") {
    double te=ExpectedT2*T2_CPMG_ECHO_FACTOR/NumOfEchoes;
    commonPars->set_EchoTime(te,noedit);
    MinEchoTime=te;
    MaxEchoTime=NumOfEchoes*te;
  }
  if(Mode=="T1_LookLocker") {
    double ti_step=ExpectedT1*T1_IR_FACTOR/(NumOfEchoes-1);
    commonPars->set_EchoTime(ti_step,noedit);
    MinEchoTime=ExpectedT1/50.0;
    MaxEchoTime=MinEchoTime+(NumOfEchoes-1)*ti_step;
    float trwait=4.0*ExpectedT1;
    if(commonPars->get_RepetitionTime()<trwait) commonPars->set_RepetitionTime(trwait);
  }
  if(Mode=="FIELD_MAP") {
    if(NumOfEchoes%2) NumOfEchoes++; // even number of echoes (echo pairs) in EPI module
    // get TE later from EPI module
  }

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

  float slicethick=geometryInfo->get_sliceThickness();
  float spatres=slicethick/4.0;

  float gamma=systemInfo->get_gamma();

  // Sinc Excitation Pulse
  exc=SeqPulsarSinc("exc",slicethick,true,4.0,commonPars->get_FlipAngle(),spatres,256);
  exc.set_freqlist( gamma * exc.get_strength() / (2.0*PII) *  geometryInfo->get_sliceOffsetVector() );
  exc.set_pulse_type(excitation);
  if(Mode=="T1_LookLocker") exc.set_rephased(false);

  if(Mode=="B1") {
    exc.set_rephased(false);
    b1flips.resize(5);
    b1flips[0]=110.0;  
    b1flips[1]=145.0;
    b1flips[2]=180.0;
    b1flips[3]=215.0;
    b1flips[4]=250.0;

    exc.set_flipangles(b1flips);
    exc.set_pulsduration(B1PulseDur);
  }

  // 90-180-90 Refocusing Pulse
  refoc=SeqPulsarBP("refoc", 1.0, 180.0);
  refoc.set_composite_pulse("90(x) 180(y) 90(x)");
  refoc.set_pulse_type(refocusing);


  // Inversion Pulse
  inv=SeqPulsar("inv",false,false);
  inv.set_dim_mode(zeroDeeMode);
  inv.set_Tp(10.0);
  inv.resize(256);
  inv.set_spat_resolution(0.0);
  inv.set_shape("Wurst(2.96,26.48)");  // bandwidth ~ 1kHz
  inv.set_trajectory("Const(0.0,1.0)");
  inv.set_filter("Gauss");
  inv.set_pulse_type(inversion);
  inv.refresh();




  ////////////////// Resolution: /////////////////////////////////

  // uniform resolution in read and phase direction
  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);


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

  // Phase encoding before acquisition
  pe1=SeqGradPhaseEnc("pe1",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());



  // Rephasing before the refocusing pulse for CPMG
  pe2=pe1;
  pe2.set_label("pe2");
  pe2.invert_strength();


  SeqObjList pe1dummy; pe1dummy+=pe1;
  dummype=SeqDelay("dummype",pe1dummy.get_duration());


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

  float os_read=1.0;

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

  dephaseMode dephmode=spinEcho;
  if(Mode=="T1_LookLocker" || Mode=="FIELD_MAP") dephmode=FID;

  readdeph=SeqAcqDeph("readdeph",acqread,dephmode);

  acqdummy=SeqDelay("acqdummy",acqread.get_duration());


  //////////////// Gradient Echo Module: //////////////////////////////

  grech=SeqGradEcho("grech", exc, commonPars->get_AcqSweepWidth(),
              commonPars->get_MatrixSize(readDirection), geometryInfo->get_FOV(readDirection),
              commonPars->get_MatrixSize(phaseDirection), geometryInfo->get_FOV(phaseDirection),
              linearEncoding, noReorder, 1, commonPars->get_ReductionFactor(), DEFAULT_ACL_BANDS, false, commonPars->get_PartialFourier());

  //////////////// EPI module: //////////////////////////////

  epi=SeqAcqEPI("epi",commonPars->get_AcqSweepWidth(),
                commonPars->get_MatrixSize(readDirection), geometryInfo->get_FOV(readDirection),
                commonPars->get_MatrixSize(phaseDirection), geometryInfo->get_FOV(phaseDirection),
                commonPars->get_MatrixSize(phaseDirection), 1, os_read,"",0,0,linear,false,1.0,0.0,NumOfEchoes/2);

  epideph=SeqAcqDeph("epideph",epi,FID);


  //////////////// Timng Delays: //////////////////////////////

  excdelay=SeqDelay("excdelay",systemInfo->get_min_duration(delayObj));

  echodelay1=SeqDelay("echodelay1",systemInfo->get_min_duration(delayObj));

  echodelay2=SeqDelay("echodelay2",systemInfo->get_min_duration(delayObj));

  relaxdelay=SeqDelay("relaxdelay",0.0);

  invdelay=SeqDelay("invdelay");

  //////////////// Echo Vector: //////////////////////////////

  // an index vector is used which is responsible for assigning
  // the ADCs to the correct k-space data in the reconstruction

  echovec=SeqVector("echovec",NumOfEchoes);



  //////////////// Loops: //////////////////////////////

  echoloop=SeqObjLoop("echoloop");

  dummyecholoop=SeqObjLoop("dummyecholoop");

  peloop=SeqObjLoop("peloop");

  sliceloop=SeqObjLoop("sliceloop");

  acculoop=SeqObjLoop("acculoop");

  fliploop=SeqObjLoop("fliploop");


  //////////////// Spoiler: //////////////////////////////

  double SpoilerDuration=2.0;
  double SpoilerStrength=60.0;

  float spoiler_strength_phys=(double)SpoilerStrength/100.0*systemInfo->get_max_grad();
  spoiler1=SeqGradConstPulse("spoiler1",phaseDirection,spoiler_strength_phys,SpoilerDuration);


  fvector spoilertrims(NumOfEchoes);
  spoilertrims.fill_linear(-1.0,1.0);
  spoiler2=SeqGradVectorPulse("spoiler2",readDirection,spoiler_strength_phys,spoilertrims,SpoilerDuration*double(NumOfEchoes));



  //////////////// Building the sequence: //////////////////////////////

  postexc=SeqObjList("postexc");
  postrefoc=SeqObjList("postrefoc");
  postrefoctmpl=SeqObjList("postrefoctmpl");

  echopart=SeqObjList("echopart");
  grechpart=SeqObjList("grechpart");
  dummyechopart=SeqObjList("dummyechopart");
  kernel=SeqObjList("kernel");
  slicepart=SeqObjList("slicepart");

  if(Mode=="T2_CPMG") {

    postexc=excdelay + readdeph ;
    postrefoc=    spoiler1  + echodelay1 + pe1;
    postrefoctmpl=spoiler1  + echodelay1 + dummype;

    echopart=      spoiler1 + refoc + postrefoc     + acqread  + pe2     + echodelay2 ;
    dummyechopart= spoiler1 + refoc + postrefoctmpl + acqdummy + dummype + echodelay2 ;

    if (NumOfDummyEchoes>1) {
      kernel= exc + postexc + dummyecholoop(dummyechopart)[NumOfDummyEchoes] + echoloop(echopart)[echovec];
    } else {
      kernel= exc + postexc + echoloop(echopart)[echovec];
    }

    slicepart= sliceloop( kernel + relaxdelay )[exc];

    set_sequence( acculoop( peloop( slicepart )[pe1][pe2] )[commonPars->get_NumOfRepetitions()] );
  }


  if(Mode=="T1_LookLocker") {

   grechpart= sliceloop( grech )[exc];

   echopart=  grechpart + spoiler2 + echodelay1;

   kernel= inv + spoiler1 + invdelay + echoloop( echopart )[spoiler2];

   slicepart=  kernel + relaxdelay;

   set_sequence(  acculoop (  peloop( slicepart )[grech.get_pe_vector()] )[commonPars->get_NumOfRepetitions()] );
  }



  if(Mode=="FIELD_MAP") {

    kernel= exc + epideph + epi;

    slicepart= sliceloop(  kernel + relaxdelay  )[exc];

    set_sequence(  acculoop ( peloop( slicepart )[epideph.get_epi_segment_vector()] )[commonPars->get_NumOfRepetitions()] );
  }

  if(Mode=="B1") {

   slicepart= sliceloop(  grech + spoiler1 + relaxdelay  )[exc];

   set_sequence(
     fliploop(
       acculoop (
         peloop(
           slicepart
         )[grech.get_pe_vector()]
       )[commonPars->get_NumOfRepetitions()]
     )[exc.get_flipangle_vector()]
   );

  }


}


void METHOD_CLASS::method_rels() {
  Log<Seq> odinlog(this,"method_rels");

  //////////////// Timings: //////////////////////////////

  float exc2refoc_duration;
  float refoc2acq_duration;
  float acq_shift;

  float min_echo_time=0.0;

  float mindelaydur=systemInfo->get_min_duration(delayObj);

  echodelay1.set_duration(mindelaydur);
  echodelay2.set_duration(mindelaydur);
  excdelay.set_duration(mindelaydur);

  EchoTimes.resize(NumOfEchoes);



  if(Mode=="T2_CPMG") {

    //////////////// Duration from the middle of the excitation pulse ///////////////////
    //////////////// to the middle of the refocusing pulse: /////////////////////////////
    exc2refoc_duration=( exc.get_duration() - exc.get_magnetic_center() )
                          + postexc.get_duration()
                          + echoloop.get_preduration()
                          + spoiler1.get_duration()
                          + refoc.get_magnetic_center();



    if(min_echo_time < exc2refoc_duration*2.0 ) min_echo_time=exc2refoc_duration*2.0;

    float echoloopdur=echoloop.get_preduration()+echopart.get_duration();

    if(min_echo_time < echoloopdur) min_echo_time=echoloopdur;

    if(commonPars->get_EchoTime()<min_echo_time) commonPars->set_EchoTime(min_echo_time);

    echodelay1.set_duration( ( commonPars->get_EchoTime() - echoloopdur )/2.0 );
    echodelay2.set_duration( ( commonPars->get_EchoTime() - echoloopdur )/2.0 );

    //////////////// Duration from the middle of the refocusing pulse ///////////////////
    //////////////// to the middle of the acquisition window: ///////////////////////////
    refoc2acq_duration=( refoc.get_duration() - refoc.get_magnetic_center() )
                     + postrefoc.get_duration()
                     + acqread.get_acquisition_center();


    echoloopdur=echoloop.get_preduration()+echopart.get_duration();

    acq_shift=refoc2acq_duration-echoloopdur/2.0;
    echodelay1.set_duration( echodelay1.get_duration() - acq_shift );
    echodelay2.set_duration( echodelay2.get_duration() + acq_shift );


    excdelay=commonPars->get_EchoTime()/2.0-exc2refoc_duration;

    EchoTimes.fill_linear(commonPars->get_EchoTime(),NumOfEchoes*commonPars->get_EchoTime());
  }






  if(Mode=="T1_LookLocker") {

    float inv2acq_duration=( inv.get_duration() - inv.get_magnetic_center() )
                           +spoiler1.get_duration()
                           +grech.get_acquisition_center();

    if(MinEchoTime<inv2acq_duration) MinEchoTime=inv2acq_duration;

    float oneloopdur=echopart.get_duration();

    float lastechotime=MinEchoTime+(NumOfEchoes-1)*oneloopdur;

    if(MaxEchoTime<lastechotime) MaxEchoTime=lastechotime;

    float echotimediff=MaxEchoTime-MinEchoTime;

    echodelay1=echotimediff/float(NumOfEchoes-1)-oneloopdur;

    invdelay=MinEchoTime-inv2acq_duration;

    EchoTimes.fill_linear(MinEchoTime,MaxEchoTime);
  }

  if(Mode=="FIELD_MAP" || Mode=="B1") {
    MinEchoTime=0.0;
    MaxEchoTime=0.0;
    EchoTimes.fill_linear(0.0,0.0);
  }
  ODINLOG(odinlog,normalDebug) << "EchoTimes=" << EchoTimes.printbody() << STD_endl;


  relaxdelay=0.0;
  double slicepackdur=slicepart.get_duration();
  ODINLOG(odinlog,normalDebug) << "slicepackdur=" << slicepackdur << STD_endl;

  int n_slices_to_consider=geometryInfo->get_nSlices();
  if(Mode=="T1_LookLocker") n_slices_to_consider=1; // because of inversion pulse
  if(Mode=="T2_CPMG") n_slices_to_consider=1; // because of hard refoc pulse

  if(commonPars->get_RepetitionTime()<slicepackdur) commonPars->set_RepetitionTime(slicepackdur);
  else relaxdelay=secureDivision(commonPars->get_RepetitionTime()-slicepackdur,n_slices_to_consider);



  float flipangle=90.0;

  if(Mode=="FIELD_MAP") {
    // calculate Ernst angle according to TR
    flipangle=180.0/PII * acos( exp ( -secureDivision ( commonPars->get_RepetitionTime(), ExpectedT1) ) );
    commonPars->set_FlipAngle( flipangle, noedit );
  } else if(Mode=="T1_LookLocker") {
    flipangle=commonPars->get_FlipAngle();
    float maxflip=15.0;
    if(flipangle>maxflip) flipangle=maxflip;
    commonPars->set_FlipAngle( flipangle, edit );
  } else {
    commonPars->set_FlipAngle( flipangle, noedit );
  }

  if(Mode!="B1") {
    exc.set_flipangle( flipangle );
  }

}


void METHOD_CLASS::method_pars_set() {
  Log<Seq> odinlog(this,"method_pars_set");

  if(Mode=="T2_CPMG") {

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

    // store different echoes in te dimension with echo times attached
    acqread.set_reco_vector(userdef, echovec, EchoTimes);

    recoInfo->set_PostProc3D("usercoll | expfit(true) ");
  }


  if(Mode=="T1_LookLocker") {

    // store different echoes in te dimension with echo times attached
    grech.set_reco_vector(userdef, spoiler2, EchoTimes);

    recoInfo->set_PostProc3D("usercoll | t1fit ");
  }


  if(Mode=="FIELD_MAP") {

    // inform the readout about the used slice vector (for automatic reconstruction)
    epi.set_reco_vector(slice,exc);

//    epi.set_te_offset(exc.get_duration()-exc.get_magnetic_center()+epideph.get_duration());

    recoInfo->set_PreProc3D("tecoll | fieldmap "); // calculate fieldmap before summing up channels!
  }

  if(Mode=="B1") {

    // store different echoes in te dimension with echo times attached
    grech.set_reco_vector(userdef, exc.get_flipangle_vector(), fvector2dvector(b1flips));

    recoInfo->set_PostProc3D("usercoll | b1fit ");
  }

}


///////////////////////////////////////////////////////////////////////////////////////////


// entry point for the sequence module
ODINMETHOD_ENTRY_POINT