diff --git a/nsdcode/nsd_mapdata.py b/nsdcode/nsd_mapdata.py index 10df283..f7b4247 100644 --- a/nsdcode/nsd_mapdata.py +++ b/nsdcode/nsd_mapdata.py @@ -29,6 +29,7 @@ def fit(self, outputfile=None, outputclass=None, fsdir=None, + transformfile=None, ): """nsa_mapdata is used to map functional data between coordinate systems @@ -211,6 +212,8 @@ def fit(self, res = None # load transform + if transformfile is not None: + tfile=transformfile a1_data = load_transform(casenum, tfile) # load sourcedata diff --git a/nsdcode/nsdmapcli.py b/nsdcode/nsdmapcli.py new file mode 100644 index 0000000..9e1b138 --- /dev/null +++ b/nsdcode/nsdmapcli.py @@ -0,0 +1,55 @@ +import os +import sys +import argparse +import textwrap +from nsdcode.nsd_mapdata import NSDmapdata +from nsdcode.nsd_datalocation import nsd_datalocation + +def argument_parse(): + parser=argparse.ArgumentParser(description='Transform NSD data from the command line', + epilog=textwrap.dedent('''\ + --sourcespace and --targetspace options include: + anat0pt5, anat0pt8, anat1pt0, func1pt0, func1pt8, MNI, + [lh,rh].white, [lh,rh].pial, [lh,rh].layerB1, [lh,rh].layerB2, [lh,rh].layerB3, fsaverage''')) + + parser.add_argument('--sourcespace',action='store',dest='sourcespace',help="One of the volume/surface space options below",required=True) + parser.add_argument('--targetspace',action='store',dest='targetspace',help="One of the volume/surface space options below",required=True) + parser.add_argument('--inputfile',action='store',dest='inputfile',help="Input file in ",required=True) + parser.add_argument('--outputfile',action='store',dest='outputfile',help="Output file in ",required=True) + parser.add_argument('--nsdlocation',action='store',dest='basedir',default=None,help='Directory containing ppdata/, etc') + parser.add_argument('--subjix',action='store',dest='subjix',type=int,help="NSD subject index 1-8") + parser.add_argument('--interptype',action='store',dest='interptype',default='cubic', + choices=['nearest','linear','cubic','wta','surfacewta'], + help="default: 'cubic'. See nsd_mapdata.py for wta details") + parser.add_argument('--badval',action='store',dest='badval',default=None) + parser.add_argument('--outputclass',action='store',dest='outputclass',default=None) + parser.add_argument('--fsdir',action='store',dest='fsdir',default=None) + parser.add_argument('--transformfile',action='store',dest='transformfile',default=None, + help="Manually-specified transformation file (ignores --nsdlocation and --subjix)") + + return parser.parse_args() + +def main(): + args=argument_parse() + #if transform file was provided, we can ignore the basedir and subjix and just set defaults + if args.transformfile is not None: + if args.basedir is None: + args.basedir=nsd_datalocation(".") + if args.subjix is None: + args.subjix=1 + NSD=NSDmapdata(args.basedir) + NSD.fit(subjix=args.subjix, + sourcespace=args.sourcespace, + targetspace=args.targetspace, + sourcedata=args.inputfile, + interptype=args.interptype, + badval=args.badval, + outputfile=args.outputfile, + outputclass=args.outputclass, + fsdir=args.fsdir, + transformfile=args.transformfile, + ) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/setup.py b/setup.py index d519046..2e693e0 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,12 @@ def local_version(version): opts = dict( use_scm_version={"root": ".", "relative_to": __file__, "write_to": op.join("nsdcode", "version.py"), - "local_scheme": local_version} + "local_scheme": local_version}, + entry_points={ + 'console_scripts': [ + 'nsdmapdata = nsdcode.nsdmapcli:main', + ], + }, )