def read_mri_cfg(subject, subjects_dir=None):
 subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
 fname = os.path.join(subjects_dir, subject, 'MRI scaling parameters.cfg')
 if (not os.path.exists(fname)):
  raise IOError(('%r does not seem to be a scaled mri subject: %r does not exist.' % (subject, fname)))
 logger.info(('Reading MRI cfg file %s' % fname))
 config = configparser.RawConfigParser()
 config.read(fname)
 n_params = config.getint('MRI Scaling', 'n_params')
 if (n_params == 1):
  scale = config.getfloat('MRI Scaling', 'scale')
 elif (n_params == 3):
  scale_str = config.get('MRI Scaling', 'scale')
  scale = np.array([float(s) for s in scale_str.split()])
 else:
  raise ValueError(('Invalid n_params value in MRI cfg: %i' % n_params))
 out = {'subject_from': config.get('MRI Scaling', 'subject_from'), 'n_params': n_params, 'scale': scale}
 return out

def read_mri_cfg ( subject , subjects_dir = None ) : subjects_dir = get_subjects_dir ( subjects_dir , raise_error = True ) fname = os . path . join ( subjects_dir , subject , 'MRI scaling parameters.cfg' ) if ( not os . path . exists ( fname ) ) : raise IOError ( ( '%r does not seem to be a scaled mri subject: %r does not exist.' % ( subject , fname ) ) ) logger . info ( ( 'Reading MRI cfg file %s' % fname ) ) config = configparser . RawConfigParser ( ) config . read ( fname ) n_params = config . getint ( 'MRI Scaling' , 'n_params' ) if ( n_params == 1 ) : scale = config . getfloat ( 'MRI Scaling' , 'scale' ) elif ( n_params == 3 ) : scale_str = config . get ( 'MRI Scaling' , 'scale' ) scale = np . array ( [ float ( s ) for s in scale_str . split ( ) ] ) else : raise ValueError ( ( 'Invalid n_params value in MRI cfg: %i' % n_params ) ) out = { 'subject_from' : config . get ( 'MRI Scaling' , 'subject_from' ) , 'n_params' : n_params , 'scale' : scale } return out
read information from the cfg file of a scaled mri brain .