def TSE_k_space_fill(n_ex, ETL, k_steps, TE_eff_number, order):
    # function defines phase encoding steps for k space filling in liner order
    # with shifting according to the TE effective number

    k_space_list_with_zero = []
    for i in range(ETL):
        k_space_list_with_zero.append(int((ETL - 1) * n_ex - i * n_ex))
    # print(k_space_list_with_zero)
    central_num = int(k_steps / 2)
    # print(central_num)
    index_central_line = k_space_list_with_zero.index(central_num)
    shift = index_central_line - TE_eff_number + 1

    if shift > 0:
        a = k_space_list_with_zero[:shift]
        b = k_space_list_with_zero[shift:]
        k_space_list_with_zero = b + a
    elif shift < 0:
        a = k_space_list_with_zero[:shift]
        b = k_space_list_with_zero[shift:]
        k_space_list_with_zero = b + a

    if order == 'non_linear':
        a = k_space_list_with_zero[:((shift-index_central_line)*2+1)]
        b = k_space_list_with_zero[((shift-index_central_line)*2+1):]
        for i in range(1, int(len(b)/2)+1):
            a.append(b[i-1])
            a.append(b[-i])
        a.append(b[i])
        k_space_list_with_zero = a

    k_space_order_filing = [k_space_list_with_zero]
    for i in range(n_ex - 1):
        k_space_list_temp = []
        for k in k_space_list_with_zero:
            k_space_list_temp.append(k + i + 1)
        k_space_order_filing.append(k_space_list_temp)


    return k_space_order_filing