imr-framework / pypulseq

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

seq.test_report() calculates wrong "Spatial resolution" if spoilers are used. #204

Closed h3lg3 closed 1 month ago

h3lg3 commented 1 month ago

Describe the bug Output of seq.test_report() for spatial resolution is wrong if kspace is not centered. In ext_test_report.py, line 72, kspace extent is calculated

k_extent = np.max(np.abs(k_traj_adc), axis=1)

However, if the k-space is not centered around 0, this calculation leads to wrong estimation of the resolution. A fix would be: k_extent = 0.5 * (np.max(k_traj_adc, axis=1) - np.min(k_traj_adc, axis=1))

This has the disadvantage, that for a centered kspace ranging, e.g., from -32 to +31 with a total of 64 samples. The above calculation slightly misestimates the resolution since k_extent is calculated to be 31.5 instead of 32 (current implementation)

Screenshots Here you can see that the maximum kspace extent (of ADC) underestimates the resolution, if it is not accounted for the lower kspace extent (of ADC) image

Desktop (please complete the following information):

h3lg3 commented 1 month ago

I figured out, that the kspace is shifted only after I imported the sequence again. Plotting the kspace trajectory directly after building did not show the shift. Setting the optional parameter "detect_rf_use = True" for seq.red() resolved the issue.

# write sequence to disk
seq.write('test.seq')

# import sequence
seq_import = pp.Sequence(system=system)

seq_import.read('test.seq') # kspace is shifted, because 180° refocussing pulses are not recognized

seq_import.read('test.seq', detect_rf_use = True) # solves problem of shifted kspace