def select_source_in_label(src, label, random_state=None, location='random', subject=None, subjects_dir=None, surf='sphere'):
 lh_vertno = list()
 rh_vertno = list()
 if ((not isinstance(location, string_types)) or (location not in ('random', 'center'))):
  raise ValueError(('location must be "random" or "center", got %s' % (location,)))
 rng = check_random_state(random_state)
 if (label.hemi == 'lh'):
  vertno = lh_vertno
  hemi_idx = 0
 else:
  vertno = rh_vertno
  hemi_idx = 1
 src_sel = np.intersect1d(src[hemi_idx]['vertno'], label.vertices)
 if (location == 'random'):
  idx = src_sel[rng.randint(0, len(src_sel), 1)[0]]
 else:
  idx = label.center_of_mass(subject, restrict_vertices=src_sel, subjects_dir=subjects_dir, surf=surf)
 vertno.append(idx)
 return (lh_vertno, rh_vertno)

def select_source_in_label ( src , label , random_state = None , location = 'random' , subject = None , subjects_dir = None , surf = 'sphere' ) : lh_vertno = list ( ) rh_vertno = list ( ) if ( ( not isinstance ( location , string_types ) ) or ( location not in ( 'random' , 'center' ) ) ) : raise ValueError ( ( 'location must be "random" or "center", got %s' % ( location , ) ) ) rng = check_random_state ( random_state ) if ( label . hemi == 'lh' ) : vertno = lh_vertno hemi_idx = 0 else : vertno = rh_vertno hemi_idx = 1 src_sel = np . intersect1d ( src [ hemi_idx ] [ 'vertno' ] , label . vertices ) if ( location == 'random' ) : idx = src_sel [ rng . randint ( 0 , len ( src_sel ) , 1 ) [ 0 ] ] else : idx = label . center_of_mass ( subject , restrict_vertices = src_sel , subjects_dir = subjects_dir , surf = surf ) vertno . append ( idx ) return ( lh_vertno , rh_vertno )
select source positions using a label .