def _to_forward_dict(fwd, names, fwd_grad=None, coord_frame=FIFF.FIFFV_COORD_HEAD, source_ori=FIFF.FIFFV_MNE_FREE_ORI):
 assert (names is not None)
 if (len(fwd) == 0):
  return None
 sol = dict(data=fwd.T, nrow=fwd.shape[1], ncol=fwd.shape[0], row_names=names, col_names=[])
 fwd = Forward(sol=sol, source_ori=source_ori, nsource=sol['ncol'], coord_frame=coord_frame, sol_grad=None, nchan=sol['nrow'], _orig_source_ori=source_ori, _orig_sol=sol['data'].copy(), _orig_sol_grad=None)
 if (fwd_grad is not None):
  sol_grad = dict(data=fwd_grad.T, nrow=fwd_grad.shape[1], ncol=fwd_grad.shape[0], row_names=names, col_names=[])
  fwd.update(dict(sol_grad=sol_grad), _orig_sol_grad=sol_grad['data'].copy())
 return fwd

def _to_forward_dict ( fwd , names , fwd_grad = None , coord_frame = FIFF . FIFFV_COORD_HEAD , source_ori = FIFF . FIFFV_MNE_FREE_ORI ) : assert ( names is not None ) if ( len ( fwd ) == 0 ) : return None sol = dict ( data = fwd . T , nrow = fwd . shape [ 1 ] , ncol = fwd . shape [ 0 ] , row_names = names , col_names = [ ] ) fwd = Forward ( sol = sol , source_ori = source_ori , nsource = sol [ 'ncol' ] , coord_frame = coord_frame , sol_grad = None , nchan = sol [ 'nrow' ] , _orig_source_ori = source_ori , _orig_sol = sol [ 'data' ] . copy ( ) , _orig_sol_grad = None ) if ( fwd_grad is not None ) : sol_grad = dict ( data = fwd_grad . T , nrow = fwd_grad . shape [ 1 ] , ncol = fwd_grad . shape [ 0 ] , row_names = names , col_names = [ ] ) fwd . update ( dict ( sol_grad = sol_grad ) , _orig_sol_grad = sol_grad [ 'data' ] . copy ( ) ) return fwd
convert forward solution matrices to dicts .