def _scale_params(subject_to, subject_from, scale, subjects_dir):
 subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
 if ((subject_from is None) != (scale is None)):
  raise TypeError('Need to provide either both subject_from and scale parameters, or neither.')
 if (subject_from is None):
  cfg = read_mri_cfg(subject_to, subjects_dir)
  subject_from = cfg['subject_from']
  n_params = cfg['n_params']
  scale = cfg['scale']
 else:
  scale = np.asarray(scale)
  if (scale.ndim == 0):
   n_params = 1
  elif (scale.shape == (3,)):
   n_params = 3
  else:
   raise ValueError(('Invalid shape for scale parameer. Need scalar or array of length 3. Got %s.' % str(scale)))
 if (n_params == 1):
  nn_scale = None
 elif (n_params == 3):
  nn_scale = (1.0 / scale)
 else:
  raise RuntimeError(('Invalid n_params value: %s' % repr(n_params)))
 return (subjects_dir, subject_from, scale, nn_scale)

def _scale_params ( subject_to , subject_from , scale , subjects_dir ) : subjects_dir = get_subjects_dir ( subjects_dir , raise_error = True ) if ( ( subject_from is None ) != ( scale is None ) ) : raise TypeError ( 'Need to provide either both subject_from and scale parameters, or neither.' ) if ( subject_from is None ) : cfg = read_mri_cfg ( subject_to , subjects_dir ) subject_from = cfg [ 'subject_from' ] n_params = cfg [ 'n_params' ] scale = cfg [ 'scale' ] else : scale = np . asarray ( scale ) if ( scale . ndim == 0 ) : n_params = 1 elif ( scale . shape == ( 3 , ) ) : n_params = 3 else : raise ValueError ( ( 'Invalid shape for scale parameer. Need scalar or array of length 3. Got %s.' % str ( scale ) ) ) if ( n_params == 1 ) : nn_scale = None elif ( n_params == 3 ) : nn_scale = ( 1.0 / scale ) else : raise RuntimeError ( ( 'Invalid n_params value: %s' % repr ( n_params ) ) ) return ( subjects_dir , subject_from , scale , nn_scale )
assemble parameters for scaling .