Several code resources are provided with the NSD dataset. See the nsddatapaper github repository for an archive of code used in the NSD data paper. Below, we document other resources.
This repository contains the utility nsd_mapdata.{m,py}, which helps map data between the various spaces used in the NSD dataset (see Spaces for imaging data). In brief, transformations between various spaces (e.g. functional, anatomical, MNI, fsaverage) have been pre-computed, and the utility simply loads in these transformations and applies them to user-supplied data.
Example scripts demonstrating usage of nsd_mapdata are provided: examples_nsdmapdata.{m,py}. In addition, we provide a video that walks through the example script: https://www.youtube.com/watch?v=XeiyFEr29gA
Three types of interpolation are available: nearest-neighbor, linear, or cubic.
Be careful about the choice of interpolation. In particular, when mapping volume data to the cortical surface, it is easy for "holes" to occur, depending on the extent to which valid values exist in the volume data and depending on the type of interpolation used.
In general, transformation between volume and surface spaces is lossy, in the sense that information loss and discretization errors are inevitable. One strategy is to perform analysis of the functional data fully in volume format and then transform to surface space at the very end (e.g. for visualization). A different strategy is to simply start up front with the "nativesurface" preparation (in which we have already transformed/interpolated the NSD betas to FreeSurfer's surface space) and then conduct analyses.
The conversion of surface data to volume format is a tricky procedure that involves certain assumptions. One particular method is implemented by nsd_mapdata (and is described in the NSD data paper), and this method was used in order to create volumetric versions of surface-oriented ROI labels (e.g. prf-visualrois). Other methods are possible.