Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nsdcode/nsd_mapdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions nsdcode/nsdmapcli.py
Original file line number Diff line number Diff line change
@@ -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 <sourcespace>",required=True)
parser.add_argument('--outputfile',action='store',dest='outputfile',help="Output file in <targetspace>",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()
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
)


Expand Down