Scanner
The functions and classes in this file are designed transform the target vertex from one space to the line-scanning session space
- class fmriproc.scanner.Scanner[source]
Bases:
objectThis object combines the information from the CalcBestVertex and pRFCalc classes to fetch the best vertex and related information from the surfaces. In fact, it runs these classes internally, so you’d only have to specify this class in order to run the others as well. At the minimum, you need to specify the subject ID as defined in the FreeSurfer/pycortex/ BIDS-anat directory, the dictionary resulting from CalcBestVertex, the matrix mapping session 1 to session 2 (the ‘fs2ses=’ flag), the hemisphere you’re interested in, and the FreeSurfer directory.
- Parameters:
subject (str) – subject-ID corresponding to the name in the pycortex filestore directory (mandatory!! for looking up how much the image has been moved when imported from FreeSurfer to Pycortex)
df (dict) – output from optimal.target_vertex; a dictionary containing the result from
linescanning.optimal.CalcBestVertexfs2ses (str, numpy.ndarray) – (4,4) array or path to matrix file mapping FreeSurfer to the new session. It sort of assumes the matrix has been created with ANTs, so make sure the have run call_antsregistration. Enter ‘identity’ to use an identity matrix; this is useful if you want to plan the line in FreeSurfer-space (before session 2)
new_anat (str) – string pointing to the new anatomy file. Generally this is in <project>/sourcedata/<subject>/<ses>/planning/nifti, if you’ve ran spinoza_lineplanning. Should be the fixed input for call_antsregistration to create fs2ses
hemisphere (str) – hemisphere you’re interested in. Should be ‘right’ or ‘left’. It will do all operations on both hemispheres anyway, but only print the actual values you need to insert in the MR console for the specified hemisphere
fs_dir (str) – path to FreeSurfer directory; will default to SUBJECTS_DIR if left empty.
ses (int, optional) – session ID of new session. Generally this will be ses-2, pointing to a line-scanning session. Should be >1
print_to_console (bool) – boolean whether to print the translation/rotations that should be inserted in the console to the terminal. Can be turned off for debugging reasons
debug (bool) – boolean for debugging mode; if True, we’ll print more information about the (converted) angles/normal vectors
- Returns:
sets attributes in an instantiation of :class:fmriproc.scanner.Scanner and will lead to printing of information for the MR-console (if print_to_console=True)
- Return type:
Attr
Example
scan = scanner.Scanner( optimal.target_vertex('sub-001'), fs2ses='genaff.mat', hemi='left', new_anat='path/to/sub-001_ses-2_T1w.nii.gz' )
- warp_normals()[source]
Apply a rigid-body transformation on a vector. Important here is that the coordinate systems used are the same: e.g., only warp an RAS-vector with an RAS-matrix, and a LPS-vector with an LPS-matrix. ANTs outputs per definition an LPS-matrix, so we’d need to convert that with ConvertTransformFile first.
- Parameters:
hemi (str (default = 'both')) – the dataframe has a normal vector for the left hemisphere and right hemisphere. Easiest to leave this to what it is.
system (str (default = 'ras')) – if we warp an RAS-vector we need an RAS matrix, if we warp an LPS vector we need an LPS matrix. The function totate_normal will actually deal with this problem
Example
self.warp_normal = self.warp_normals()