I have to work with a bunch of if
statement in one code. They are all the same with slight changes. Is there any way how I can compromise all this code and make it more elegant and shorter ?
Code below:
if con_name == 'coh':
coh = my_coherence(n_freqs, Rxy_mean, Rxx_mean, Ryy_mean)
coh_surro = my_coherence(n_freqs, Rxy_s_mean, Rxx_s_mean, Ryy_s_mean)
return coh, coh_surro, freqs, freqs_surro
if con_name == 'imcoh':
imcoh = my_imcoh(n_freqs, Rxy_mean, Rxx_mean, Ryy_mean)
imcoh_surro = my_imcoh(n_freqs, Rxy_s_mean, Rxx_s_mean, Ryy_s_mean)
return imcoh, imcoh_surro, freqs, freqs_surro
if con_name == 'cohy':
cohy = my_cohy(n_freqs, Rxy_mean, Rxx_mean, Ryy_mean)
cohy_surro = my_cohy(n_freqs, Rxy_s_mean, Rxx_s_mean, Ryy_s_mean)
return cohy, cohy_surro, freqs, freqs_surro
if con_name == 'plv':
plv = my_plv(n_freqs, Rxy, Rxy_mean)
plv_surro = my_plv(n_freqs, Rxy_s, Rxy_s_mean)
return plv, plv_surro, freqs, freqs_surro
if con_name == 'pli':
pli = my_pli(n_freqs, Rxy, Rxy_mean)
pli_surro = my_pli(n_freqs, Rxy_s, Rxy_s_mean)
return pli, pli_surro, freqs, freqs_surro
if con_name == 'wpli':
wpli = my_wpli(n_freqs, Rxy, Rxy_mean)
wpli_surro = my_wpli(n_freqs, Rxy_s, Rxy_s_mean)
return wpli, wpli_surro, freqs, freqs_surro
I am sorry if this is to easy, but I tried and tried and can't figure out a way.
Aucun commentaire:
Enregistrer un commentaire