KSFoundation  [October2024]
A platform for structured EPIC programming on GE MR systems
Prep sequence module: ChemSat (kschemsat.[h,cc,e])

Data Structures

struct  KSCHEMSAT_DESIGN
 
struct  KSCHEMSAT_MODULE
 

Macros

#define KSCHEMSAT_MODULE_LOADED
 
#define KSCHEMSAT_DEFAULT_FLIP   95
 
#define KSCHEMSAT_DEFAULT_SINCRF_BW_15T   150 /* for 1.5T */
 
#define KSCHEMSAT_DEFAULT_SINCRF_BW_3T   300 /* for 3T */
 
#define KSCHEMSAT_DEFAULT_SINCRF_TBP   4
 
#define KSCHEMSAT_DEFAULT_SPOILERAREA   5000
 
#define KSCHEMSAT_DEFAULT_SSITIME   1000 /* try to reduce this value */
 
#define KSCHEMSAT_INIT_DESIGN   {KSCHEMSAT_OFF, KSCHEMSAT_DEFAULT_FLIP, 0, KSCHEMSAT_RF_STD, KSCHEMSAT_DEFAULT_SINCRF_BW_3T, KSCHEMSAT_DEFAULT_SINCRF_TBP, KSCHEMSAT_DEFAULT_SPOILERAREA, KSCHEMSAT_DEFAULT_SSITIME}
 
#define KSCHEMSAT_INIT_MODULE   {KS_INIT_BASE(KSCHEMSAT_MODULE), KS_INIT_SEQ_CONTROL, KSCHEMSAT_INIT_DESIGN, KS_INIT_RF, KS_INIT_TRAP, KS_NOTSET, 0, 0}
 

Enumerations

enum  { KSCHEMSAT_OFF, KSCHEMSAT_FAT, KSCHEMSAT_WATER }
 
enum  { KSCHEMSAT_RF_STD, KSCHEMSAT_RF_SINC }
 

Functions

void kschemsat_init_design (KSCHEMSAT_DESIGN *design)
 
STATUS kschemsat_eval_design (KSCHEMSAT_MODULE *chemsat)
 
STATUS kschemsat_pg (KSCHEMSAT_MODULE *chemsat, int start_time, KS_SEQ_CONTROL *seqctrl_p)
 
void kschemsat_set_design_from_UI (KSCHEMSAT_DESIGN *design)
 

Variables

KSCHEMSAT_MODULE kschemsat = KSCHEMSAT_INIT_MODULE
 
int kschemsat_flag = KSCHEMSAT_OFF with {KSCHEMSAT_OFF, KSCHEMSAT_WATER, KSCHEMSAT_OFF, VIS, "flag for kschemsat (0:Off 1:FatSat 2:WaterSat)",}
 
float kschemsat_flip = KSCHEMSAT_DEFAULT_FLIP with {0, 360, KSCHEMSAT_DEFAULT_FLIP, VIS, "RF flip angle [deg]",}
 
int kschemsat_rftype = KSCHEMSAT_RF_STD with {KSCHEMSAT_RF_STD, KSCHEMSAT_RF_SINC, KSCHEMSAT_RF_STD, VIS, "RF type (0:Std 1:Sinc)",}
 
int kschemsat_sinc_bw = KSCHEMSAT_DEFAULT_SINCRF_BW_3T with {2, 100000, 300, VIS, "Sinc RF BW",}
 
int kschemsat_sinc_tbp = KSCHEMSAT_DEFAULT_SINCRF_TBP with {2, 20, 2, VIS, "Sinc RF Time-Bandwidth-Product",}
 
int kschemsat_rfoffset = 0 with {-1000, 1000, 0, VIS, "RF excitation freq offset [Hz]",}
 
float kschemsat_spoilerarea = KSCHEMSAT_DEFAULT_SPOILERAREA with {0, 10000, KSCHEMSAT_DEFAULT_SPOILERAREA, VIS, "Spoiler area",}
 
int kschemsat_ssi_time = KSCHEMSAT_DEFAULT_SSITIME with {10, 20000, KSCHEMSAT_DEFAULT_SSITIME, VIS, "Time from eos to ssi in intern trig",}
 

Detailed Description

Macro Definition Documentation

◆ KSCHEMSAT_MODULE_LOADED

#define KSCHEMSAT_MODULE_LOADED

can be used to check whether the chemsat module has been included in a main psd

◆ KSCHEMSAT_DEFAULT_FLIP

#define KSCHEMSAT_DEFAULT_FLIP   95

◆ KSCHEMSAT_DEFAULT_SINCRF_BW_15T

#define KSCHEMSAT_DEFAULT_SINCRF_BW_15T   150 /* for 1.5T */

◆ KSCHEMSAT_DEFAULT_SINCRF_BW_3T

#define KSCHEMSAT_DEFAULT_SINCRF_BW_3T   300 /* for 3T */

◆ KSCHEMSAT_DEFAULT_SINCRF_TBP

#define KSCHEMSAT_DEFAULT_SINCRF_TBP   4

◆ KSCHEMSAT_DEFAULT_SPOILERAREA

#define KSCHEMSAT_DEFAULT_SPOILERAREA   5000

◆ KSCHEMSAT_DEFAULT_SSITIME

#define KSCHEMSAT_DEFAULT_SSITIME   1000 /* try to reduce this value */

◆ KSCHEMSAT_INIT_DESIGN

◆ KSCHEMSAT_INIT_MODULE

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
KSCHEMSAT_OFF 
KSCHEMSAT_FAT 
KSCHEMSAT_WATER 
Definition: kschemsat.h:27
Definition: kschemsat.h:27
Definition: kschemsat.h:27

◆ anonymous enum

anonymous enum
Enumerator
KSCHEMSAT_RF_STD 
KSCHEMSAT_RF_SINC 
Definition: kschemsat.h:28
Definition: kschemsat.h:28

Function Documentation

◆ kschemsat_init_design()

void kschemsat_init_design ( KSCHEMSAT_DESIGN design)

Initialize a chemical sat design to off

Parameters
[out]designpointer to the chemical sat design
Return values
STATUSSUCCESS or FAILURE
32  {
33  design->satmode = KSCHEMSAT_OFF;
34 
35 } /* kschemsat_init_design() */
int satmode
Definition: kschemsat.h:46
Definition: kschemsat.h:27

◆ kschemsat_eval_design()

STATUS kschemsat_eval_design ( KSCHEMSAT_MODULE chemsat)

Populate objects from design

Parameters
[in,out]chemsatpointer to the module to be processed
Return values
STATUSSUCCESS or FAILURE
40  {
41  STATUS status;
42 
43  chemsat->end_time = 0;
44 
45  if (chemsat->design.satmode == KSCHEMSAT_OFF) {
46  return SUCCESS;
47  }
48 
49  /* RF */
50  if (chemsat->design.rftype == KSCHEMSAT_RF_SINC) {
51  /* create a KS_RF using ks_eval_rf_sinc */
52  status = ks_eval_rf_sinc(&chemsat->rf, "kschemsat_rf", chemsat->design.sincrf_bw, chemsat->design.sincrf_tbp, chemsat->design.flip, KS_RF_SINCWIN_HAMMING);
53  KS_RAISE(status);
54  chemsat->rf.role = KS_RF_ROLE_CHEMSAT;
55  } else {
56  if (cffield == 30000)
57  chemsat->rf = chemsat_cs3t; /* KSFoundation_GERF.h */
58  else
59  chemsat->rf = chemsat_csm; /* KSFoundation_GERF.h */
60  chemsat->rf.flip = chemsat->design.flip;
61  status = ks_eval_rf(&chemsat->rf, "kschemsat_rf");
62  KS_RAISE(status);
63  }
64  chemsat->rf.cf_offset = chemsat->design.rfoffset; /* Exciter offset in Hz */
65 
66  /* ks_print_rf(chemsat->rf, stderr); fflush(stderr); */
67 
68  /* set up spoiler */
69  chemsat->spoiler.area = chemsat->design.spoilerarea;
70  status = ks_eval_trap_rotation_invariant_75_max_slewrate(&chemsat->spoiler, "kschemsat_spoiler");
71  KS_RAISE(status);
72 
73 
74  /* setup seqctrl with desired SSI time and zero duration. .min_duration will be set in kschemsat_pg() */
75  ks_init_seqcontrol(&chemsat->seqctrl);
76  strcpy(chemsat->seqctrl.description, "kschemsat");
77 
78  return SUCCESS;
79 
80 } /* kschemsat_eval_design() */
STATUS ks_eval_trap_rotation_invariant_75_max_slewrate(KS_TRAP *trap, const char *const desc)
Sets up a trapezoid using a KS_TRAP sequence object with physical gradient constraints (invariant to ...
Definition: KSFoundation_host.c:524
int satmode
Definition: kschemsat.h:46
float cf_offset
Definition: KSFoundation.h:1030
Definition: KSFoundation.h:2341
int role
Definition: KSFoundation.h:1027
float spoilerarea
Definition: kschemsat.h:52
float flip
Definition: kschemsat.h:47
int sincrf_tbp
Definition: kschemsat.h:51
Definition: kschemsat.h:27
int end_time
Definition: kschemsat.h:70
KS_SEQ_CONTROL seqctrl
Definition: kschemsat.h:66
float flip
Definition: KSFoundation.h:1028
KS_RF rf
Definition: kschemsat.h:68
int sincrf_bw
Definition: kschemsat.h:50
DECL_TYPE KS_RF chemsat_cs3t
Definition: KSFoundation_GERF.c:2716
KS_TRAP spoiler
Definition: kschemsat.h:69
void ks_init_seqcontrol(KS_SEQ_CONTROL *seqcontrol)
Resets KS_SEQ_CONTROL to its default value (KS_INIT_SEQ_CONTROL)
Definition: KSFoundation_host.c:148
float area
Definition: KSFoundation.h:670
#define KS_RAISE(status)
Definition: KSFoundation.h:190
KSCHEMSAT_DESIGN design
Definition: kschemsat.h:67
STATUS ks_eval_rf(KS_RF *rf, const char *const desc) WARN_UNUSED_RESULT
Sets up a KS_RF object
Definition: KSFoundation_host.c:2805
STATUS ks_eval_rf_sinc(KS_RF *rf, const char *const desc, double bw, double tbw, float flip, int wintype) WARN_UNUSED_RESULT
Sets up a KS_RF object with a Sinc pulse shape
Definition: KSFoundation_host.c:2176
Definition: kschemsat.h:28
DECL_TYPE KS_RF chemsat_csm
Definition: KSFoundation_GERF.c:2642
Definition: KSFoundation.h:2340
KS_DESCRIPTION description
Definition: KSFoundation.h:1234
int rfoffset
Definition: kschemsat.h:48
int rftype
Definition: kschemsat.h:49

◆ kschemsat_pg()

STATUS kschemsat_pg ( KSCHEMSAT_MODULE chemsat,
int  start_time,
KS_SEQ_CONTROL seqctrl_p 
)

Generate the waveforms of a chemical sat module

If seqctrl_p is not NULL, it is assumed that the ChemSat is generated within another sequence module, use start_time to control the positioning. The end_time field is set to be able to continue the pulse generation.

Parameters
[in,out]chemsatpointer to the module to be processed
[in]start_timetime position for the start of the chemical sat waveforms
[in,out]seqctrl_poptional pointer to a sequence control for embedding
Return values
STATUSSUCCESS or FAILURE
89  {
90  STATUS status;
92 
93  if (!chemsat) {
94  return KS_THROW("the first argument can not be NULL");
95  }
96 
97  #ifdef HOST_TGT
99  chemsat->seqctrl.duration = 0;
100  #endif
101 
102  /* Initialize critical fields */
103  chemsat->embedded = 1;
104  chemsat->spoiling_counter = 0;
105 
106  /* return early if sat mode is off */
107  if (chemsat->design.satmode == KSCHEMSAT_OFF) {
108  chemsat->end_time = start_time;
109  return SUCCESS;
110  }
111 
112  if (!seqctrl_p) {
113  /* If seqctrl_p is NULL we assume an independent sequence module will be generated */
114  seqctrl_p = &chemsat->seqctrl;
115  chemsat->embedded = 0;
116  }
117 
118  loc.pos = RUP_GRD(IMax(2, KS_RFSSP_PRETIME + 32, start_time));
119 
120  /* RF */
121  status = ks_pg_rf(&chemsat->rf, loc, seqctrl_p);
122  KS_RAISE(status);
123 
124  loc.pos += chemsat->rf.rfwave.duration;
125 
126  /* Y spoiler */
127  loc.board = YGRAD;
128  status = ks_pg_trap(&chemsat->spoiler, loc, seqctrl_p);
129  KS_RAISE(status);
130 
131  /* Z spoiler */
132  loc.board = ZGRAD;
133  status = ks_pg_trap(&chemsat->spoiler, loc, seqctrl_p);
134  KS_RAISE(status);
135 
136  loc.pos += chemsat->spoiler.duration;
137 
138  /* make sure we are divisible by GRAD_UPDATE_TIME (4us) */
139  loc.pos = RUP_GRD(loc.pos);
140 
141  chemsat->end_time = loc.pos;
142 
143 #ifdef HOST_TGT
144  /************************************************************************************************
145  * Set the minimal sequence duration
146  ***********************************************************************************************/
147  chemsat->seqctrl.ssi_time = chemsat->design.ssi_time;
148  ks_eval_seqctrl_setminduration(seqctrl_p, chemsat->end_time);
149 #endif
150 
151  return SUCCESS;
152 
153 } /* kschemsat_pg() */
int satmode
Definition: kschemsat.h:46
int pos
Definition: KSFoundation.h:463
Definition: kschemsat.h:27
int end_time
Definition: kschemsat.h:70
int board
Definition: KSFoundation.h:462
int duration
Definition: KSFoundation.h:1227
KS_SEQ_CONTROL seqctrl
Definition: kschemsat.h:66
KS_RF rf
Definition: kschemsat.h:68
KS_TRAP spoiler
Definition: kschemsat.h:69
int embedded
Definition: kschemsat.h:71
KS_WAVE rfwave
Definition: KSFoundation.h:1037
STATUS ks_pg_rf(KS_RF *rf, KS_SEQLOC loc, KS_SEQ_CONTROL *ctrl) WARN_UNUSED_RESULT
Places a KS_RF sequence object on a board at some position in the pulse sequence
Definition: KSFoundation_common.c:2652
int ssi_time
Definition: kschemsat.h:53
STATUS ks_pg_trap(KS_TRAP *trap, KS_SEQLOC loc, KS_SEQ_CONTROL *ctrl) WARN_UNUSED_RESULT
Places a KS_TRAP sequence object on a board at some position in the pulse sequence
Definition: KSFoundation_common.c:1802
#define KS_RAISE(status)
Definition: KSFoundation.h:190
KSCHEMSAT_DESIGN design
Definition: kschemsat.h:67
typedef struct used as argument to ks_pg_*** functions to control where and when to place a sequence ...
Definition: KSFoundation.h:461
int ssi_time
Definition: KSFoundation.h:1226
STATUS ks_eval_seqctrl_setminduration(KS_SEQ_CONTROL *seqctrl, int mindur)
Sets the minimum duration and duration fields of a KS_SEQ_CONTROL struct based on some minimum time (...
Definition: KSFoundation_host.c:4921
int spoiling_counter
Definition: kschemsat.h:72
#define KS_INIT_SEQLOC
Definition: KSFoundation.h:287
int duration
Definition: KSFoundation.h:673
#define KS_THROW(format,...)
Definition: KSFoundation.h:181
int duration
Definition: KSFoundation.h:747
#define KS_RFSSP_PRETIME
Definition: KSFoundation.h:217

◆ kschemsat_set_design_from_UI()

void kschemsat_set_design_from_UI ( KSCHEMSAT_DESIGN design)

Set the design values of a chemical sat module according to the scanner's UI

Parameters
[out]designPointer to a chamical sat's design
Return values
STATUSSUCCESS or FAILURE
78  {
79 
81  if (opfat) {
83  kschemsat_rfoffset = -(float) SDL_GetChemicalShift(cffield);
84  } else if (opwater) {
86  } else {
88  }
89 
90  if (cffield == 30000) {
92  } else {
94  }
95 
96  design->satmode = kschemsat_flag;
97 
98  /* RF */
99  design->flip = kschemsat_flip;
100  design->rfoffset = kschemsat_rfoffset;
101  design->rftype = kschemsat_rftype;
102  if (design->rftype == KSCHEMSAT_RF_SINC) {
103  design->sincrf_bw = kschemsat_sinc_bw;
104  design->sincrf_tbp = kschemsat_sinc_tbp;
105  } else {
106  design->sincrf_bw = KS_NOTSET;
107  design->sincrf_tbp = KS_NOTSET;
108  }
109 
110  /* Spoiler */
112 
113  /* SSI time */
114  design->ssi_time = kschemsat_ssi_time;
115 
116 } /* kschemsat_set_design_from_UI() */
int satmode
Definition: kschemsat.h:46
#define KS_NOTSET
Definition: KSFoundation.h:115
Definition: kschemsat.h:27
float spoilerarea
Definition: kschemsat.h:52
float flip
Definition: kschemsat.h:47
int sincrf_tbp
Definition: kschemsat.h:51
#define KSCHEMSAT_DEFAULT_SINCRF_BW_15T
Definition: kschemsat.h:33
Definition: kschemsat.h:27
int sincrf_bw
Definition: kschemsat.h:50
#define KSCHEMSAT_DEFAULT_SINCRF_BW_3T
Definition: kschemsat.h:34
int kschemsat_rftype
Definition: kschemsat.e:57
int kschemsat_rfoffset
Definition: kschemsat.e:60
int kschemsat_ssi_time
Definition: kschemsat.e:62
float kschemsat_flip
Definition: kschemsat.e:56
Definition: kschemsat.h:27
int ssi_time
Definition: kschemsat.h:53
Definition: kschemsat.h:28
int kschemsat_flag
Definition: kschemsat.e:55
int kschemsat_sinc_bw
Definition: kschemsat.e:58
int rfoffset
Definition: kschemsat.h:48
int rftype
Definition: kschemsat.h:49
float kschemsat_spoilerarea
Definition: kschemsat.e:61
int kschemsat_sinc_tbp
Definition: kschemsat.e:59

Variable Documentation

◆ kschemsat

◆ kschemsat_flag

int kschemsat_flag = KSCHEMSAT_OFF with {KSCHEMSAT_OFF, KSCHEMSAT_WATER, KSCHEMSAT_OFF, VIS, "flag for kschemsat (0:Off 1:FatSat 2:WaterSat)",}

◆ kschemsat_flip

float kschemsat_flip = KSCHEMSAT_DEFAULT_FLIP with {0, 360, KSCHEMSAT_DEFAULT_FLIP, VIS, "RF flip angle [deg]",}

◆ kschemsat_rftype

int kschemsat_rftype = KSCHEMSAT_RF_STD with {KSCHEMSAT_RF_STD, KSCHEMSAT_RF_SINC, KSCHEMSAT_RF_STD, VIS, "RF type (0:Std 1:Sinc)",}

◆ kschemsat_sinc_bw

int kschemsat_sinc_bw = KSCHEMSAT_DEFAULT_SINCRF_BW_3T with {2, 100000, 300, VIS, "Sinc RF BW",}

◆ kschemsat_sinc_tbp

int kschemsat_sinc_tbp = KSCHEMSAT_DEFAULT_SINCRF_TBP with {2, 20, 2, VIS, "Sinc RF Time-Bandwidth-Product",}

◆ kschemsat_rfoffset

int kschemsat_rfoffset = 0 with {-1000, 1000, 0, VIS, "RF excitation freq offset [Hz]",}

◆ kschemsat_spoilerarea

float kschemsat_spoilerarea = KSCHEMSAT_DEFAULT_SPOILERAREA with {0, 10000, KSCHEMSAT_DEFAULT_SPOILERAREA, VIS, "Spoiler area",}

◆ kschemsat_ssi_time

int kschemsat_ssi_time = KSCHEMSAT_DEFAULT_SSITIME with {10, 20000, KSCHEMSAT_DEFAULT_SSITIME, VIS, "Time from eos to ssi in intern trig",}