sequence_provider
sequence_provider
Sequence provider class.
ADCGate
dataclass
Define precalculated attributes of an ADC gate.
SequenceProvider
SequenceProvider(gradient_efficiency: tuple[float, float, float], gpa_gain: tuple[float, float, float], gradient_output_limits: tuple[int, int, int], gradients_50ohms: bool, rf_output_limit: int, rf_50ohms: bool, rf_to_mvolt: float, spcm_dwell_time: float, system: Opts, rf_gain_lut_path: Path | None = None)
Bases: Sequence
Sequence provider class.
Subclass of the PyPulseq Sequence, so that all PyPulseq sequence methods remain accessible.
The main functionality is unroll_sequence, which translates the block-structured sequence into
the interleaved int16 replay buffer of the transmit card (RF, three gradients and three digital
control signals in bit 15 of the gradient channels).
Examples:
>>> seq_provider = SequenceProvider(..., system=opts)
>>> seq_provider.read("./seq_file.seq")
>>> unrolled = seq_provider.unroll_sequence(acquisition_parameter)
Initialize sequence provider class which is used to unroll a pulseq sequence.
Parameters:
-
gradient_efficiency(tuple[float, float, float]) –Efficiency of the gradient coils in T/m/A per physical gradient channel, e.g. [0.4e-3, 0.4e-3, 0.4e-3].
-
gpa_gain(tuple[float, float, float]) –Transconductance of the gradient power amplifier in A/V per physical gradient channel, e.g. [4.7, 4.7, 4.7].
-
gradient_output_limits(tuple[int, int, int]) –Integer output limit per gradient channel in mV, e.g. [6000, 6000, 6000].
-
gradients_50ohms(bool) –Boolean flag which indicates if the gradient output is terminated into 50 ohms or high impedance. If terminated into high impedance, the card output doubles, what needs to be considered when calculating the sequence.
-
rf_output_limit(int) –Integer output limit of the RF channel in mV.
-
rf_50ohms(bool) –Boolean flag which indicates if the rf output is terminated into 50 ohms (see gradients_50ohms).
-
rf_to_mvolt(float) –Translation of RF waveform from pulseq (Hz) to mV.
-
spcm_dwell_time(float) –Sampling time raster of the output waveform (depends on spectrum card).
-
system(Opts) –Pypulseq system limits object used for sequence construction.
-
rf_gain_lut_path(Path or None, default:None) –Path to the RF power amplifier gain lookup table (.npy file), by default None. If None or the file does not exist, no LUT is applied.
Source code in src/console/pulseq_interpreter/sequence_provider.py
from_pypulseq
Read a pypulseq sequence to sequence provider.
Parameters:
-
seq(Sequence) –Pypulseq
Sequenceinstance
Raises:
-
AttributeError–seq is not a valid pypulseq
Sequenceinstance
Source code in src/console/pulseq_interpreter/sequence_provider.py
to_pypulseq
Create a pypulseq sequence from sequence provider.
Source code in src/console/pulseq_interpreter/sequence_provider.py
dict
dict() -> dict
Abstract method which returns variables for logging in dictionary.
Source code in src/console/pulseq_interpreter/sequence_provider.py
unroll_sequence
unroll_sequence(parameter: AcquisitionParameter) -> UnrolledSequence
Unroll the pypulseq sequence description.
Parameters:
-
parameter(AcquisitionParameter) –Instance of AcquisitionParameter containing all necessary parameters to calculate the sequence waveforms, i.e. larmor frequency, gradient offsets, etc.
Returns:
-
UnrolledSequence–Interleaved int16 replay buffer of the transmit card (channel order RF, gradient 1, 2, 3), in which bit 15 of the gradient channels carries the digital control signals, together with one
RxDatatemplate per ADC event.
Raises:
-
ValueError–Invalid acquisition parameter, or a waveform exceeds the output limit of its channel.
-
IndexError–Inconsistent block timing or an RF waveform exceeding its block.
Examples:
For channels ch0, ch1, ch2, ch3, data values n = 0, 1, ..., N are ordered the following way.
Per channel data can be extracted by the following code.
>>> rf = seq[0::4]
>>> g1 = (seq[1::4].view(np.uint16) << 1).view(np.int16)
>>> g2 = (seq[2::4].view(np.uint16) << 1).view(np.int16)
>>> g3 = (seq[3::4].view(np.uint16) << 1).view(np.int16)
Bit 15 of the gradient channels carries the digital signals: channel 1 the ADC gate, channel 2 the phase reference and channel 3 the RF unblanking signal. As bit 15 does not encode the sign, the values are viewed as uint16 before shifting.
>>> adc_gate = seq[1::4].view(np.uint16) >> 15
>>> reference = seq[2::4].view(np.uint16) >> 15
>>> unblanking = seq[3::4].view(np.uint16) >> 15
Source code in src/console/pulseq_interpreter/sequence_provider.py
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 | |