diff --git a/src/pypulseq/Sequence/block.py b/src/pypulseq/Sequence/block.py index 46f9f0af..9b9d0da2 100644 --- a/src/pypulseq/Sequence/block.py +++ b/src/pypulseq/Sequence/block.py @@ -121,7 +121,7 @@ def set_block(self, block_index: int, *args: SimpleNamespace) -> None: if hasattr(event, 'id'): adc_id = event.id else: - adc_id = register_adc_event(self, event) + adc_id, _ = register_adc_event(self, event) new_block[5] = adc_id duration = max(duration, event.delay + event.num_samples * event.dwell + event.dead_time) @@ -318,6 +318,8 @@ def get_block(self, block_index: int) -> SimpleNamespace: else: block.rf = self.rf_from_lib_data(self.rf_library.data[event_ind[1]], 'u') # Undefined type/use + # TODO: add optional rf ID from raw_block + # Gradients grad_channels = ['gx', 'gy', 'gz'] for i in range(len(grad_channels)): @@ -371,18 +373,31 @@ def get_block(self, block_index: int) -> SimpleNamespace: # ADC if event_ind[5] > 0: lib_data = self.adc_library.data[event_ind[5]] + shape_id_phase_modulation = lib_data[-2] + if shape_id_phase_modulation: + shape_data = self.shape_library.data[shape_id_phase_modulation] + compressed = SimpleNamespace() + compressed.num_samples = shape_data[0] + compressed.data = shape_data[1:] + phase_shape = decompress_shape(compressed) + else: + phase_shape = np.array([], dtype=float) adc = SimpleNamespace() - ( - adc.num_samples, - adc.dwell, - adc.delay, - adc.freq_offset, - adc.phase_offset, - adc.dead_time, - ) = [lib_data[x] for x in range(6)] + adc.num_samples = lib_data[0] + adc.dwell = lib_data[1] + adc.delay = lib_data[2] + adc.freq_ppm = lib_data[3] + adc.phase_ppm = lib_data[4] + adc.freq_offset = lib_data[5] + adc.phase_offset = lib_data[6] + adc.phase_modulation = phase_shape + adc.dead_time = self.system.adc_dead_time adc.num_samples = int(adc.num_samples) adc.type = 'adc' + + # TODO: add optional adc ID from raw_block + block.adc = adc # Triggers @@ -449,7 +464,7 @@ def get_block(self, block_index: int) -> SimpleNamespace: return block -def register_adc_event(self, event: EventLibrary) -> int: +def register_adc_event(self, event: EventLibrary) -> Tuple[int, List[int]]: """ Parameters @@ -459,25 +474,52 @@ def register_adc_event(self, event: EventLibrary) -> int: Returns ------- - int - ID of registered ADC event. + int, [int, ...] + ID of registered RF event, list of shape IDs """ + surely_new = False + + # Handle phase modulation + if not hasattr(event, 'phase_modulation') or event.phase_modulation is None or len(event.phase_modulation) == 0: + shape_id = 0 + else: + if hasattr(event, 'shape_id'): + shape_id = event.shape_id + else: + phase_shape = compress_shape(np.asarray(event.phase_modulation).flatten()) + shape_data = np.concatenate(([phase_shape.num_samples], phase_shape.data)) + shape_id, shape_found = self.shape_library.find_or_insert(shape_data) + if not shape_found: + surely_new = True + + # Construct the ADC event data data = ( event.num_samples, event.dwell, - event.delay, + max(event.delay, event.dead_time), + event.freq_ppm, + event.phase_ppm, event.freq_offset, event.phase_offset, + shape_id, event.dead_time, ) - adc_id, found = self.adc_library.find_or_insert(new_data=data) - # Clear block cache because ADC was overwritten - # TODO: Could find only the blocks that are affected by the changes - if self.use_block_cache and found: - self.block_cache.clear() + # Insert or find/insert into libraryAdd commentMore actions + if surely_new: + adc_id = self.adc_library.insert(0, data) + else: + adc_id, found = self.adc_library.find_or_insert(data) + + # Clear block cache if overwritten + if self.use_block_cache and found: + self.block_cache.clear() + + # Optional mapping + if hasattr(event, 'name'): + self.adc_id_to_name_map[adc_id] = event.name - return adc_id + return adc_id, shape_id def register_control_event(self, event: SimpleNamespace) -> int: diff --git a/src/pypulseq/Sequence/read_seq.py b/src/pypulseq/Sequence/read_seq.py index 26302ce5..6a160289 100644 --- a/src/pypulseq/Sequence/read_seq.py +++ b/src/pypulseq/Sequence/read_seq.py @@ -162,9 +162,17 @@ def read(self, path: str, detect_rf_use: bool = False, remove_duplicates: bool = else: self.grad_library = __read_events(input_file, (1, 1e-6, 1e-6, 1e-6, 1e-6), 't', self.grad_library) elif section == '[ADC]': - self.adc_library = __read_events( - input_file, (1, 1e-9, 1e-6, 1, 1), event_library=self.adc_library, append=self.system.adc_dead_time - ) + if version_combined >= 1005000: # 1.5.x format + self.adc_library = __read_events( + input_file, + (1, 1e-9, 1e-6, 1, 1, 1, 1, 1), + event_library=self.adc_library, + append=self.system.adc_dead_time, + ) + else: # 1.4.x format and below + self.adc_library = __read_events( + input_file, (1, 1e-9, 1e-6, 1, 1), event_library=self.adc_library, append=self.system.adc_dead_time + ) elif section == '[DELAYS]': if version_combined >= 1004000: raise RuntimeError('Pulseq file revision 1.4.0 and above MUST NOT contain [DELAYS] section') diff --git a/src/pypulseq/Sequence/sequence.py b/src/pypulseq/Sequence/sequence.py index 7ced795e..259b5cd6 100644 --- a/src/pypulseq/Sequence/sequence.py +++ b/src/pypulseq/Sequence/sequence.py @@ -93,6 +93,7 @@ def __init__(self, system: Union[Opts, None] = None, use_block_cache: bool = Tru self.signature_file = '' self.signature_value = '' self.rf_id_to_name_map = {} + self.adc_id_to_name_map = {} self.block_durations = {} self.extension_numeric_idx = [] @@ -1224,7 +1225,7 @@ def remove_duplicates(self, in_place: bool = False) -> Self: seq_copy.block_events[block_id][1] = mapping[seq_copy.block_events[block_id][1]] # Filter duplicates in ADC library - seq_copy.adc_library, mapping = seq_copy.adc_library.remove_duplicates((0, -9, -6, 6, 6, 6)) + seq_copy.adc_library, mapping = seq_copy.adc_library.remove_duplicates((0, -9, -6, 6, 6, 6, 6, 6, 6)) # Remap ADC event IDs for block_id in seq_copy.block_events: diff --git a/src/pypulseq/Sequence/write_seq.py b/src/pypulseq/Sequence/write_seq.py index ebcf45b7..48f661c2 100644 --- a/src/pypulseq/Sequence/write_seq.py +++ b/src/pypulseq/Sequence/write_seq.py @@ -162,12 +162,12 @@ def write(self, file_name: Union[str, Path], create_signature, remove_duplicates if len(self.adc_library.data) != 0: output_file.write('# Format of ADC events:\n') - output_file.write('# id num dwell delay freq phase\n') - output_file.write('# .. .. ns us Hz rad\n') + output_file.write('# id num dwell delay freqPPM phasePPM freq phase phase_id\n') + output_file.write('# .. .. ns us ppm rad/MHz Hz rad ..\n') output_file.write('[ADC]\n') - id_format_str = '{:.0f} {:.0f} {:.0f} {:.0f} {:g} {:g}\n' # Refer lines 20-21 + id_format_str = '{:.0f} {:.0f} {:.0f} {:.0f} {:g} {:g} {:g} {:g} {:.0f}\n' # Refer lines 20-21 for k in self.adc_library.data: - data = np.multiply(self.adc_library.data[k][0:5], [1, 1e9, 1e6, 1, 1]) + data = np.multiply(self.adc_library.data[k][0:8], [1, 1e9, 1e6, 1, 1, 1, 1, 1]) s = id_format_str.format(k, *data) output_file.write(s) output_file.write('\n') diff --git a/src/pypulseq/make_adc.py b/src/pypulseq/make_adc.py index a7bb6707..231386b1 100644 --- a/src/pypulseq/make_adc.py +++ b/src/pypulseq/make_adc.py @@ -4,6 +4,8 @@ from typing import List, Optional, Tuple, Union from warnings import warn +import numpy as np + from pypulseq.opts import Opts from pypulseq.utils.tracing import trace, trace_enabled @@ -16,6 +18,9 @@ def make_adc( freq_offset: float = 0, phase_offset: float = 0, system: Union[Opts, None] = None, + freq_ppm: float = 0, + phase_ppm: float = 0, + phase_modulation: np.ndarray = None, ) -> SimpleNamespace: """ Create an ADC readout event. @@ -36,6 +41,13 @@ def make_adc( Frequency offset of ADC readout event. phase_offset : float, default=0 Phase offset of ADC readout event. + freq_ppm : float, default=0 + PPM frequency offset of ADC readout event. + phase_ppm : float, default=0 + PPM phase offset of ADC readout event. + phase_modulation : numpy.ndarray, default=None + Phase modulation array for FOV shifting. + If provided, it must have `num_samples` number of samples. Returns ------- @@ -57,11 +69,17 @@ def make_adc( adc.delay = delay adc.freq_offset = freq_offset adc.phase_offset = phase_offset + adc.freq_ppm = freq_ppm + adc.phase_ppm = phase_ppm adc.dead_time = system.adc_dead_time if (dwell == 0 and duration == 0) or (dwell > 0 and duration > 0): raise ValueError('Either dwell or duration must be defined') + if phase_modulation is not None and len(phase_modulation) != num_samples: + raise ValueError('ADC Phase modulation vector must have the same length as the number of samples') + adc.phase_modulation = phase_modulation + if duration > 0: adc.dwell = duration / num_samples diff --git a/tests/expected_output/seq2.seq b/tests/expected_output/seq2.seq index c77300cd..f5dd7626 100644 --- a/tests/expected_output/seq2.seq +++ b/tests/expected_output/seq2.seq @@ -41,10 +41,10 @@ TotalDuration 0.0142 4 102459 240 9520 240 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 100 100000 0 0 0 +1 100 100000 0 0 0 0 0 0 # Sequence Shapes [SHAPES] @@ -70,4 +70,4 @@ num_samples 2 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash 7e8bfc27296bebb59901d7f6c2595b75 +Hash 84be8c860fdbebf68977a6779ae84cb4 diff --git a/tests/expected_output/seq3.seq b/tests/expected_output/seq3.seq index ed9bfc64..7db723a6 100644 --- a/tests/expected_output/seq3.seq +++ b/tests/expected_output/seq3.seq @@ -92,10 +92,10 @@ TotalDuration 0.12722 12 1.66667e+06 240 0 240 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 100 100000 0 0 0 +1 100 100000 0 0 0 0 0 0 # Format of extension lists: # id type ref next_id @@ -133,4 +133,4 @@ num_samples 2 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash 4ad305ffb67000bc974f15d48411ce1c +Hash 890a2a51ec2754a0007f5e1bda944975 diff --git a/tests/expected_output/seq4.seq b/tests/expected_output/seq4.seq index 889601bc..95b432d5 100644 --- a/tests/expected_output/seq4.seq +++ b/tests/expected_output/seq4.seq @@ -92,10 +92,10 @@ TotalDuration 0.12722 12 1.66667e+06 240 0 240 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 100 100000 0 0 0 +1 100 100000 0 0 0 0 0 0 # Format of extension lists: # id type ref next_id @@ -151,4 +151,4 @@ num_samples 2 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash 5a1ef322af8969e98bb7ae996d630839 +Hash 74a5b1a80817326ed54758f9cbe8c446 diff --git a/tests/expected_output/write_epi.seq b/tests/expected_output/write_epi.seq index 999e836a..c0dcd1a1 100644 --- a/tests/expected_output/write_epi.seq +++ b/tests/expected_output/write_epi.seq @@ -429,10 +429,10 @@ TotalDuration 0.15405 7 -1.13636e+06 210 260 210 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 64 4000 214 0 0 +1 64 4000 214 0 0 0 0 0 # Sequence Shapes [SHAPES] @@ -3461,4 +3461,4 @@ num_samples 3000 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash 28216862a9ddf0aee4d31a5fbecc4bb6 +Hash e6dba7be0f6647ea5e8ceb85c5afe0ac diff --git a/tests/expected_output/write_epi_label.seq b/tests/expected_output/write_epi_label.seq index 6ad2bebf..1b2ae8a9 100644 --- a/tests/expected_output/write_epi_label.seq +++ b/tests/expected_output/write_epi_label.seq @@ -5680,10 +5680,10 @@ TotalDuration 4.32868 8 1.35307e+06 250 610 250 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 64 4000 214 0 0 +1 64 4000 214 0 0 0 0 0 # Format of extension lists: # id type ref next_id @@ -8763,4 +8763,4 @@ num_samples 3000 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash 7094537c10608235728fd41a2c43ec07 +Hash b2950251a04185feafc64b2bb9101dca diff --git a/tests/expected_output/write_epi_se.seq b/tests/expected_output/write_epi_se.seq index 3d58d8fe..e4d26327 100644 --- a/tests/expected_output/write_epi_se.seq +++ b/tests/expected_output/write_epi_se.seq @@ -175,10 +175,10 @@ TotalDuration 0.08315 8 -781250 150 320 150 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 64 5000 150 0 0 +1 64 5000 150 0 0 0 0 0 # Sequence Shapes [SHAPES] @@ -3222,4 +3222,4 @@ num_samples 2 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash cc67cded0ce3d84780a1d526cd81d25c +Hash fa0b012993045142ae20c0ec821d5ad7 diff --git a/tests/expected_output/write_gre.seq b/tests/expected_output/write_gre.seq index 48090d6d..a26c5c50 100644 --- a/tests/expected_output/write_gre.seq +++ b/tests/expected_output/write_gre.seq @@ -444,33 +444,33 @@ TotalDuration 0.768 71 0 10 980 10 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 64 50000 20 0 0 -2 64 50000 20 0 2.04204 -3 64 50000 20 0 6.12611 -4 64 50000 20 0 5.96903 -5 64 50000 20 0 1.5708 -6 64 50000 20 0 5.49779 -7 64 50000 20 0 5.18363 -8 64 50000 20 0 0.628319 -9 64 50000 20 0 4.39823 -10 64 50000 20 0 3.92699 -11 64 50000 20 0 2.82743 -12 64 50000 20 0 2.19911 -13 64 50000 20 0 3.61283 -14 64 50000 20 0 0.785398 -15 64 50000 20 0 1.25664 -16 64 50000 20 0 4.55531 -17 64 50000 20 0 4.71239 -18 64 50000 20 0 0.471239 -19 64 50000 20 0 1.41372 -20 64 50000 20 0 3.14159 -21 64 50000 20 0 5.34071 -22 64 50000 20 0 2.35619 -23 64 50000 20 0 3.76991 -24 64 50000 20 0 2.98451 +1 64 50000 20 0 0 0 0 0 +2 64 50000 20 0 0 0 2.04204 0 +3 64 50000 20 0 0 0 6.12611 0 +4 64 50000 20 0 0 0 5.96903 0 +5 64 50000 20 0 0 0 1.5708 0 +6 64 50000 20 0 0 0 5.49779 0 +7 64 50000 20 0 0 0 5.18363 0 +8 64 50000 20 0 0 0 0.628319 0 +9 64 50000 20 0 0 0 4.39823 0 +10 64 50000 20 0 0 0 3.92699 0 +11 64 50000 20 0 0 0 2.82743 0 +12 64 50000 20 0 0 0 2.19911 0 +13 64 50000 20 0 0 0 3.61283 0 +14 64 50000 20 0 0 0 0.785398 0 +15 64 50000 20 0 0 0 1.25664 0 +16 64 50000 20 0 0 0 4.55531 0 +17 64 50000 20 0 0 0 4.71239 0 +18 64 50000 20 0 0 0 0.471239 0 +19 64 50000 20 0 0 0 1.41372 0 +20 64 50000 20 0 0 0 3.14159 0 +21 64 50000 20 0 0 0 5.34071 0 +22 64 50000 20 0 0 0 2.35619 0 +23 64 50000 20 0 0 0 3.76991 0 +24 64 50000 20 0 0 0 2.98451 0 # Sequence Shapes [SHAPES] @@ -3499,4 +3499,4 @@ num_samples 3000 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash db3779801ae0ba9abb2f246402b5ae9c +Hash 7160d56755113d789f083de4e9d7a9a1 diff --git a/tests/expected_output/write_gre_label.seq b/tests/expected_output/write_gre_label.seq index 71a49614..8a33988a 100644 --- a/tests/expected_output/write_gre_label.seq +++ b/tests/expected_output/write_gre_label.seq @@ -445,33 +445,33 @@ TotalDuration 0.64 71 -0 10 980 10 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 64 50000 20 0 0 -2 64 50000 20 0 2.04204 -3 64 50000 20 0 6.12611 -4 64 50000 20 0 5.96903 -5 64 50000 20 0 1.5708 -6 64 50000 20 0 5.49779 -7 64 50000 20 0 5.18363 -8 64 50000 20 0 0.628319 -9 64 50000 20 0 4.39823 -10 64 50000 20 0 3.92699 -11 64 50000 20 0 2.82743 -12 64 50000 20 0 2.19911 -13 64 50000 20 0 3.61283 -14 64 50000 20 0 0.785398 -15 64 50000 20 0 1.25664 -16 64 50000 20 0 4.55531 -17 64 50000 20 0 4.71239 -18 64 50000 20 0 0.471239 -19 64 50000 20 0 1.41372 -20 64 50000 20 0 3.14159 -21 64 50000 20 0 5.34071 -22 64 50000 20 0 2.35619 -23 64 50000 20 0 3.76991 -24 64 50000 20 0 2.98451 +1 64 50000 20 0 0 0 0 0 +2 64 50000 20 0 0 0 2.04204 0 +3 64 50000 20 0 0 0 6.12611 0 +4 64 50000 20 0 0 0 5.96903 0 +5 64 50000 20 0 0 0 1.5708 0 +6 64 50000 20 0 0 0 5.49779 0 +7 64 50000 20 0 0 0 5.18363 0 +8 64 50000 20 0 0 0 0.628319 0 +9 64 50000 20 0 0 0 4.39823 0 +10 64 50000 20 0 0 0 3.92699 0 +11 64 50000 20 0 0 0 2.82743 0 +12 64 50000 20 0 0 0 2.19911 0 +13 64 50000 20 0 0 0 3.61283 0 +14 64 50000 20 0 0 0 0.785398 0 +15 64 50000 20 0 0 0 1.25664 0 +16 64 50000 20 0 0 0 4.55531 0 +17 64 50000 20 0 0 0 4.71239 0 +18 64 50000 20 0 0 0 0.471239 0 +19 64 50000 20 0 0 0 1.41372 0 +20 64 50000 20 0 0 0 3.14159 0 +21 64 50000 20 0 0 0 5.34071 0 +22 64 50000 20 0 0 0 2.35619 0 +23 64 50000 20 0 0 0 3.76991 0 +24 64 50000 20 0 0 0 2.98451 0 # Format of extension lists: # id type ref next_id @@ -3522,4 +3522,4 @@ num_samples 3000 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash d3cadb82df334540fbaf44229b284ef8 +Hash 9685a123498aa0542870622e0c1ce861 diff --git a/tests/expected_output/write_radial_gre.seq b/tests/expected_output/write_radial_gre.seq index 0f31a7d7..d1d29e91 100644 --- a/tests/expected_output/write_radial_gre.seq +++ b/tests/expected_output/write_radial_gre.seq @@ -638,33 +638,33 @@ TotalDuration 1.62081 180 -768177 160 0 160 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 64 20000 40 0 0.471239 -2 64 20000 40 0 1.41372 -3 64 20000 40 0 4.39823 -4 64 20000 40 0 3.14159 -5 64 20000 40 0 3.92699 -6 64 20000 40 0 5.34071 -7 64 20000 40 0 5.96903 -8 64 20000 40 0 2.35619 -9 64 20000 40 0 0.785398 -10 64 20000 40 0 1.25664 -11 64 20000 40 0 3.76991 -12 64 20000 40 0 2.04204 -13 64 20000 40 0 4.71239 -14 64 20000 40 0 2.82743 -15 64 20000 40 0 2.98451 -16 64 20000 40 0 5.18363 -17 64 20000 40 0 1.5708 -18 64 20000 40 0 3.61283 -19 64 20000 40 0 4.55531 -20 64 20000 40 0 0 -21 64 20000 40 0 2.19911 -22 64 20000 40 0 5.49779 -23 64 20000 40 0 0.628319 -24 64 20000 40 0 6.12611 +1 64 20000 40 0 0 0 0.471239 0 +2 64 20000 40 0 0 0 1.41372 0 +3 64 20000 40 0 0 0 4.39823 0 +4 64 20000 40 0 0 0 3.14159 0 +5 64 20000 40 0 0 0 3.92699 0 +6 64 20000 40 0 0 0 5.34071 0 +7 64 20000 40 0 0 0 5.96903 0 +8 64 20000 40 0 0 0 2.35619 0 +9 64 20000 40 0 0 0 0.785398 0 +10 64 20000 40 0 0 0 1.25664 0 +11 64 20000 40 0 0 0 3.76991 0 +12 64 20000 40 0 0 0 2.04204 0 +13 64 20000 40 0 0 0 4.71239 0 +14 64 20000 40 0 0 0 2.82743 0 +15 64 20000 40 0 0 0 2.98451 0 +16 64 20000 40 0 0 0 5.18363 0 +17 64 20000 40 0 0 0 1.5708 0 +18 64 20000 40 0 0 0 3.61283 0 +19 64 20000 40 0 0 0 4.55531 0 +20 64 20000 40 0 0 0 0 0 +21 64 20000 40 0 0 0 2.19911 0 +22 64 20000 40 0 0 0 5.49779 0 +23 64 20000 40 0 0 0 0.628319 0 +24 64 20000 40 0 0 0 6.12611 0 # Sequence Shapes [SHAPES] @@ -4693,4 +4693,4 @@ num_samples 4000 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash dd222876689cf2f28449bed5881aaa32 +Hash 58cdbaad4e1e8082860b71b9826935db diff --git a/tests/expected_output/write_ute.seq b/tests/expected_output/write_ute.seq index 2008eb53..03bddf25 100644 --- a/tests/expected_output/write_ute.seq +++ b/tests/expected_output/write_ute.seq @@ -373,33 +373,33 @@ TotalDuration 0.64 64 -5.8783e-11 80 0 80 0 # Format of ADC events: -# id num dwell delay freq phase -# .. .. ns us Hz rad +# id num dwell delay freqPPM phasePPM freq phase phase_id +# .. .. ns us ppm rad/MHz Hz rad .. [ADC] -1 128 20000 20 0 0 -2 128 20000 20 0 2.04204 -3 128 20000 20 0 6.12611 -4 128 20000 20 0 5.96903 -5 128 20000 20 0 1.5708 -6 128 20000 20 0 5.49779 -7 128 20000 20 0 5.18363 -8 128 20000 20 0 0.628319 -9 128 20000 20 0 4.39823 -10 128 20000 20 0 3.92699 -11 128 20000 20 0 2.82743 -12 128 20000 20 0 2.19911 -13 128 20000 20 0 3.61283 -14 128 20000 20 0 0.785398 -15 128 20000 20 0 1.25664 -16 128 20000 20 0 4.55531 -17 128 20000 20 0 4.71239 -18 128 20000 20 0 0.471239 -19 128 20000 20 0 1.41372 -20 128 20000 20 0 3.14159 -21 128 20000 20 0 5.34071 -22 128 20000 20 0 2.35619 -23 128 20000 20 0 3.76991 -24 128 20000 20 0 2.98451 +1 128 20000 20 0 0 0 0 0 +2 128 20000 20 0 0 0 2.04204 0 +3 128 20000 20 0 0 0 6.12611 0 +4 128 20000 20 0 0 0 5.96903 0 +5 128 20000 20 0 0 0 1.5708 0 +6 128 20000 20 0 0 0 5.49779 0 +7 128 20000 20 0 0 0 5.18363 0 +8 128 20000 20 0 0 0 0.628319 0 +9 128 20000 20 0 0 0 4.39823 0 +10 128 20000 20 0 0 0 3.92699 0 +11 128 20000 20 0 0 0 2.82743 0 +12 128 20000 20 0 0 0 2.19911 0 +13 128 20000 20 0 0 0 3.61283 0 +14 128 20000 20 0 0 0 0.785398 0 +15 128 20000 20 0 0 0 1.25664 0 +16 128 20000 20 0 0 0 4.55531 0 +17 128 20000 20 0 0 0 4.71239 0 +18 128 20000 20 0 0 0 0.471239 0 +19 128 20000 20 0 0 0 1.41372 0 +20 128 20000 20 0 0 0 3.14159 0 +21 128 20000 20 0 0 0 5.34071 0 +22 128 20000 20 0 0 0 2.35619 0 +23 128 20000 20 0 0 0 3.76991 0 +24 128 20000 20 0 0 0 2.98451 0 # Sequence Shapes [SHAPES] @@ -1424,4 +1424,4 @@ num_samples 1000 # It can be reproduced/verified with md5sum if the file trimmed to the position right above [SIGNATURE] # The new line character preceding [SIGNATURE] BELONGS to the signature (and needs to be stripped away for recalculating/verification) Type md5 -Hash 7a1999f4351b28e01eda704e38168ef9 +Hash d068b005279832626cd595b50b51baea diff --git a/tests/test_check_timing.py b/tests/test_check_timing.py index cb4a2682..91d47b77 100644 --- a/tests/test_check_timing.py +++ b/tests/test_check_timing.py @@ -54,7 +54,7 @@ def test_check_timing(): seq.add_block(adc) # Block 4: RASTER adc = pp.make_adc(num_samples=100, duration=1e-3, system=system_broken) - seq.add_block(adc) # Block 5: ADC_DEAD_TIME, POST_ADC_DEAD_TIME + seq.add_block(adc) # Block 5: ADC_DEAD_TIME, POST_ADC_DEAD_TIME, BLOCK_DURATION_MISMATCH gx = pp.make_trapezoid(channel='x', area=1, duration=1, system=system) seq.add_block(gx) # Block 6: No error @@ -84,6 +84,9 @@ def test_check_timing(): assert exists_in_error_report(error_report, 5, event='adc', field='delay', error_type='ADC_DEAD_TIME') assert exists_in_error_report(error_report, 5, event='adc', field='duration', error_type='POST_ADC_DEAD_TIME') + assert exists_in_error_report( + error_report, 5, event='block', field='duration', error_type='BLOCK_DURATION_MISMATCH' + ) assert exists_in_error_report(error_report, 7, event='block', field='duration', error_type='RASTER') assert exists_in_error_report(error_report, 7, event='gx', field='flat_time', error_type='RASTER') @@ -94,4 +97,4 @@ def test_check_timing(): assert exists_in_error_report(error_report, 9, event='gx', field='delay', error_type='NEGATIVE_DELAY') - assert len(error_report) == 12, 'Total number of timing errors was expected to be 12' + assert len(error_report) == 13, 'Total number of timing errors was expected to be 12'