TSE_k_space_fill.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. def TSE_k_space_fill(n_ex, ETL, k_steps, TE_eff_number, order):
  2. # function defines phase encoding steps for k space filling in liner order
  3. # with shifting according to the TE effective number
  4. k_space_list_with_zero = []
  5. for i in range(ETL):
  6. k_space_list_with_zero.append(int((ETL - 1) * n_ex - i * n_ex))
  7. # print(k_space_list_with_zero)
  8. central_num = int(k_steps / 2)
  9. # print(central_num)
  10. index_central_line = k_space_list_with_zero.index(central_num)
  11. shift = index_central_line - TE_eff_number + 1
  12. if shift > 0:
  13. a = k_space_list_with_zero[:shift]
  14. b = k_space_list_with_zero[shift:]
  15. k_space_list_with_zero = b + a
  16. elif shift < 0:
  17. a = k_space_list_with_zero[:shift]
  18. b = k_space_list_with_zero[shift:]
  19. k_space_list_with_zero = b + a
  20. if order == 'non_linear':
  21. a = k_space_list_with_zero[:((shift-index_central_line)*2+1)]
  22. b = k_space_list_with_zero[((shift-index_central_line)*2+1):]
  23. for i in range(1, int(len(b)/2)+1):
  24. a.append(b[i-1])
  25. a.append(b[-i])
  26. a.append(b[i])
  27. k_space_list_with_zero = a
  28. k_space_order_filing = [k_space_list_with_zero]
  29. for i in range(n_ex - 1):
  30. k_space_list_temp = []
  31. for k in k_space_list_with_zero:
  32. k_space_list_temp.append(k + i + 1)
  33. k_space_order_filing.append(k_space_list_temp)
  34. return k_space_order_filing