Core Components¶
Sequence ¶
Sequence(
building_blocks: List[SequenceBaseBlock],
system_specs: SystemSpec,
snap_to_raster: bool = False,
copy: bool = False,
)
Container for MRI sequence building blocks.
A sequence stores mutable SequenceBaseBlock instances and validates them against a shared
SystemSpec. Conceptual usage examples live in the sequence model guide.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
building_blocks
|
List[SequenceBaseBlock]
|
Building blocks to include in the sequence. |
required |
system_specs
|
SystemSpec
|
System limits used for validation and rasterization. |
required |
snap_to_raster
|
bool
|
If |
False
|
copy
|
bool
|
If |
False
|
Source code in cmrseq/core/_sequence.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
duration
property
¶
duration: Quantity
Time difference of earliest start and latest end of all blocks contained in the sequence
gradients
property
¶
gradients: List[Tuple[Quantity, Quantity]]
Returns the gradient definitions (t, wf) of all Gradient-type blocks that are contained in the sequence. If an OMatrix is registered the gradient channels are rotated accordingly by applying the OMatrix object
rf
property
¶
rf: List[Tuple[Quantity, Quantity]]
Returns the rf definitions (t, amplitude) of RFPulse-type blocks that are contained in the sequence. If an OMatrix is registered the frequency offset is adjusted accordingly by applying the OMatrix object
rf_events
property
¶
rf_events: List[Tuple[Quantity, Quantity]]
Returns the rf events (rf-center, flip-angle) of RFPulse-type blocks that are contained in the sequence.
adc_centers
property
¶
adc_centers: List[Quantity]
Returns the centers of all adc_blocks in the sequence.
blocks
property
¶
blocks: List[str]
Returns a tuple containing the names of all blocks contained in the sequence object, where temporal ordering is assumed
items ¶
items()
Returns a generator yielding (unique_block_name, block) tuples
Source code in cmrseq/core/_sequence.py
173 174 175 176 | |
validate ¶
validate() -> None
Calls the validation function of each block with self._system_specs
Raises:
| Type | Description |
|---|---|
ValueError
|
If any contained block fails to validate with own system specs |
ValueError
|
If any combination of contained acquisition blocks have temporal overlap. |
:raise ValueError: If all combined gradient definitions exceed system limits (max amplitude
|
and slew-rate) |
Source code in cmrseq/core/_sequence.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
add_block ¶
add_block(
block: SequenceBaseBlock, copy: bool = True
) -> None
Add the instance of block to the internal List of sequence blocks.
Note: The internal definition of blocks is mutable, therefore if the new block is not copied, subsequent alterations can have unwanted side-effects inside the sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
SequenceBaseBlock
|
Sequence block to be added to the sequence |
required |
copy
|
bool
|
Determines if the block is copied before adding it to the sequence |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If block.validate() fails to validate using the system specs of self |
TypeError
|
If block is an instance of class SequenceBaseBlock |
Source code in cmrseq/core/_sequence.py
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 | |
rename_blocks ¶
rename_blocks(old_names: List[str], new_names: List[str])
Renames blocks and updates block lookup map
Source code in cmrseq/core/_sequence.py
360 361 362 363 364 365 366 367 | |
remove_block ¶
remove_block(block_name: str)
Removes block from internal lookup
Source code in cmrseq/core/_sequence.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
append ¶
append(
other: Union[Sequence, SequenceBaseBlock],
copy: bool = True,
end_time: Quantity = None,
) -> None
If both system specifications match, copies all blocks from other, shifts them by the
current end time of this sequence intance (plus an additional delay according to ADC/RF -
dead times and RF-ring-down time) and adds the blocks to itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Union[Sequence, SequenceBaseBlock]
|
Sequence or block to be added to the sequence |
required |
copy
|
bool
|
if true copies the other sequence object |
True
|
end_time
|
Quantity
|
|
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If other fails to validate using the system specs of self |
Source code in cmrseq/core/_sequence.py
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 | |
fast_extend ¶
fast_extend(other, copy: bool = True)
Faster alternative to extend() that: - preserves the original extend() semantics (other is a sequence of Sequence or individual SequenceBaseBlock items), - keeps a tqdm progress bar, - avoids calling self.append() per-sequence (which causes growing costs), - does a single bulk extend of self._blocks and a single bulk update of lookups and o-matrix dictionaries.
NOTE: This directly manipulates internals (_blocks, _block_lookup, etc.) for speed.
Source code in cmrseq/core/_sequence.py
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 | |
extend ¶
extend(
other: Sequence[Union[Sequence, SequenceBaseBlock]],
copy: bool = True,
) -> None
If both system specifications match, copies all blocks from other shifts them by own
tmax and adds the blocks to own collection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Sequence[Union[Sequence, SequenceBaseBlock]]
|
ListSequence or block to be added to the sequence |
required |
copy
|
bool
|
if true copies the other sequence object |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If other fails to validate using the system specs of self |
Source code in cmrseq/core/_sequence.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
get_block ¶
get_block(
block_name: Union[str, Iterable[str]] = None,
partial_string_match: Union[str, Iterable[str]] = None,
regular_expression: Union[str, Iterable[str]] = None,
typedef=None,
invert_pattern: bool = False,
sort_by: str = None,
) -> Union[SequenceBaseBlock, List[SequenceBaseBlock]]
Returns reference to the block whose member name matches the specified argument.
If no block with given name is present in the sequence, it returns None
.. note::
Checks which keyword argument to use from left to right as specified in the signature.
If multiple are specified uses only the first one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_name
|
Union[str, Iterable[str]]
|
String or iterable of strings exactly matching a set of blocks contained in the sequence |
None
|
partial_string_match
|
Union[str, Iterable[str]]
|
str or iterable of strings that specify partial string matches. All blocks partially matching at least one are returned. |
None
|
regular_expression
|
Union[str, Iterable[str]]
|
str or iterable of strings containing regular expressions that are matched against the block-names. All blocks, matching at least one of the given expressions are returned. |
None
|
typedef
|
type defintion (e.g. cmrseq.bausteine.ADC) |
None
|
|
invert_pattern
|
bool
|
if True, all blocks except of the pattern-matched names are returned |
False
|
sort_by
|
str
|
from [None, start, end] returns the list of blocks sorted according to their start or end time, is ignored if blocks are retrieved by name |
None
|
Returns:
| Type | Description |
|---|---|
SequenceBaseBlock or List of SequenceBaseBlocks depending on the specified argument
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no keyword argument is specified. |
Source code in cmrseq/core/_sequence.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 | |
register_omatrix ¶
register_omatrix(
matrix: OMatrix,
gradients: list[Union[str, Gradient]] = None,
rf_pulses: list[
tuple[
Union[str, RFPulse],
Union[str, TrapezoidalGradient],
]
] = None,
)
Updates the mapping of orientation matrix objects for given Gradient blocks and rf_pulses associated with a slice-selection gradients
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
OMatrix
|
cmrseq.OMatrix object |
required |
gradients
|
list[Union[str, Gradient]]
|
List of unique block names or instances of type Gradient to be registered with the given o-matrix |
None
|
rf_pulses
|
list[tuple[Union[str, RFPulse], Union[str, TrapezoidalGradient]]]
|
List of tuples containing block-names or instances of (RF-pulse, TrapezoidalGradients), to be registered with the orientation matrix |
None
|
Source code in cmrseq/core/_sequence.py
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | |
update_global_omatrix ¶
update_global_omatrix(
matrix: OMatrix,
overwrite: bool = False,
warn_assign: bool = False,
) -> None
Update the sequence-level orientation matrix.
Global orientation matrices must not contain a positional shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
OMatrix
|
Orientation matrix to assign, or |
required |
overwrite
|
bool
|
If |
False
|
warn_assign
|
bool
|
If |
False
|
Source code in cmrseq/core/_sequence.py
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | |
shift_in_time ¶
shift_in_time(shift: Quantity) -> None
Shifts all blocks contained in the sequence object by the specified time
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shift
|
Quantity
|
Quantity of dimesion time |
required |
Source code in cmrseq/core/_sequence.py
864 865 866 867 868 869 870 871 872 873 | |
time_reverse ¶
time_reverse() -> None
Reverses the sequence in time
Source code in cmrseq/core/_sequence.py
875 876 877 878 879 880 881 | |
copy ¶
copy() -> Sequence
Source code in cmrseq/core/_sequence.py
1001 1002 | |
partial_sequence ¶
partial_sequence(
copy_blocks: bool,
partial_string_match: Union[str, Iterable[str]] = None,
regular_expression: Union[str, Iterable[str]] = None,
invert_pattern: bool = False,
**kwargs,
) -> Sequence
Returns a cmrseq.Sequence object containing references or deep-copies of all blocks matched either with partial-string-match or regular expressions specified as keyword argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
copy_blocks
|
bool
|
if True, creates deep-copies of matched blocks. |
required |
partial_string_match
|
Union[str, Iterable[str]]
|
str or iterable of strings that specify partial string matches. All blocks partially matching at least one are returned. |
None
|
regular_expression
|
Union[str, Iterable[str]]
|
str or iterable of strings containing regular expressions that are matched against the block-names. All blocks, matching at least one of the given expressions are returned. |
None
|
invert_pattern
|
bool
|
if True, all blocks except of the pattern-matched names are returned |
False
|
Returns:
| Type | Description |
|---|---|
Sequence object
|
|
Source code in cmrseq/core/_sequence.py
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
gradients_to_grid ¶
gradients_to_grid(
start_time: Quantity = None,
) -> Tuple[np.ndarray, np.ndarray]
Grids gradient definitions of all blocks contained in the sequence, on a joint time grid from the minimal to maximal value in single time-points definitions with a step-length defined in system_specs.grad_raster_time. If gradients occur at the same time on the same channel, they are added.
Returns:
| Type | Description |
|---|---|
(np.ndarray, np.ndarray) of shape (t, ) containing the time-grid and (3 [gx, gy, gz], t) containing the waveform definition in ms and mT/m returns (None, None) if no gradients are contained in the sequence
|
|
Source code in cmrseq/core/_sequence.py
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 | |
combined_gradients ¶
combined_gradients() -> Tuple[np.ndarray, np.ndarray]
Combines the gradient definitions of all blocks contained in the sequence, into a joint single definition. The joint time-points are defined by the set of unique time-points of all combined blocks. If gradients occur at the same time on the same channel, they are added.
Returns:
| Type | Description |
|---|---|
(np.ndarray, np.ndarray) of shape (t, ) containing the time-points and (3 [gx, gy, gz], t) containing the waveform definition in ms and mT/m returns (None, None) if no gradients are contained in the sequence
|
|
Source code in cmrseq/core/_sequence.py
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
combined_rf ¶
combined_rf() -> Tuple[np.ndarray, np.ndarray]
Combines the rf-definitions of all blocks contained in the sequence, into a joint single definition. The joint time-points are defined by the set of unique time-points of all combined blocks. If rf occur at the same time they are added.
Returns:
| Type | Description |
|---|---|
(np.ndarray, np.ndarray) of shape (t, ) containing the time-points and (t, ) containing the complex RF-waveform definition in ms and uT
|
|
Source code in cmrseq/core/_sequence.py
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | |
rf_to_grid ¶
rf_to_grid() -> Tuple[np.ndarray, np.ndarray]
Grids RF-definitions of all blocks contained in the sequence, on a joint time grid from the minimal to maximal value in single time-points definitions with a step-length defined in system_specs.rf_raster_time.
If RF-pulses occur at the same time on the same channel, they are added.
Returns:
| Type | Description |
|---|---|
(np.ndarray, np.ndarray) of shape (1, t) containing the time-grid and (1, t) containing the complex RF amplitude
|
|
Source code in cmrseq/core/_sequence.py
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 | |
combined_adc ¶
combined_adc() -> Tuple[np.ndarray, np.ndarray]
Combines all ADC-type blocks contained in the sequence, on a joint time grid.
Note: The binary event channel of the returned array is technically not needed but adheres to the signature of dense gridding
Returns:
| Type | Description |
|---|---|
Array of shape (t, ) containing the time-points Array of shape (t, 2) containing binary event and phase
|
|
Source code in cmrseq/core/_sequence.py
1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 | |
adc_to_grid ¶
adc_to_grid(
force_raster: bool = False,
) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
Grids the ADC-Events of all blocks contained in the sequence as boolean 1D mask along with the resulting time-grid. Additionally, the start and end points of the all adc-blocks are returned. The definition of start/end differ for force_gradient_raster True/False
Boolean mask explanation:
- *force_raster* == `False`
events that are not defined on the grid, are inserted into the
time-raster resulting in a non-uniform time definition.
The boolean values of the newly inserted points are set to 1.
- *force_raster* == `True`
for events that are not defined on the grid the boolean values
of the interval borders on gradient raster time are set to 1.
For events that are already on the grid, the corresponding single
index is set 1.
Start/End - definition:
- *force_raster* == `False`:
the exact time of first/last event per block is returned.
- *force_raster* == `True`:
The returned start/end times correspond to the beginning and end of the plateau
of a trapezoidal gradient played out during the adc-events (addition of dwell-time).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_raster
|
bool
|
bool defaults to True |
False
|
Returns:
| Type | Description |
|---|---|
Tuple(np.array, np.array, np.array) (t, ) containing time-values (t, ) containing values of 0 or 1, indicating where the adc is active (t, ) containing the adc_phase in radians (#adc_blocks, 2) where (:, 0) contains the indices of the start time of the adc-block and (:, 1) the end time correspondingly.
|
|
Source code in cmrseq/core/_sequence.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 | |
calculate_kspace ¶
calculate_kspace() -> Tuple[
np.ndarray, np.ndarray, np.ndarray
]
Evaluates the k-space trajectory of the sequence.
Note: All RF-pulses with a smaller flip-angle other than 180° are assumed to be excitation pulses. 180° - Refocusing pulses result in a complex conjugation of the trajectory. Consecutive excitation pulses are handled by starting from k-space center again.
Returns:
| Type | Description |
|---|---|
Tuple of arrays containing:
|
|
Source code in cmrseq/core/_sequence.py
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 | |
calculate_moment ¶
calculate_moment(
moment: int = 0,
center_time: Quantity = Quantity(0.0, "ms"),
end_time: Quantity = None,
start_time: Quantity = None,
) -> Quantity
Calculates gradient moments about a given center point
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moment
|
int
|
int of desired moment number |
0
|
center_time
|
Quantity
|
Quantity of center time to calculate moment about, defaults to t=0 |
Quantity(0.0, 'ms')
|
end_time
|
Quantity
|
Time to calculate moment up to, default is end of sequence |
None
|
start_time
|
Quantity
|
Time to calculate moment from, default is start of sequence |
None
|
Returns:
| Type | Description |
|---|---|
Quantity[Mx, My, Mz]
|
|
Source code in cmrseq/core/_sequence.py
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 | |
SystemSpec ¶
SystemSpec(
gamma: Quantity = Quantity(42.576, "MHz/T"),
grad_raster_time: Quantity = Quantity(0.01, "ms"),
max_grad: Quantity = Quantity(40, "mT/m"),
max_slew: Quantity = Quantity(120, "mT/m/ms"),
rf_peak_power: Quantity = Quantity(30, "uT"),
rf_raster_time: Quantity = Quantity(0.01, "ms"),
rf_dead_time: Quantity = Quantity(0.0, "ms"),
rf_ringdown_time: Quantity = Quantity(0.0, "ms"),
rf_lead_time: Quantity = Quantity(0.0, "ms"),
adc_raster_time: Quantity = Quantity(100, "ns"),
adc_dead_time: Quantity = Quantity(0.0, "ms"),
b0: Quantity = Quantity(1.5, "T"),
enable_simulatenous_trasmit_receive: bool = False,
)
Bundles the system limit specifications, meant to be passed as object for creating sequences and building blocks.
In addition to store all relevant system specifications this class implements the methods to calculate quantities that depend on these limits (e.g. get_shortest_rise_time).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gamma
|
Quantity
|
Gyromagnetic Ratio of the target nucleus with dimensions equivalent to[MHz / T] |
Quantity(42.576, 'MHz/T')
|
grad_raster_time
|
Quantity
|
Raster time for gradient definitions with dimension [Time] |
Quantity(0.01, 'ms')
|
max_grad
|
Quantity
|
Maximal allowed gradient strength for combined gradient channels in dimension equivalent to [mT/m] |
Quantity(40, 'mT/m')
|
max_slew
|
Quantity
|
Maximal allow gradient slew-rate for combined gradient channels in dimensions equivalent to [mT/m/ms] |
Quantity(120, 'mT/m/ms')
|
rf_peak_power
|
Quantity
|
Maximal allowed peak rf power defined as B1 field strength with dimensions equivalent to [uT] |
Quantity(30, 'uT')
|
rf_raster_time
|
Quantity
|
Raster time for radio-frequency waveform definitions with dimension [Time] |
Quantity(0.01, 'ms')
|
rf_dead_time
|
Quantity
|
Minimum time between consecutive RF-pulses, due to switching delays in the transmit chain. |
Quantity(0.0, 'ms')
|
rf_ringdown_time
|
Quantity
|
Defines the minimum delay between a RF-pulse and and acquisition block. Corresponds to the time scale of self induced currents in the transmit coil, which could result in receive chain damages and sampling distortion. |
Quantity(0.0, 'ms')
|
rf_lead_time
|
Quantity
|
Defines the minimum delay between an acquisition block and a subsequent RF-pulse. This corresponds to the delay caused by switching from receive to transmit. |
Quantity(0.0, 'ms')
|
adc_raster_time
|
Quantity
|
Raster time for signal sampling definitions with dimension [Time] |
Quantity(100, 'ns')
|
adc_dead_time
|
Quantity
|
Minimum time between consecutive Sampling (ADC) blocks, due to switching delays in the receive chain. |
Quantity(0.0, 'ms')
|
b0
|
Quantity
|
Static field strength in dimension of [T] |
Quantity(1.5, 'T')
|
enable_simulatenous_trasmit_receive
|
bool
|
System flag for sequence validation. If true, RF and ADC blocks are allowed to be occur simultaneously (ignoring) rf_ringdown_time in validation. |
False
|
Source code in cmrseq/core/_system.py
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 | |
enable_simulatenous_trasmit_receive
instance-attribute
¶
enable_simulatenous_trasmit_receive: bool = (
enable_simulatenous_trasmit_receive
)
minmax_risetime
property
¶
minmax_risetime
Returns the minimum rise time to reach the maximum gradient amplitude
get_shortest_rise_time ¶
get_shortest_rise_time(
delta_amplitude: Quantity,
) -> Quantity
Calculates the shortest ramp duration for the specified amplitude difference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delta_amplitude
|
Quantity
|
Quantity[mT/m] |
required |
Returns:
| Type | Description |
|---|---|
delta t Quantity[ms] which is guaranteed to be a multiple of grad_raster_time
|
|
Source code in cmrseq/core/_system.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
get_shortest_gradient ¶
get_shortest_gradient(
area: Quantity,
) -> Tuple[Quantity, Quantity, Quantity]
Calculates the shortest gradient of a given area, obeying system limits
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
Quantity
|
Quantity[mT/m*s] |
required |
Returns:
| Type | Description |
|---|---|
Tuple(amplitude, rise time, flat time)
|
|
Source code in cmrseq/core/_system.py
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 | |
get_fastest_kspace_traverse ¶
get_fastest_kspace_traverse(
k_space_vector: Quantity,
) -> Tuple[Quantity, Quantity, Quantity]
Computes the shortest gradient, resulting in a k-space traverse along the specified vector.
.. note:
This assumes the isotropic gradient limits, hence the norm of the gradient
vector adhering to the system limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k_space_vector
|
Quantity
|
(3, ) for X, Y, Z |
required |
Returns:
| Type | Description |
|---|---|
Amplitude, ramp- and flat-duration of the resulting gradient pulse
|
|
Source code in cmrseq/core/_system.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
time_to_raster ¶
time_to_raster(
time: Quantity, raster: str = "grad"
) -> Quantity
Calculates the time projected onto the either gradient or rf raster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Quantity
|
Quantity[s] |
required |
raster
|
str
|
from [grad, rd] |
'grad'
|
Returns:
| Type | Description |
|---|---|
Quantity[ms]
|
|
Source code in cmrseq/core/_system.py
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 | |
is_on_raster ¶
is_on_raster(
time: Quantity, raster: str
) -> (bool, Quantity)
Checks is given time is on raster. Returns a bool and the numerical difference to the next valid grid point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Quantity
|
|
required |
raster
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
object
|
|
Source code in cmrseq/core/_system.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
modified_copy ¶
modified_copy(**kwargs) -> SystemSpec
Copies system specsifications and modifies the specified attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kwargs
|
keyword argument according to instantiation, with the updated value |
{}
|
Returns:
| Type | Description |
|---|---|
SystemSpecs
|
|
Source code in cmrseq/core/_system.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
OMatrix ¶
OMatrix(
position: Quantity,
slice_normal: ndarray,
readout_direction: ndarray,
system_specs: SystemSpec,
)
Captures the transformation of a slice coordinate system (Readout, Phase encoding, Slice Normal) to XYZ scanner coordinates.
When applied to Gradient and corresponding RFPulse objects, a transformed definition of the waveforms is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Quantity
|
Scalar length value for a positional offset along the slice-normal direction |
required |
slice_normal
|
ndarray
|
(3, ) 3D vector containing the slice normal |
required |
readout_direction
|
ndarray
|
(3, ) 3D vector containing the readout direction |
required |
system_specs
|
SystemSpec
|
|
required |
Raises:
| Type | Description |
|---|---|
BuildingBlockArgumentError
|
if slice_normal and readout_direction are not orthogonal |
Source code in cmrseq/core/_omatrix.py
51 52 53 54 55 56 57 58 59 60 61 | |
readout_direction
property
writable
¶
readout_direction
Return read-only view of the readout direction
apply ¶
apply(
block: Union[
Gradient, Tuple[RFPulse, TrapezoidalGradient]
],
) -> Tuple[Quantity, Quantity]
Applies the spatial transformation from Slice-coordinates to XYZ-coordinates to the specified block.
For a Gradient block this means a rotation of the vector defined as the gradient channels [gx, gy, gz], where the total gradient area on all channels is preserved. The returned values are the time-points (t, ) and transformed gradient-waveform (3, t).
For a RFPulse the application of the OMatrix only makes sense in presence of a corresponding Trapezoidal gradient defining the slice-selective excitation. If given a tuple containing (RFPulse, TrapezoidalGradient), the frequency-modulated RF waveform is returned as time-points (t, ) and complex-wf (t, ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
Union[Gradient, Tuple[RFPulse, TrapezoidalGradient]]
|
Either an instance of a Gradient, or a tuple containing an RFPulse as well as a corresponding TrapezoidalGradient object defining the slice-selective excitation |
required |
Source code in cmrseq/core/_omatrix.py
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 | |
update ¶
update(
position: Quantity = None,
slice_normal: ndarray = None,
readout_direction: ndarray = None,
) -> None
Updates all specified properties of the OMatrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Quantity
|
Scalar length value for a positional offset along the slice-normal direction |
None
|
slice_normal
|
ndarray
|
(3, ) 3D vector containing the slice normal |
None
|
readout_direction
|
ndarray
|
(3, ) 3D vector containing the readout direction |
None
|
Returns:
| Type | Description |
|---|---|
object
|
|
Source code in cmrseq/core/_omatrix.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
merge_OMatrices
staticmethod
¶
merge_OMatrices(
omatrices: List[OMatrix],
allow_first_shift: bool = False,
) -> OMatrix
Combine a list of orientation matrices into one matrix.
The first entry is applied first. By default only the last matrix may contain a positional
shift. Set allow_first_shift=True to instead allow only the first matrix to contain the
positional shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omatrices
|
List[OMatrix]
|
Orientation matrices to merge. |
required |
allow_first_shift
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
OMatrix
|
Merged orientation matrix. |
Source code in cmrseq/core/_omatrix.py
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 | |
Label ¶
Label(
name: Union[str, List[str]] = None,
value: Union[int, List[int]] = None,
)
Container for sequence labels and Pulseq extension metadata.
Labels are stored with ISMRMRD-style names and are attached to sequence blocks that support a
label attribute, currently RF and ADC blocks. When a sequence is exported to Pulseq,
standard counters are written as LABELSET/LABELINC extensions. The special labels
triggerWait and triggerSend are written as Pulseq trigger extensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Union[str, List[str]]
|
Label name, or list of label names, to initialize. |
None
|
value
|
Union[int, List[int]]
|
Integer label value, or list of values matching |
None
|
Source code in cmrseq/core/_labels.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
setLabels ¶
setLabels(
name: Union[str, List[str]],
value: Union[int, List[int]],
)
Set one or more label values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Union[str, List[str]]
|
Label name, or list of names. |
required |
value
|
Union[int, List[int]]
|
Integer label value, or list of values matching |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any label name is not supported. |
Source code in cmrseq/core/_labels.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
clearLabels ¶
clearLabels(name: Union[str, List[str]])
Clear one or more labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Union[str, List[str]]
|
Label name, list of names, or |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any label name is not supported. |
Source code in cmrseq/core/_labels.py
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 | |
getActiveLabels ¶
getActiveLabels()
Return labels with non-None values.
Returns:
| Type | Description |
|---|---|
dict
|
Mapping from active label name to integer value. |
Source code in cmrseq/core/_labels.py
118 119 120 121 122 123 124 125 126 | |
getValue ¶
getValue(name: str)
Return the value for one label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Label name. |
required |
Returns:
| Type | Description |
|---|---|
int or None
|
Current label value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in cmrseq/core/_labels.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
SequenceBaseBlock ¶
SequenceBaseBlock(
system_specs: SystemSpec,
name: str,
snap_to_raster: bool = False,
)
Bases: SimpleNamespace
Base class for all building blocks, defining the abstract interface for generic interaction with blocks.
All subclases must implent the abstract methods, and all general methods on blocks must only access the implemented methods when no sub-class type check is performed.
Furthermore, all subclasses must call the base-class constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system_specs
|
SystemSpec
|
|
required |
name
|
str
|
|
required |
snap_to_raster
|
bool
|
|
False
|
Must be called as last line of subclass.init
Source code in cmrseq/core/bausteine/_base.py
34 35 36 37 38 39 40 | |
tmin
property
¶
tmin: Quantity
Calculates the smallest time occuring in all contained definitions.
Returns:
| Type | Description |
|---|---|
Quantity[time]
|
|
tmax
property
¶
tmax: Quantity
Calculates the largest time occuring in all contained definitions.
Returns:
| Type | Description |
|---|---|
Quantity[time]
|
|
duration
property
¶
duration: Quantity
Calculates the duration of the block, which is defined as tmax - tmin.
copy ¶
copy() -> SequenceBaseBlock
Returns a deep copied building block object
Source code in cmrseq/core/bausteine/_base.py
48 49 50 | |
snap_to_raster
abstractmethod
¶
snap_to_raster(system_specs: SystemSpec) -> None
Source code in cmrseq/core/bausteine/_base.py
52 53 54 | |
validate
abstractmethod
¶
validate(system_specs: SystemSpec) -> None
Should raise a ValueError if subclass logic is not met by definition
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system_specs
|
SystemSpec
|
|
required |
Returns:
| Type | Description |
|---|---|
object
|
|
Source code in cmrseq/core/bausteine/_base.py
59 60 61 62 63 64 65 66 67 68 69 70 | |
flip
abstractmethod
¶
flip(time_flip: Quantity = None)
Flips block around specified time point
Source code in cmrseq/core/bausteine/_base.py
95 96 97 98 | |
shift
abstractmethod
¶
shift(time_shift: Quantity) -> None
Shifts block in time
Source code in cmrseq/core/bausteine/_base.py
100 101 102 103 | |