imr-framework / pypulseq

Pulseq in Python
https://pypulseq.readthedocs.io
GNU Affero General Public License v3.0
115 stars 62 forks source link

Backwards compatibility with Version 1.3.1post1 #69

Closed tonggehua closed 2 years ago

tonggehua commented 2 years ago

Describe the bug Version 1.4.0 (commit 5ef964c5bb0515260aac9acc760ee385f7c38fa1) cannot read seq files generated with Version 1.3.1post1

To Reproduce

  1. Pull from referenced commit
  2. Run the following in Python console:
    from pypulseq.Sequence.sequence import Sequence
    seq =  Sequence()
    seq.read('ute2d.seq')

    (This leads to Error 1)

  3. Change the version number in the seq file from 1.3.1post1 to 1.3.1 and rerun the same thing (This leads to Error 2)

Error 1: Traceback (most recent call last): File "C:\Users\tongg\PycharmProjects\disimpy\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in seq.read('ute2d.seq') File "C:\Users\tongg\PycharmProjects\pypulseq\pypulseq\Sequence\sequence.py", line 943, in read read(self, path=file_path, detect_rf_use=detect_rf_use) File "C:\Users\tongg\PycharmProjects\pypulseq\pypulseq\Sequence\read_seq.py", line 98, in read version_major, version_minor, version_revision = __read_version(input_file) File "C:\Users\tongg\PycharmProjects\pypulseq\pypulseq\Sequence\read_seq.py", line 412, in __read_version revision = int(tok[1]) ValueError: invalid literal for int() with base 10: '1post1'

Error 2: Traceback (most recent call last): File "C:\Users\tongg\PycharmProjects\disimpy\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in seq.read('ute2d.seq') File "C:\Users\tongg\PycharmProjects\pypulseq\pypulseq\Sequence\sequence.py", line 943, in read read(self, path=file_path, detect_rf_use=detect_rf_use) File "C:\Users\tongg\PycharmProjects\pypulseq\pypulseq\Sequence\read_seq.py", line 225, in read self.rf_library.data[i][:3], KeyError: 0

Expected behavior The sequence should be loaded without generating either error.

Desktop (please complete the following information):

Seq file used ute2d.seq (Attached; change extension to .seq before using) ute2d.md

schuenke commented 2 years ago

I am struggling with the same problem. Are you working on a solution yet or should I try finding a solution and create a PR? Don't wanna spend time on it if you are almost done anyway.

sravan953 commented 2 years ago

@schuenke I have not yet started working on it - but I will get it done soon. Thanks for offering to help!

sravan953 commented 2 years ago

@tonggehua @schuenke Thanks for bearing with me, commit 7f8345cba4ca6d686e65457b78900729d131a6ea should hopefully fix this.

@tonggehua P.S: For quite some time now, you can just do import pypulseq as pp and call submodules/methods directly:

import pypulseq as pp

seq = pp.Sequence()
schuenke commented 2 years ago

@sravan953 it seems to work for me. Thanks 👍