imr-framework / pypulseq

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

Indexing problem prevents reading of rf pulse in .seq file #27

Closed imr-framework closed 4 years ago

imr-framework commented 4 years ago

Describe the bug Indexing error appears when trying to load a regular .seq file (FLASH sequence, 2D Cartesian)

To Reproduce

  1. Download the .seq file (https://drive.google.com/file/d/1mFMWPrEwwsw086W6KgPRy7Wh-EorLwsJ/view?usp=sharing) and put it in your current folder for running Python
  2. pip install the latest PyPulseq, and run the following:
    from pypulseq.Sequence.sequence import Sequence
    seq = Sequence()
    seq.read('FLASH.seq')
    seq.get_block(1)

Expected behavior The following error appears:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\tongg\PycharmProjects\py2jemris\venv\lib\site-packages\pypulseq\Sequence\sequence.py", line 115, in get_block
    return block.get_block(self, block_index)
  File "C:\Users\tongg\PycharmProjects\py2jemris\venv\lib\site-packages\pypulseq\Sequence\block.py", line 177, in get_block
    block.rf = self.rf_from_lib_data(self.rf_library.data[event_ind[1]])
  File "C:\Users\tongg\PycharmProjects\py2jemris\venv\lib\site-packages\pypulseq\Sequence\sequence.py", line 160, in rf_from_lib_data
    rf.dead_time = lib_data[6]
IndexError: index 6 is out of bounds for axis 0 with size 6

Desktop (please complete the following information):

sravan953 commented 4 years ago

@tonggehua Was the .seq file generated on Pulseq or pypulseq?

tonggehua commented 4 years ago

@tonggehua Was the .seq file generated on Pulseq or pypulseq?

It was generated with pypulseq.

tonggehua commented 4 years ago

@sravan953 With the current version, this happens:

s.read('seq_files/FLASH_N256_Ns16_TE5ms_TR10ms_FA8deg.seq')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\tongg\PycharmProjects\py2jemris\venv\lib\site-packages\pypulseq\Sequence\sequence.py", line 175, in read
    read(self, file_path)
  File "C:\Users\tongg\PycharmProjects\py2jemris\venv\lib\site-packages\pypulseq\Sequence\read_seq.py", line 42, in read
    f'Unsupported version: {version_major, version_minor, version_revision}. '
Exception: Unsupported version: (array([1.]), array([2.]), array([1.])). Expected: (1, 2, 0)
sravan953 commented 4 years ago

@tonggehua Does it read alright if you manually change the version number to 1.2.0 in the seq file? I guess I updated the version number incorrectly during the JOSS review process.

tonggehua commented 4 years ago

@sravan953 it does; do you mind changing it back to 1.2.1, so it aligns for everyone?

sravan953 commented 4 years ago

@tonggehua Good to hear. Sorry for the inconvenience, but sticking to 1.2.0 makes sense so that it remains compatible with Pulseq on Matlab.