# -*- coding: utf-8 -*-
"""
Created on Fri Mar 15 11:47:02 2024

@author: zilya

"""

import tkinter as tk
import tkinter.filedialog
from types import SimpleNamespace
from math import ceil
import json


def param_set_lim(M0_dj,param_list,lim,param):
    if 'sl_nb' in param_list:
        M0_dj.label_sl_nb_min.configure(text = str(ceil(lim.sl_nb_min)))
        M0_dj.label_sl_nb_max.configure(text = str(ceil(lim.sl_nb_max)))
    if 'sl_thkn' in param_list:
        M0_dj.label_sl_thkn_min.configure(text = str(ceil(lim.sl_thkn_min*1000)/1000))
        M0_dj.label_sl_thkn_max.configure(text = str(ceil(lim.sl_thkn_max*1000)/1000))
    if 'sl_gap' in param_list:
        M0_dj.label_sl_gap_min.configure(text = str(ceil(lim.sl_gap_min)))
        M0_dj.label_sl_gap_max.configure(text = str(ceil(lim.sl_gap_max)))
    if 'slab_thkn' in param_list:
        M0_dj.label_slab_thkn_min.configure(text = str(ceil(lim.slab_thkn_min*1000)/1000))
        M0_dj.label_slab_thkn_max.configure(text = str(ceil(lim.slab_thkn_max*1000)/1000))
    
    if 'FoV_f' in param_list:
        M0_dj.label_FoV_f_min.configure(text = str(ceil(lim.FoV_f_min*1000)/1000))
        M0_dj.label_FoV_f_max.configure(text = str(ceil(lim.FoV_f_max*1000)/1000))
    if 'FoV_p_image' in param_list:
        M0_dj.label_FoV_p_image_min.configure(text = str(ceil(lim.FoV_p_image_min*1000)/1000))
        M0_dj.label_FoV_p_image_max.configure(text = str(ceil(lim.FoV_p_image_max*1000)/1000))
    if 'Nf' in param_list:
        M0_dj.label_Nf_min.configure(text = str(ceil(lim.Nf_min)))
        M0_dj.label_Nf_max.configure(text = str(ceil(lim.Nf_max)))
    if 'Np_image' in param_list:
        M0_dj.label_Np_image_min.configure(text = str(ceil(lim.Np_image_min)))
        M0_dj.label_Np_image_max.configure(text = str(ceil(lim.Np_image_max)))
        M0_dj.label_Acq_matrix_v.configure(text = str(ceil(param.Nf)) + "x" + str(ceil(param.Np)))
    if 'Nss' in param_list:
        M0_dj.label_Nss_min.configure(text = str(ceil(lim.Nss_min)))
        M0_dj.label_Nss_max.configure(text = str(ceil(lim.Nss_max)))
    if 'BW_pixel' in param_list:
        M0_dj.label_BW_pixel_min.configure(text = str(ceil(lim.BW_pixel_min)))
        M0_dj.label_BW_pixel_max.configure(text = str(ceil(lim.BW_pixel_max)))
    
    if 'TE' in param_list:
        M0_dj.label_TE_min.configure(text = str(ceil(lim.TE_min*1000)/1000))
        M0_dj.label_TE_max.configure(text = str(ceil(lim.TE_max*1000)/1000))
    if 'N_TE' in param_list:
        M0_dj.label_N_TE_min.configure(text = str(ceil(lim.N_TE_min)))
        M0_dj.label_N_TE_max.configure(text = str(ceil(lim.N_TE_max)))
        M0_dj.label_N_TE_1v.configure(text = str(ceil(param.ES*1000)/1000))
        M0_dj.label_N_TE_2v.configure(text = str(ceil(param.TE*1000)/1000))
    if 'IE' in param_list:
        M0_dj.label_IE_min.configure(text = str(ceil(lim.IE_min*1000)/1000))
        M0_dj.label_IE_max.configure(text = str(ceil(lim.IE_max*10000)/10000))
    if 'ETL' in param_list:
        M0_dj.label_ETL_min.configure(text = str(lim.ETL_min))
        M0_dj.label_ETL_max.configure(text = str(lim.ETL_max))
    if 'contrasts' in param_list:
        M0_dj.label_contrasts_min.configure(text = str(ceil(lim.contrasts_min)))
        M0_dj.label_contrasts_max.configure(text = str(lim.contrasts_max))
    if 'concats' in param_list:
        M0_dj.label_concats_min.configure(text = str(lim.concats_min))
        M0_dj.label_concats_max.configure(text = str(lim.concats_max))
    if 'TR' in param_list:
        M0_dj.label_TR_min.configure(text = str(ceil(lim.TR_min*100)/100))
        M0_dj.label_TR_max.configure(text = str(ceil(lim.TR_max*100)/100))
    if 'TD' in param_list:
        M0_dj.label_TD_min.configure(text = str(ceil(lim.TD_min*100)/100))
        M0_dj.label_TD_max.configure(text = str(ceil(lim.TD_max*100)/100))
    
    if 'FA' in param_list:
        M0_dj.label_FA_min.configure(text = str(ceil(lim.FA_min)))
        M0_dj.label_FA_max.configure(text = str(ceil(lim.FA_max)))
    if 'RA' in param_list:
        M0_dj.label_RA_min.configure(text = str(ceil(lim.RA_min)))
        M0_dj.label_RA_max.configure(text = str(ceil(lim.RA_max)))
    if 'spoil_strenght' in param_list:
        M0_dj.label_spoil_strenght_min.configure(text = str(ceil(lim.spoil_strenght_min)))
        M0_dj.label_spoil_strenght_max.configure(text = str(ceil(lim.spoil_strenght_max)))
    if 'RF_spoil' in param_list:
        M0_dj.label_RF_spoil_min.configure(text = str(ceil(lim.RF_spoil_min)))
        M0_dj.label_RF_spoil_max.configure(text = str(ceil(lim.RF_spoil_max)))
    
    if 'average' in param_list:
        M0_dj.label_average_min.configure(text = str(ceil(lim.average_min)))
        M0_dj.label_average_max.configure(text = str(ceil(lim.average_max)))
    if 'D_scans' in param_list:
        M0_dj.label_D_scans_min.configure(text = str(ceil(lim.D_scans_min)))
        M0_dj.label_D_scans_max.configure(text = str(ceil(lim.D_scans_max)))
    if 'ph_over_phase' in param_list:
        M0_dj.label_ph_over_phase_min.configure(text = str(ceil(lim.ph_over_phase_min)))
        M0_dj.label_ph_over_phase_max.configure(text = str(ceil(lim.ph_over_phase_max)))
    if 'ph_over_slice' in param_list:
        M0_dj.label_ph_over_slice_min.configure(text = str(ceil(lim.ph_over_slice_min)))
        M0_dj.label_ph_over_slice_max.configure(text = str(ceil(lim.ph_over_slice_max)))
    
    if 'TI' in param_list:
        M0_dj.label_TI_min.configure(text = str(ceil(lim.TI_min*100)/100))
        M0_dj.label_TI_max.configure(text = str(ceil(lim.TI_max*100)/100))
    if 'N_TI' in param_list:
        M0_dj.label_N_TI_min.configure(text = str(ceil(lim.N_TI_min)))
        M0_dj.label_N_TI_max.configure(text = str(ceil(lim.N_TI_max*1000)/1000))
        M0_dj.label_TI_eff_v.configure(text = str(ceil(param.TI_eff*1000)/1000))
                
    if 'b' in param_list:
        M0_dj.label_b_min.configure(text = str(ceil(lim.b_min)))
        M0_dj.label_b_max.configure(text = str(ceil(lim.b_max)))
    if 'sat_sl_thkn' in param_list:
        M0_dj.label_sat_sl_thkn_min.configure(text = str(ceil(lim.sat_sl_thkn_min*10000)/10000))
        M0_dj.label_sat_sl_thkn_max.configure(text = str(ceil(lim.sat_sl_thkn_max*10000)/10000))
    if 'distance_ex_sat' in param_list:
        M0_dj.label_distance_ex_sat_min.configure(text = str(ceil(lim.distance_ex_sat_min)))
        M0_dj.label_distance_ex_sat_max.configure(text = str(ceil(lim.distance_ex_sat_max)))  
         
def param_dj_get(M0_dj,param_list):
    
    param_get = SimpleNamespace()
    if 'sl_nb' in param_list:
        param_get.sl_nb = int(M0_dj.textBox_sl_nb.get())
    if 'sl_thkn' in param_list:
        param_get.sl_thkn = float(M0_dj.textBox_sl_thkn.get())
    if 'sl_gap' in param_list:
        param_get.sl_gap = float(M0_dj.textBox_sl_gap.get())
    if 'slab_thkn' in param_list:
        param_get.slab_thkn = float(M0_dj.textBox_slab_thkn.get())
        
    if 'FoV_f' in param_list:
        param_get.FoV_f = float(M0_dj.textBox_FoV_f.get())
    if 'FoV_p_image' in param_list:
        param_get.FoV_p_image = float(M0_dj.textBox_FoV_p_image.get())
    if 'Nf' in param_list:
        param_get.Nf = float(M0_dj.textBox_Nf.get())
    if 'Np_image' in param_list:
        param_get.Np_image = float(M0_dj.textBox_Np_image.get())
    if 'Nss' in param_list:
        param_get.Nss = float(M0_dj.textBox_Nss.get())
    if 'BW_pixel' in param_list:
        param_get.BW_pixel = float(M0_dj.textBox_BW_pixel.get())
        
    if 'TE' in param_list:
        param_get.TE = float(M0_dj.textBox_TE.get())
    if 'N_TE' in param_list:
        param_get.N_TE = float(M0_dj.textBox_N_TE.get())
    if 'IE' in param_list:
        param_get.IE = float(M0_dj.textBox_IE.get())
    if 'ETL' in param_list:
        param_get.ETL = float(M0_dj.textBox_ETL.get())
    if 'contrasts' in param_list:
        param_get.contrasts = int(M0_dj.textBox_contrasts.get())
    if 'concats' in param_list:
        param_get.concats = int(M0_dj.textBox_concats.get())
    if 'TR' in param_list:
        param_get.TR = float(M0_dj.textBox_TR.get())
    if 'TD' in param_list:
        param_get.TD = float(M0_dj.textBox_TD.get())
      
    if 'FA' in param_list:
        param_get.FA = float(M0_dj.textBox_FA.get())
    if 'RA' in param_list:
        param_get.RA = float(M0_dj.textBox_RA.get())
    if 'spoil_strenght' in param_list:
        param_get.spoil_strenght = float(M0_dj.textBox_spoil_strenght.get())
    if 'RF_spoil' in param_list:
        param_get.RF_spoil = float(M0_dj.textBox_RF_spoil.get())
        
    if 'average' in param_list:
        param_get.average = int(M0_dj.textBox_average.get())
    if 'D_scans' in param_list:
        param_get.D_scans = int(M0_dj.textBox_D_scans.get())
    if 'ph_over_phase' in param_list:
        param_get.ph_over_phase = float(M0_dj.textBox_ph_over_phase.get())
    if 'ph_over_slice' in param_list:
        param_get.ph_over_slice = float(M0_dj.textBox_ph_over_slice.get())
    if 'part_fourier_factor_phase' in param_list:
        param_get.part_fourier_factor_phase = float(M0_dj.textBox_part_fourier_factor_phase.get())
    if 'part_fourier_factor_slice' in param_list:
        param_get.part_fourier_factor_slice = float(M0_dj.textBox_part_fourier_factor_slice.get())
    
    param_get.ZF = False
    if M0_dj.radio_ZF.get() == 2:
        param_get.ZF = True
    
    param_get.FS = False
    param_get.SPAIR = False
    param_get.WS = False
    param_get.WE = False
    
    param_get.IR = False
    param_get.DIR = False
    param_get.TIR = False
    param_get.SR = False
    param_get.T2_prep_IR = False
    
    if M0_dj.radio_f_w.get() == 11:
        param_get.FS = True
    if M0_dj.radio_f_w.get() == 12:
        param_get.SPAIR = True
    if M0_dj.radio_f_w.get() == 13:
        param_get.WS = True
    if M0_dj.radio_f_w.get() == 14:
        param_get.WE = True

    if M0_dj.radio_m_p.get() == 21:
        param_get.IR = True
    if M0_dj.radio_m_p.get() == 22:
        param_get.DIR = True
    if M0_dj.radio_m_p.get() == 23:
        param_get.TIR = True
    if M0_dj.radio_m_p.get() == 24:
        param_get.SR = True
    if M0_dj.radio_m_p.get() == 25:
        param_get.T2_prep_IR = True
        
    if 'TI' in param_list:
        param_get.TI = float(M0_dj.textBox_TI.get())
    if 'N_TI' in param_list:
        param_get.N_TI = float(M0_dj.textBox_N_TI.get())
    if 'b' in param_list:
        param_get.b = float(M0_dj.textBox_b.get())
    if 'sat_sl_thkn' in param_list:
        param_get.sat_sl_thkn = float(M0_dj.textBox_sat_sl_thkn.get())
    if 'distance_ex_sat' in param_list:
        param_get.distance_ex_sat = float(M0_dj.textBox_distance_ex_sat.get())
    
    param_get.flow_comp_fr = False
    param_get.flow_comp_sl = False
    if 'flow_comp' in param_list:
        if M0_dj.radio_flow_comp.get() == 2:
            param_get.flow_comp_fr = True
        if M0_dj.radio_flow_comp.get() == 3:
            param_get.flow_comp_sl = True
        if M0_dj.radio_flow_comp.get() == 4:
            param_get.flow_comp_fr = True
            param_get.flow_comp_sl = True  
        
    param_get.recomb = False
    if 'recomb' in param_list:
        if M0_dj.radio_recomb.get() == 2:
            param_get.recomb = True
            
    return param_get

def read_json(Main,M0_dj,param_list):
    filepath = tk.filedialog.askopenfilename()
    if filepath != "":
        with open(filepath, "r") as file:
            params_j = json.load(file)
            if 'sl_nb' in param_list:
                M0_dj.textBox_sl_nb.delete(0, 'end'); M0_dj.textBox_sl_nb.insert(0, params_j['sl_nb'])
            if 'sl_thkn' in param_list:
                M0_dj.textBox_sl_thkn.delete(0, 'end'); M0_dj.textBox_sl_thkn.insert(0, params_j['sl_thkn'])
            if 'sl_gap' in param_list:
                M0_dj.textBox_sl_gap.delete(0, 'end'); M0_dj.textBox_sl_gap.insert(0, params_j['sl_gap'])
            if 'slab_thkn' in param_list:
                M0_dj.textBox_slab_thkn.delete(0, 'end'); M0_dj.textBox_slab_thkn.insert(0, params_j['slab_thkn'])
            
            if 'FoV_f' in param_list:
                M0_dj.textBox_FoV_f.delete(0, 'end'); M0_dj.textBox_FoV_f.insert(0, params_j['FoV_f'])
            if 'FoV_p_image' in param_list:
                M0_dj.textBox_FoV_p_image.delete(0, 'end'); M0_dj.textBox_FoV_p_image.insert(0, params_j['FoV_p_image'])
            if 'Nf' in param_list:
                M0_dj.textBox_Nf.delete(0, 'end'); M0_dj.textBox_Nf.insert(0, params_j['Nf'])
            if 'Np_image' in param_list:
                M0_dj.textBox_Np_image.delete(0, 'end'); M0_dj.textBox_Np_image.insert(0, params_j['Np_image'])
            if 'Nss' in param_list:
                M0_dj.textBox_Nss.delete(0, 'end'); M0_dj.textBox_Nss.insert(0, params_j['Nss'])
            if 'BW_pixel' in param_list:
                M0_dj.textBox_BW_pixel.delete(0, 'end'); M0_dj.textBox_BW_pixel.insert(0, params_j['BW_pixel'])
            
            if 'TE' in param_list:
                M0_dj.textBox_TE.delete(0, 'end'); M0_dj.textBox_TE.insert(0, params_j['TE'])
            if 'N_TE' in param_list:
                M0_dj.textBox_N_TE.delete(0, 'end'); M0_dj.textBox_N_TE.insert(0, params_j['N_TE'])
            if 'IE' in param_list:
                M0_dj.textBox_IE.delete(0, 'end'); M0_dj.textBox_IE.insert(0, params_j['IE'])
            if 'ETL' in param_list:
                M0_dj.textBox_ETL.delete(0, 'end'); M0_dj.textBox_ETL.insert(0, params_j['ETL'])
            if 'contrasts' in param_list:
                M0_dj.textBox_contrasts.delete(0, 'end'); M0_dj.textBox_contrasts.insert(0, params_j['contrasts'])
            if 'concats' in param_list:
                M0_dj.textBox_concats.delete(0, 'end'); M0_dj.textBox_concats.insert(0, params_j['concats'])
            if 'TR' in param_list:
                M0_dj.textBox_TR.delete(0, 'end'); M0_dj.textBox_TR.insert(0, params_j['TR'])
            if 'TD' in param_list:
                M0_dj.textBox_TD.delete(0, 'end'); M0_dj.textBox_TD.insert(0, params_j['TD'])
            
            if 'FA' in param_list:
                M0_dj.textBox_FA.delete(0, 'end'); M0_dj.textBox_FA.insert(0, params_j['FA'])
            if 'RA' in param_list:
                M0_dj.textBox_RA.delete(0, 'end'); M0_dj.textBox_RA.insert(0, params_j['RA'])
            if 'spoil_strenght' in param_list:
                M0_dj.textBox_spoil_strenght.delete(0, 'end'); M0_dj.textBox_spoil_strenght.insert(0, params_j['spoil_strenght'])
            if 'RF_spoil' in param_list:
                M0_dj.textBox_RF_spoil.delete(0, 'end'); M0_dj.textBox_RF_spoil.insert(0, params_j['RF_spoil'])
            
            if 'average' in param_list:
                M0_dj.textBox_average.delete(0, 'end'); M0_dj.textBox_average.insert(0, params_j['average'])
            if 'D_scans' in param_list:
                M0_dj.textBox_D_scans.delete(0, 'end'); M0_dj.textBox_D_scans.insert(0, params_j['D_scans'])
            if 'ph_over_phase' in param_list:
                M0_dj.textBox_ph_over_phase.delete(0, 'end'); M0_dj.textBox_ph_over_phase.insert(0, params_j['ph_over_phase'])
            if 'ph_over_slice' in param_list:
                M0_dj.textBox_ph_over_slice.delete(0, 'end'); M0_dj.textBox_ph_over_slice.insert(0, params_j['ph_over_slice'])
            
            if 'TI' in param_list:
                M0_dj.textBox_TI.delete(0, 'end'); M0_dj.textBox_TI.insert(0, params_j['TI'])
            if 'N_TI' in param_list:
                M0_dj.textBox_N_TI.delete(0, 'end'); M0_dj.textBox_N_TI.insert(0, params_j['N_TI'])
            if 'b' in param_list:
                M0_dj.textBox_b.delete(0, 'end'); M0_dj.textBox_b.insert(0, params_j['b'])
            if 'sat_sl_thkn' in param_list:
                M0_dj.textBox_sat_sl_thkn.delete(0, 'end'); M0_dj.textBox_sat_sl_thkn.insert(0, params_j['sat_sl_thkn'])
            if 'distance_ex_sat' in param_list:
                M0_dj.textBox_distance_ex_sat.delete(0, 'end'); M0_dj.textBox_distance_ex_sat.insert(0, params_j['distance_ex_sat'])
                
                
def param_digits_create(Main,M0_dj,param_list,default):
    
    row = 0
    M0_dj.label_min = tk.Label(Main, text = "min", width = 10)
    M0_dj.label_min.grid(row=row, column=2)
    M0_dj.label_max = tk.Label(Main, text = "max", width = 10)
    M0_dj.label_max.grid(row=row, column=3)
    row += 1 
    
    M0_dj.label_1 = tk.Label(Main, text = 'Slice', font="Helvetica 10 bold")
    M0_dj.label_1.grid(row=row , column=0,sticky = "E")
    row += 1
    
    if 'sl_nb' in param_list:  
        M0_dj.label_sl_nb = tk.Label(Main, text = 'Slice number')
        M0_dj.label_sl_nb.grid(row=row , column=0,sticky = "E")
        M0_dj.textBox_sl_nb = tk.Entry(Main,width = 6)
        M0_dj.textBox_sl_nb.insert(0, default.sl_nb)
        M0_dj.textBox_sl_nb.grid(row=row, column=1)
        M0_dj.label_sl_nb_min = tk.Label(Main)
        M0_dj.label_sl_nb_min.grid(row=row, column=2)
        M0_dj.label_sl_nb_max = tk.Label(Main)
        M0_dj.label_sl_nb_max.grid(row=row, column=3)
        row += 1
        
    if 'sl_thkn' in param_list:
        M0_dj.label_sl_thkn = tk.Label(Main, text = 'Slice thickness, m')
        M0_dj.label_sl_thkn.grid(row=row , column=0,sticky = "E")
        M0_dj.textBox_sl_thkn = tk.Entry(Main,width = 6)
        M0_dj.textBox_sl_thkn.insert(0, default.sl_thkn)
        M0_dj.textBox_sl_thkn.grid(row=row, column=1)
        M0_dj.label_sl_thkn_min = tk.Label(Main)
        M0_dj.label_sl_thkn_min.grid(row=row, column=2)
        M0_dj.label_sl_thkn_max = tk.Label(Main)
        M0_dj.label_sl_thkn_max.grid(row=row, column=3)
        row += 1
        
    if 'sl_gap' in param_list:
        M0_dj.label_sl_gap = tk.Label(Main, text = 'Slice gap, %')
        M0_dj.label_sl_gap.grid(row=row , column=0,sticky = "E")
        M0_dj.textBox_sl_gap = tk.Entry(Main,width = 6)
        M0_dj.textBox_sl_gap.insert(0, default.sl_gap)
        M0_dj.textBox_sl_gap.grid(row=row, column=1)
        M0_dj.label_sl_gap_min = tk.Label(Main)
        M0_dj.label_sl_gap_min.grid(row=row, column=2)
        M0_dj.label_sl_gap_max = tk.Label(Main)
        M0_dj.label_sl_gap_max.grid(row=row, column=3)
        row += 1
        
    if 'slab_thkn' in param_list:
        M0_dj.label_slab_thkn = tk.Label(Main, text = 'Slab thickness, m')
        M0_dj.label_slab_thkn.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_slab_thkn = tk.Entry(Main,width = 6)
        M0_dj.textBox_slab_thkn.insert(0, default.slab_thkn)
        M0_dj.textBox_slab_thkn.grid(row=row, column=1)
        M0_dj.label_slab_thkn_min = tk.Label(Main)
        M0_dj.label_slab_thkn_min.grid(row=row, column=2)
        M0_dj.label_slab_thkn_max = tk.Label(Main)
        M0_dj.label_slab_thkn_max.grid(row=row, column=3)
        row += 1
      
    M0_dj.label_2 = tk.Label(Main, text = 'Resolution', font="Helvetica 10 bold")
    M0_dj.label_2.grid(row=row , column=0,sticky = "E")
    row += 1
    
    if 'FoV_f' in param_list:
        M0_dj.label_FoV_f = tk.Label(Main, text = 'FoV freq, m')
        M0_dj.label_FoV_f.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_FoV_f = tk.Entry(Main,width = 6)
        M0_dj.textBox_FoV_f.insert(0, default.FoV_f)
        M0_dj.textBox_FoV_f.grid(row=row, column=1)
        M0_dj.label_FoV_f_min = tk.Label(Main)
        M0_dj.label_FoV_f_min.grid(row=row, column=2)
        M0_dj.label_FoV_f_max = tk.Label(Main)
        M0_dj.label_FoV_f_max.grid(row=row, column=3)
        row += 1
        
    if 'FoV_p_image' in param_list:
        M0_dj.label_FoV_p_image = tk.Label(Main, text = 'FoV phase, m')
        M0_dj.label_FoV_p_image.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_FoV_p_image = tk.Entry(Main,width = 6)
        M0_dj.textBox_FoV_p_image.insert(0, default.FoV_p_image)
        M0_dj.textBox_FoV_p_image.grid(row=row, column=1)
        M0_dj.label_FoV_p_image_min = tk.Label(Main)
        M0_dj.label_FoV_p_image_min.grid(row=row, column=2)
        M0_dj.label_FoV_p_image_max = tk.Label(Main)
        M0_dj.label_FoV_p_image_max.grid(row=row, column=3)
        row += 1
        
    if 'Nf' in param_list:
        M0_dj.label_Nf = tk.Label(Main, text = 'Read resolution')
        M0_dj.label_Nf.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_Nf = tk.Entry(width = 6)
        M0_dj.textBox_Nf.insert(0, default.Nf)
        M0_dj.textBox_Nf.grid(row=row, column=1)
        M0_dj.label_Nf_min = tk.Label(Main)
        M0_dj.label_Nf_min.grid(row=row, column=2)
        M0_dj.label_Nf_max = tk.Label(Main)
        M0_dj.label_Nf_max.grid(row=row, column=3)
        row += 1
    
    if 'Np_image' in param_list:
        M0_dj.label_Np_image = tk.Label(Main, text = 'Phase resolution')
        M0_dj.label_Np_image.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_Np_image = tk.Entry(width = 6)
        M0_dj.textBox_Np_image.insert(0, default.Np_image)
        M0_dj.textBox_Np_image.grid(row=row, column=1)
        M0_dj.label_Np_image_min = tk.Label(Main)
        M0_dj.label_Np_image_min.grid(row=row, column=2)
        M0_dj.label_Np_image_max = tk.Label(Main)
        M0_dj.label_Np_image_max.grid(row=row, column=3)
        row += 1
        M0_dj.label_Acq_matrix = tk.Label(Main, text = 'Acquisition matrix (NfxNp)')
        M0_dj.label_Acq_matrix.grid(row=row, column=0,sticky = "E")
        M0_dj.label_Acq_matrix_v = tk.Label(Main)
        M0_dj.label_Acq_matrix_v.grid(row=row, column=1)
        row += 1
        
    if 'Nss' in param_list:
        M0_dj.label_Nss = tk.Label(Main, text = 'Number of slices')
        M0_dj.label_Nss.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_Nss = tk.Entry(width = 6)
        M0_dj.textBox_Nss.insert(0, default.Nss)
        M0_dj.textBox_Nss.grid(row=row, column=1)
        M0_dj.label_Nss_min = tk.Label(Main)
        M0_dj.label_Nss_min.grid(row=row, column=2)
        M0_dj.label_Nss_max = tk.Label(Main)
        M0_dj.label_Nss_max.grid(row=row, column=3)
        row += 1
        
    if 'BW_pixel' in param_list:
        M0_dj.label_BW_pixel = tk.Label(Main, text = 'BW per pixel')
        M0_dj.label_BW_pixel.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_BW_pixel = tk.Entry(width = 6)
        M0_dj.textBox_BW_pixel.insert(0, default.BW_pixel)
        M0_dj.textBox_BW_pixel.grid(row=row, column=1)
        M0_dj.label_BW_pixel_min = tk.Label(Main)
        M0_dj.label_BW_pixel_min.grid(row=row, column=2)
        M0_dj.label_BW_pixel_max = tk.Label(Main)
        M0_dj.label_BW_pixel_max.grid(row=row, column=3)
        row += 1
     
    M0_dj.label_3 = tk.Label(Main, text = 'Contrast', font="Helvetica 10 bold")
    M0_dj.label_3.grid(row=row , column=0,sticky = "E")
    row += 1  
        
    if 'TE' in param_list:
        M0_dj.label_TE = tk.Label(Main, text = 'TE, s')
        M0_dj.label_TE.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_TE = tk.Entry(Main,width = 6)
        M0_dj.textBox_TE.insert(0, default.TE)
        M0_dj.textBox_TE.grid(row=row, column=1)
        M0_dj.label_TE_min = tk.Label(Main)
        M0_dj.label_TE_min.grid(row=row, column=2)
        M0_dj.label_TE_max = tk.Label(Main)
        M0_dj.label_TE_max.grid(row=row, column=3)
        row += 1
        
    if 'N_TE' in param_list:
        M0_dj.label_N_TE = tk.Label(Main, text = 'N_TE, s')
        M0_dj.label_N_TE.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_N_TE = tk.Entry(Main,width = 6)
        M0_dj.textBox_N_TE.insert(0, default.N_TE)
        M0_dj.textBox_N_TE.grid(row=row, column=1)
        M0_dj.label_N_TE_min = tk.Label(Main)
        M0_dj.label_N_TE_min.grid(row=row, column=2)
        M0_dj.label_N_TE_max = tk.Label(Main)
        M0_dj.label_N_TE_max.grid(row=row, column=3)
        row += 1
        M0_dj.label_N_TE_1 = tk.Label(Main, text = 'ES, s')
        M0_dj.label_N_TE_1.grid(row=row, column=0,sticky = "E")
        M0_dj.label_N_TE_1v = tk.Label(Main)
        M0_dj.label_N_TE_1v.grid(row=row, column=1)
        row += 1
        M0_dj.label_N_TE_2 = tk.Label(Main, text = 'TE, s')
        M0_dj.label_N_TE_2.grid(row=row, column=0,sticky = "E")
        M0_dj.label_N_TE_2v = tk.Label(Main)
        M0_dj.label_N_TE_2v.grid(row=row, column=1)
        row += 1
        
        
        
    if 'IE' in param_list:
        M0_dj.label_IE = tk.Label(Main, text = 'Inter echo, s')
        M0_dj.label_IE.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_IE = tk.Entry(width = 6)
        M0_dj.textBox_IE.insert(0, default.IE)
        M0_dj.textBox_IE.grid(row=row, column=1)
        M0_dj.label_IE_min = tk.Label(Main)
        M0_dj.label_IE_min.grid(row=row, column=2)
        M0_dj.label_IE_max = tk.Label(Main)
        M0_dj.label_IE_max.grid(row=row, column=3)
        row += 1
        
    if 'ETL' in param_list:
        M0_dj.label_ETL = tk.Label(Main, text = 'ETL (Np multiples of ETL)')
        M0_dj.label_ETL.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_ETL = tk.Entry(width = 6)
        M0_dj.textBox_ETL.insert(0, default.ETL)
        M0_dj.textBox_ETL.grid(row=row, column=1)
        M0_dj.label_ETL_min = tk.Label(Main)
        M0_dj.label_ETL_min.grid(row=row, column=2)
        M0_dj.label_ETL_max = tk.Label(Main)
        M0_dj.label_ETL_max.grid(row=row, column=3)
        row += 1
        
    if 'contrasts' in param_list:
        M0_dj.label_contrasts = tk.Label(Main, text = 'Number of contrasts')
        M0_dj.label_contrasts.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_contrasts = tk.Entry(width = 6)
        M0_dj.textBox_contrasts.insert(0, default.contrasts)
        M0_dj.textBox_contrasts.grid(row=row, column=1)
        M0_dj.label_contrasts_min = tk.Label(Main)
        M0_dj.label_contrasts_min.grid(row=row, column=2)
        M0_dj.label_contrasts_max = tk.Label(Main)
        M0_dj.label_contrasts_max.grid(row=row, column=3)
        row += 1
        
    if 'concats' in param_list:
        M0_dj.label_concats = tk.Label(Main, text = 'Concatination')
        M0_dj.label_concats.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_concats = tk.Entry(width = 6)
        M0_dj.textBox_concats.insert(0, default.concats)
        M0_dj.textBox_concats.grid(row=row, column=1)
        M0_dj.label_concats_min = tk.Label(Main)
        M0_dj.label_concats_min.grid(row=row, column=2)
        M0_dj.label_concats_max = tk.Label(Main)
        M0_dj.label_concats_max.grid(row=row, column=3)
        row += 1
               
    if 'TR' in param_list:
        M0_dj.label_TR = tk.Label(Main, text = 'TR, s')
        M0_dj.label_TR.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_TR = tk.Entry(Main,width = 6)
        M0_dj.textBox_TR.insert(0, default.TR)
        M0_dj.textBox_TR.grid(row=row, column=1)
        M0_dj.label_TR_min = tk.Label(Main)
        M0_dj.label_TR_min.grid(row=row, column=2)
        M0_dj.label_TR_max = tk.Label(Main)
        M0_dj.label_TR_max.grid(row=row, column=3)
        row += 1
    
    if 'TD' in param_list:
        M0_dj.label_TD = tk.Label(Main, text = 'TD, s')
        M0_dj.label_TD.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_TD = tk.Entry(width = 6)
        M0_dj.textBox_TD.insert(0, default.TD)
        M0_dj.textBox_TD.grid(row=row, column=1)
        M0_dj.label_TD_min = tk.Label(Main)
        M0_dj.label_TD_min.grid(row=row, column=2)
        M0_dj.label_TD_max = tk.Label(Main)
        M0_dj.label_TD_max.grid(row=row, column=3)
        row += 1
        
    M0_dj.label_4 = tk.Label(Main, text = 'RF and gradients', font="Helvetica 10 bold")
    M0_dj.label_4.grid(row=row , column=0,sticky = "E")
    row += 1
        
    if 'FA' in param_list:
        M0_dj.label_FA = tk.Label(Main, text = 'Excitation pulse, degree')
        M0_dj.label_FA.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_FA = tk.Entry(width = 6)
        M0_dj.textBox_FA.insert(0, default.FA)
        M0_dj.textBox_FA.grid(row=row, column=1)
        M0_dj.label_FA_min = tk.Label(Main)
        M0_dj.label_FA_min.grid(row=row, column=2)
        M0_dj.label_FA_max = tk.Label(Main)
        M0_dj.label_FA_max.grid(row=row, column=3)
        row += 1
        
    if 'RA' in param_list:
        M0_dj.label_RA = tk.Label(Main, text = 'Refocusing pulse, degree')
        M0_dj.label_RA.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_RA = tk.Entry(width = 6)
        M0_dj.textBox_RA.insert(0, default.RA)
        M0_dj.textBox_RA.grid(row=row, column=1)
        M0_dj.label_RA_min = tk.Label(Main)
        M0_dj.label_RA_min.grid(row=row, column=2)
        M0_dj.label_RA_max = tk.Label(Main)
        M0_dj.label_RA_max.grid(row=row, column=3)
        row += 1
        
    if 'spoil_strenght' in param_list:
        M0_dj.label_spoil_strenght = tk.Label(Main, text = 'Spoil strenght')
        M0_dj.label_spoil_strenght.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_spoil_strenght = tk.Entry(width = 6)
        M0_dj.textBox_spoil_strenght.insert(0, default.spoil_strenght)
        M0_dj.textBox_spoil_strenght.grid(row=row, column=1)
        M0_dj.label_spoil_strenght_min = tk.Label(Main)
        M0_dj.label_spoil_strenght_min.grid(row=row, column=2)
        M0_dj.label_spoil_strenght_max = tk.Label(Main)
        M0_dj.label_spoil_strenght_max.grid(row=row, column=3)
        row += 1
        
    if 'RF_spoil' in param_list:
        M0_dj.label_RF_spoil = tk.Label(Main, text = 'Spoil strenght')
        M0_dj.label_RF_spoil.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_RF_spoil = tk.Entry(width = 6)
        M0_dj.textBox_RF_spoil.insert(0, default.RF_spoil)
        M0_dj.textBox_RF_spoil.grid(row=row, column=1)
        M0_dj.label_RF_spoil_min = tk.Label(Main)
        M0_dj.label_RF_spoil_min.grid(row=row, column=2)
        M0_dj.label_RF_spoil_max = tk.Label(Main)
        M0_dj.label_RF_spoil_max.grid(row=row, column=3)
        row += 1
    
    M0_dj.label_5 = tk.Label(Main, text = 'Image',font="Helvetica 10 bold")
    M0_dj.label_5.grid(row=row , column=0,sticky = "E")
    row += 1
        
    if 'average' in param_list:
        M0_dj.label_average = tk.Label(Main, text = 'Averages')
        M0_dj.label_average.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_average = tk.Entry(width = 6)
        M0_dj.textBox_average.insert(0, default.average)
        M0_dj.textBox_average.grid(row=row, column=1)
        M0_dj.label_average_min = tk.Label(Main)
        M0_dj.label_average_min.grid(row=row, column=2)
        M0_dj.label_average_max = tk.Label(Main)
        M0_dj.label_average_max.grid(row=row, column=3)
        row += 1
        
    if 'D_scans' in param_list:
        M0_dj.label_D_scans = tk.Label(Main, text = 'Dummy scans')
        M0_dj.label_D_scans.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_D_scans = tk.Entry(width = 6)
        M0_dj.textBox_D_scans.insert(0, default.average)
        M0_dj.textBox_D_scans.grid(row=row, column=1)
        M0_dj.label_D_scans_min = tk.Label(Main)
        M0_dj.label_D_scans_min.grid(row=row, column=2)
        M0_dj.label_D_scans_max = tk.Label(Main)
        M0_dj.label_D_scans_max.grid(row=row, column=3)
        row += 1
        
    if 'ph_over_phase' in param_list:
        M0_dj.label_ph_over_phase = tk.Label(Main, text = 'Phase oversampling, %')
        M0_dj.label_ph_over_phase.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_ph_over_phase = tk.Entry(width = 6)
        M0_dj.textBox_ph_over_phase.insert(0, default.ph_over_phase)
        M0_dj.textBox_ph_over_phase.grid(row=row, column=1)
        M0_dj.label_ph_over_phase_min = tk.Label(Main)
        M0_dj.label_ph_over_phase_min.grid(row=row, column=2)
        M0_dj.label_ph_over_phase_max = tk.Label(Main)
        M0_dj.label_ph_over_phase_max.grid(row=row, column=3)
        row += 1
        
    if 'ph_over_slice' in param_list:
        M0_dj.label_ph_over_slice = tk.Label(Main, text = 'Phase oversampling slice, %')
        M0_dj.label_ph_over_slice.grid(row=row, column=0,sticky = "E")
        M0_dj.textBox_ph_over_slice = tk.Entry(width = 6)
        M0_dj.textBox_ph_over_slice.insert(0, default.ph_over_slice)
        M0_dj.textBox_ph_over_slice.grid(row=row, column=1)
        M0_dj.label_ph_over_slice_min = tk.Label(Main)
        M0_dj.label_ph_over_slice_min.grid(row=row, column=2)
        M0_dj.label_ph_over_slice_max = tk.Label(Main)
        M0_dj.label_ph_over_slice_max.grid(row=row, column=3)
        row += 1
        
    if 'part_fourier_factor_phase' in param_list:
        M0_dj.label_part_fourier_factor_phase= tk.Label(Main, text = 'Partial fourier phase')
        M0_dj.label_part_fourier_factor_phase.grid(row=row, column=0,sticky = "E")
        spinbox_var = tk.StringVar()
        PF=[1, 0.75, 0.55]
        M0_dj.textBox_part_fourier_factor_phase = tk.Spinbox(Main, textvariable=spinbox_var, values=PF,width = 4)
        M0_dj.textBox_part_fourier_factor_phase.grid(row=row, column=1)
        row += 1
        
    if 'part_fourier_factor_slice' in param_list:
        M0_dj.label_part_fourier_factor_slice= tk.Label(Main, text = 'Partial fourier slice')
        M0_dj.label_part_fourier_factor_slice.grid(row=row, column=0,sticky = "E")
        spinbox_var = tk.StringVar()
        PF=[1, 0.75, 0.55]
        M0_dj.textBox_part_fourier_factor_slice = tk.Spinbox(Main, textvariable=spinbox_var, values=PF,width = 4)
        M0_dj.textBox_part_fourier_factor_slice.grid(row=row, column=1)
        row += 1
        
    if 'ZF' in param_list:
        M0_dj.radio_ZF = tk.IntVar() 
        M0_dj.radio_ZF.set(1)
        M0_dj.label_ZF = tk.Label(Main, text = "ZIP:", width = 10)
        M0_dj.label_ZF.grid(row=row, column=0, sticky = "E")
        M0_dj.R_ZF = tk.Radiobutton(Main, text="Off", variable=M0_dj.radio_ZF, value=1) 
        M0_dj.R_ZF.grid(row=row, column=1) 
        M0_dj.R_ZF = tk.Radiobutton(Main, text="On", variable=M0_dj.radio_ZF, value=2) 
        M0_dj.R_ZF.grid(row=row, column=2)
    
    row = 0
    M0_dj.radio_f_w = tk.IntVar() 
    M0_dj.radio_f_w.set(10)

    M0_dj.labelR_1 = tk.Label(Main, text = "f/w contrast:", width = 10)
    M0_dj.labelR_1.grid(row=row, column=4)

    M0_dj.R10_off = tk.Radiobutton(Main, text="off", variable=M0_dj.radio_f_w, value=10) 
    M0_dj.R10_off.grid(row=row, column=5)    
    
    if 'FS' in param_list:
        M0_dj.R11 = tk.Radiobutton(Main, text="FS(+)", variable=M0_dj.radio_f_w, value=11) 
        M0_dj.R11.grid(row=row, column=6) 
    
    if 'SPAIR' in param_list:
        M0_dj.R12 = tk.Radiobutton(Main, text="SPAIR(+)", variable=M0_dj.radio_f_w, value=12) 
        M0_dj.R12.grid(row=row, column=7)
        
    row += 1
    if 'WS' in param_list:
        M0_dj.R13 = tk.Radiobutton(Main, text="WS", variable=M0_dj.radio_f_w, value=13) 
        M0_dj.R13.grid(row=row, column=5)
    
    if 'WE' in param_list:
        M0_dj.R14 = tk.Radiobutton(Main, text="WE", variable=M0_dj.radio_f_w, value=14) 
        M0_dj.R14.grid(row=row, column=6)
    
    row += 1        
    M0_dj.radio_m_p = tk.IntVar() 
    M0_dj.radio_m_p.set(20)
    M0_dj.labelR_2 = tk.Label(Main, text = "magn. prep.:", width = 10)
    M0_dj.labelR_2.grid(row=row, column=4)
    
    M0_dj.R20_off = tk.Radiobutton(Main, text="off", variable=M0_dj.radio_m_p, value=20) 
    M0_dj.R20_off.grid(row=row, column=5)
    
    if 'IR' in param_list:
        M0_dj.R21 = tk.Radiobutton(Main, text="IR(+)", variable=M0_dj.radio_m_p, value=21) 
        M0_dj.R21.grid(row=row, column=6) 
    
    if 'DIR' in param_list:
        M0_dj.R22 = tk.Radiobutton(Main, text="DIR", variable=M0_dj.radio_m_p, value=22) 
        M0_dj.R22.grid(row=row, column=7)
        
    row += 1    
    if 'TIR' in param_list:
        M0_dj.R23 = tk.Radiobutton(Main, text="TIR", variable=M0_dj.radio_m_p, value=23) 
        M0_dj.R23.grid(row=row, column=5)
        
    if 'SR' in param_list:
        M0_dj.R24 = tk.Radiobutton(Main, text="SR", variable=M0_dj.radio_m_p, value=24) 
        M0_dj.R24.grid(row=row, column=6)
    
    if 'T2_prep_IR' in param_list:
        M0_dj.R25 = tk.Radiobutton(Main, text="T2 prep IR", variable=M0_dj.radio_m_p, value=25) 
        M0_dj.R25.grid(row=row, column=7)
    
    row += 1   
    M0_dj.label_min = tk.Label(Main, text = "min", width = 10)
    M0_dj.label_min.grid(row=row, column=6)
    M0_dj.label_max = tk.Label(Main, text = "max", width = 10)
    M0_dj.label_max.grid(row=row, column=7)
    row += 1
    
    if 'TI' in param_list:
        M0_dj.label_TI = tk.Label(Main, text = 'TI, s')
        M0_dj.label_TI.grid(row=row, column=4,sticky = "E")
        M0_dj.textBox_TI = tk.Entry(width = 6)
        M0_dj.textBox_TI.insert(0, default.TI)
        M0_dj.textBox_TI.grid(row=row, column=5)
        M0_dj.label_TI_min = tk.Label(Main)
        M0_dj.label_TI_min.grid(row=row, column=6)
        M0_dj.label_TI_max = tk.Label(Main)
        M0_dj.label_TI_max.grid(row=row, column=7)
        row += 1
       
    if 'N_TI' in param_list:
        M0_dj.label_N_TI = tk.Label(Main, text = 'N_TI effective')
        M0_dj.label_N_TI.grid(row=row, column=4,sticky = "E")
        M0_dj.textBox_N_TI = tk.Entry(width = 6)
        M0_dj.textBox_N_TI.insert(0, default.N_TI)
        M0_dj.textBox_N_TI.grid(row=row, column=5)
        M0_dj.label_N_TI_min = tk.Label(Main)
        M0_dj.label_N_TI_min.grid(row=row, column=6)
        M0_dj.label_N_TI_max = tk.Label(Main)
        M0_dj.label_N_TI_max.grid(row=row, column=7)
        row += 1
        M0_dj.label_TI_eff = tk.Label(Main, text = 'TI eff, s')
        M0_dj.label_TI_eff.grid(row=row, column=4,sticky = "E")
        M0_dj.label_TI_eff_v = tk.Label(Main)
        M0_dj.label_TI_eff_v.grid(row=row, column=5)
        row += 1
        
    if 'b' in param_list:
        M0_dj.label_b = tk.Label(Main, text = 'b')
        M0_dj.label_b.grid(row=row, column=4,sticky = "E")
        M0_dj.textBox_b = tk.Entry(width = 6)
        M0_dj.textBox_b.insert(0, default.b)
        M0_dj.textBox_b.grid(row=row, column=5)
        M0_dj.label_b_min = tk.Label(Main)
        M0_dj.label_b_min.grid(row=row, column=6)
        M0_dj.label_b_max = tk.Label(Main)
        M0_dj.label_b_max.grid(row=row, column=7)
        row += 1
        
    
        
    if 'sat_sl_thkn' in param_list:
        M0_dj.label_sat_sl_thkn = tk.Label(Main, text = 'Sat slice thkn, m')
        M0_dj.label_sat_sl_thkn.grid(row=row, column=4,sticky = "E")
        M0_dj.textBox_sat_sl_thkn = tk.Entry(width = 6)
        M0_dj.textBox_sat_sl_thkn.insert(0, default.sat_sl_thkn)
        M0_dj.textBox_sat_sl_thkn.grid(row=row, column=5)
        M0_dj.label_sat_sl_thkn_min = tk.Label(Main)
        M0_dj.label_sat_sl_thkn_min.grid(row=row, column=6)
        M0_dj.label_sat_sl_thkn_max = tk.Label(Main)
        M0_dj.label_sat_sl_thkn_max.grid(row=row, column=7)
        row += 1
        
    if 'distance_ex_sat' in param_list:
        M0_dj.label_distance_ex_sat = tk.Label(Main, text = 'Sat slice gap (!= 0), m')
        M0_dj.label_distance_ex_sat.grid(row=row, column=4,sticky = "E")
        M0_dj.textBox_distance_ex_sat = tk.Entry(width = 6)
        M0_dj.textBox_distance_ex_sat.insert(0, default.distance_ex_sat)
        M0_dj.textBox_distance_ex_sat.grid(row=row, column=5)
        M0_dj.label_distance_ex_sat_min = tk.Label(Main)
        M0_dj.label_distance_ex_sat_min.grid(row=row, column=6)
        M0_dj.label_distance_ex_sat_max = tk.Label(Main)
        M0_dj.label_distance_ex_sat_max.grid(row=row, column=7)
        row += 1
        
    if 'flow_comp' in param_list:
        M0_dj.radio_flow_comp = tk.IntVar() 
        M0_dj.radio_flow_comp.set(1)
        
        M0_dj.label_flow_comp = tk.Label(Main, text = "Flow-comp.:", width = 10)
        M0_dj.label_flow_comp.grid(row=row, column=4, sticky = "E")
        M0_dj.R1_flow_comp = tk.Radiobutton(Main, text="Off", variable=M0_dj.radio_flow_comp, value=1) 
        M0_dj.R1_flow_comp.grid(row=row, column=5 ) 
        M0_dj.R2_flow_comp = tk.Radiobutton(Main, text="On (freq)", variable=M0_dj.radio_flow_comp, value=2) 
        M0_dj.R2_flow_comp.grid(row=row, column=6 )
        row += 1
        M0_dj.R3_flow_comp = tk.Radiobutton(Main, text="On (slice)", variable=M0_dj.radio_flow_comp, value=3) 
        M0_dj.R3_flow_comp.grid(row=row, column=5 ) 
        M0_dj.R4_flow_comp = tk.Radiobutton(Main, text="Off (freq/slice)", variable=M0_dj.radio_flow_comp, value=4) 
        M0_dj.R4_flow_comp.grid(row=row, column=6 )
        row += 1
        
    if 'recomb' in param_list:
        M0_dj.radio_recomb = tk.IntVar() 
        M0_dj.radio_recomb.set(1)
        
        M0_dj.label_recomb = tk.Label(Main, text = "Recomb-ion:", width = 10)
        M0_dj.label_recomb.grid(row=row, column=4, sticky = "E")
        M0_dj.R1_recomb = tk.Radiobutton(Main, text="Off", variable=M0_dj.radio_recomb, value=1) 
        M0_dj.R1_recomb.grid(row=row, column=5 ) 
        M0_dj.R2_recomb = tk.Radiobutton(Main, text="On", variable=M0_dj.radio_recomb, value=2) 
        M0_dj.R2_recomb.grid(row=row, column=6 )
        row += 1  

    
    return M0_dj