def _sort_components(ica, order, copy=True):
 assert (ica.n_components_ == len(order))
 if copy:
  ica = ica.copy()
 ica.mixing_matrix_ = ica.mixing_matrix_[:, order]
 ica.unmixing_matrix_ = ica.unmixing_matrix_[order, :]
 if isinstance(order, np.ndarray):
  order = list(order)
 if ica.exclude:
  ica.exclude = [order.index(ic) for ic in ica.exclude]
 for k in ica.labels_.keys():
  ica.labels_[k] = [order.index(ic) for ic in ica.labels_[k]]
 return ica

def _sort_components ( ica , order , copy = True ) : assert ( ica . n_components_ == len ( order ) ) if copy : ica = ica . copy ( ) ica . mixing_matrix_ = ica . mixing_matrix_ [ : , order ] ica . unmixing_matrix_ = ica . unmixing_matrix_ [ order , : ] if isinstance ( order , np . ndarray ) : order = list ( order ) if ica . exclude : ica . exclude = [ order . index ( ic ) for ic in ica . exclude ] for k in ica . labels_ . keys ( ) : ica . labels_ [ k ] = [ order . index ( ic ) for ic in ica . labels_ [ k ] ] return ica
change the order of components in ica solution .