From 56188a3236b7f1211d63e52b43435702fc39cb1a Mon Sep 17 00:00:00 2001 From: Dylan Tisdall Date: Mon, 5 Oct 2026 14:17:11 -0400 Subject: [PATCH] Set signature_file to 'text' in read, as write does read() set signature_file to 'Text', while write() sets 'text', the value that MATLAB Pulseq documents ('text' or 'bin'). So the value for the same .seq file depended on whether the sequence was written or read. Add a check to test_writeread that signature_type and signature_file are the same after write() and after read(). Closes #427 Co-Authored-By: Claude Opus 5.5 --- src/pypulseq/Sequence/read_seq.py | 2 +- tests/test_sequence.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pypulseq/Sequence/read_seq.py b/src/pypulseq/Sequence/read_seq.py index 50aa78f6..8d587010 100644 --- a/src/pypulseq/Sequence/read_seq.py +++ b/src/pypulseq/Sequence/read_seq.py @@ -97,7 +97,7 @@ def read(self, path: str, detect_rf_use: Union[bool, None] = None, remove_duplic self.signature_type = temp_sign_defs['Type'] if 'Hash' in temp_sign_defs: self.signature_value = temp_sign_defs['Hash'] - self.signature_file = 'Text' + self.signature_file = 'text' elif section == '[VERSION]': file_version_major, file_version_minor, file_version_revision = __read_version(input_file) file_version_combined = 1000000 * file_version_major + 1000 * file_version_minor + file_version_revision diff --git a/tests/test_sequence.py b/tests/test_sequence.py index 5d83dc82..ce24254d 100644 --- a/tests/test_sequence.py +++ b/tests/test_sequence.py @@ -442,6 +442,10 @@ def test_writeread(self, seq_func, tmp_path, compare_seq_file): # Clean up written sequence file output_filename.unlink() + # Test that the signature is described in the same way after write and after read + assert seq.signature_file == 'text' + assert (seq2.signature_type, seq2.signature_file) == (seq.signature_type, seq.signature_file) + # Test for approximate equality of all blocks assert list(seq2.block_events.keys()) == list(seq.block_events.keys()), 'Sequence block IDs are not identical' for block_counter in seq.block_events: