def main(args):
<EOL>(args, opts) = _surface_to_ribbon_parser(args)<EOL>if opts['<STR_LIT>']:<EOL><INDENT>print(info, file=sys.stdout)<EOL>return <NUM_LIT:1><EOL><DEDENT>verbose = opts['<STR_LIT>']<EOL>def note(s):<EOL><INDENT>if verbose: print(s, file=sys.stdout)<EOL>return verbose<EOL><DEDENT>if '<STR_LIT>' in opts and opts['<STR_LIT>'] is not None:<EOL><INDENT>add_subject_path(opts['<STR_LIT>'])<EOL><DEDENT>(lhfl, rhfl) = (opts['<STR_LIT>'], opts['<STR_LIT>'])<EOL>if len(args) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif len(args) == <NUM_LIT:1>:<EOL><INDENT>sub = find_subject_path(os.getenv('<STR_LIT>'))<EOL>outfl = args[<NUM_LIT:0>]<EOL><DEDENT>elif len(args) == <NUM_LIT:2>:<EOL><INDENT>sbpth = find_subject_path(args[<NUM_LIT:0>])<EOL>if sbpth is not None:<EOL><INDENT>sub = sbpth<EOL><DEDENT>else:<EOL><INDENT>sub = find_subject_path(os.getenv('<STR_LIT>'))<EOL>if lhfl is not None: rhfl = args[<NUM_LIT:0>]<EOL>elif rhfl is not None: lhfl = args[<NUM_LIT:0>]<EOL>else: raise ValueError('<STR_LIT>' % args[<NUM_LIT:0>])<EOL><DEDENT>outfl = args[<NUM_LIT:1>]<EOL><DEDENT>elif len(args) == <NUM_LIT:3>:<EOL><INDENT>sbpth0 = find_subject_path(args[<NUM_LIT:0>])<EOL>sbpth1 = find_subject_path(args[<NUM_LIT:1>])<EOL>if sbpth0 is not None:<EOL><INDENT>sub = sbpth0<EOL>if lhfl is not None: rhfl = args[<NUM_LIT:1>]<EOL>elif rhfl is not None: lhfl = args[<NUM_LIT:1>]<EOL>else: raise ValueError('<STR_LIT>' % args[<NUM_LIT:1>])<EOL><DEDENT>elif sbpth1 is not None:<EOL><INDENT>sub = sbpth1<EOL>if lhfl is not None: rhfl = args[<NUM_LIT:0>]<EOL>elif rhfl is not None: lhfl = args[<NUM_LIT:0>]<EOL>else: raise ValueError('<STR_LIT>' % args[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>sub = find_subject_path(os.getenv('<STR_LIT>'))<EOL>if lhfl is not None or rhfl is not None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>(lhfl, rhfl) = args<EOL><DEDENT>outfl = args[<NUM_LIT:2>]<EOL><DEDENT>elif len(args) == <NUM_LIT:4>:<EOL><INDENT>if lhfl is not None or rhfl is not None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>subidx = next((i for (i,a) in enumerate(args) if find_subject_path(a) is not None), None)<EOL>if subidx is None: raise ValueError('<STR_LIT>')<EOL>sub = find_subject_path(args[subidx])<EOL>del args[subidx]<EOL>(lhfl, rhfl, outfl) = args<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if sub is None: raise ValueError('<STR_LIT>')<EOL>if lhfl is None and rhfl is None: raise ValueError('<STR_LIT>')<EOL>method = opts['<STR_LIT>'].lower()<EOL>if method not in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>' % method)<EOL><DEDENT>if opts['<STR_LIT>'] is None: dtyp = None<EOL>elif opts['<STR_LIT>'].lower() == '<STR_LIT:float>': dtyp = np.float32<EOL>elif opts['<STR_LIT>'].lower() == '<STR_LIT:int>': dtyp = np.int32<EOL>else: raise ValueError('<STR_LIT>')<EOL>if method == '<STR_LIT>':<EOL><INDENT>if dtyp is np.float32: method = '<STR_LIT>'<EOL>elif dtyp is np.int32: method = '<STR_LIT>'<EOL>else: method = '<STR_LIT>'<EOL><DEDENT>note('<STR_LIT>')<EOL>(lhdat, rhdat) = (None, None)<EOL>if lhfl is not None:<EOL><INDENT>note('<STR_LIT>' % lhfl)<EOL>lhdat = read_surf_file(lhfl)<EOL><DEDENT>if rhfl is not None:<EOL><INDENT>note('<STR_LIT>' % rhfl)<EOL>rhdat = read_surf_file(rhfl)<EOL><DEDENT>(dat, hemi) = (rhdat, '<STR_LIT>') if lhdat is None else(lhdat, '<STR_LIT>') if rhdat is None else((lhdat, rhdat), None)<EOL>sub = subject(sub)<EOL>note('<STR_LIT>')<EOL>vol = sub.cortex_to_image(dat, hemi=hemi, method=method, fill=opts['<STR_LIT>'], dtype=dtyp)<EOL>note('<STR_LIT>' % outfl)<EOL>save(outfl, vol, affine=sub.voxel_to_native_matrix)<EOL>note('<STR_LIT>')<EOL>return <NUM_LIT:0><EOL>
surface_to_rubbon.main(args) can be given a list of arguments, such as sys.argv[1:]; these
arguments may include any options and must include exactly one subject id and one output
filename. Additionally one or two surface input filenames must be given. The surface files are
projected into the ribbon and written to the output filename. For more information see the
string stored in surface_to_image.info.