cvnlab / nsdcode

Code related to analyzing the Natural Scenes Dataset
BSD 2-Clause "Simplified" License
30 stars 8 forks source link

Add CLI for transforming files (and minor nsd_mapdata.py tweak) #14

Open kjamison opened 3 years ago

kjamison commented 3 years ago

Tweak mapdata to bypass nsdpath and accept transform file

iancharest commented 3 years ago

Hey that's a great idea! Perhaps it would be useful to modify the setup file with an entry point for the console?

entry_points={
        'console_scripts': [
            'nsdmapdata = nsdmapcli:main',
        ],
    },

Otherwise the code looks good and should be useful indeed. Maybe worth adding an example of how to use it straight from the console?

e.g. if we make the change to the setup script, then it would be :

nsdmapdata -h

to get some help on how to use?

kjamison commented 3 years ago

Updated accordingly (See the updated commit) Wasn't sure where to include the example usage, but it would be something like: nsdmapdata --sourcespace MNI --targetspace func1pt8 --inputfile atlas_in_MNI.nii.gz --outputfile atlas_in_subj01.nii.gz --interptype nearest --nsdlocation <mynsdfolder> --subjix 1 or nsdmapdata --sourcespace MNI --targetspace func1pt8 --inputfile atlas_in_MNI.nii.gz --outputfile atlas_in_subj01.nii.gz --interptype nearest --transformfile <mynsdfolder>/ppdata/subj01/transforms/MNI-to-func1pt8.nii.gz

kjamison commented 3 years ago

Oh I see you just meant the help info. Currently that looks like:

$ nsdmapdata -h
usage: nsdmapdata [-h] --sourcespace SOURCESPACE --targetspace TARGETSPACE
                  --inputfile INPUTFILE --outputfile OUTPUTFILE
                  [--nsdlocation BASEDIR] [--subjix SUBJIX]
                  [--interptype {nearest,linear,cubic,wta,surfacewta}]
                  [--badval BADVAL] [--outputclass OUTPUTCLASS]
                  [--fsdir FSDIR] [--transformfile TRANSFORMFILE]

Transform NSD data from the command line

optional arguments:
  -h, --help            show this help message and exit
  --sourcespace SOURCESPACE
                        One of the volume/surface space options below
  --targetspace TARGETSPACE
                        One of the volume/surface space options below
  --inputfile INPUTFILE
                        Input file in <sourcespace>
  --outputfile OUTPUTFILE
                        Output file in <targetspace>
  --nsdlocation BASEDIR
                        Directory containing ppdata/, etc
  --subjix SUBJIX       NSD subject index 1-8
  --interptype {nearest,linear,cubic,wta,surfacewta}
                        default: 'cubic'. See nsd_mapdata.py for wta details
  --badval BADVAL
  --outputclass OUTPUTCLASS
  --fsdir FSDIR
  --transformfile TRANSFORMFILE
                        Manually-specified transformation file (ignores
                        --nsdlocation and --subjix)

--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