cortex.freesurfer.import_subj¶
- cortex.freesurfer.import_subj(freesurfer_subject, pycortex_subject=None, freesurfer_subject_dir=None, whitematter_surf='smoothwm', autoflatten=True, autoflatten_args=None)[source]¶
Imports a subject from freesurfer
This will overwrite (after giving a warning and an option to continue) the pre-existing subject, including all blender cuts, masks, transforms, etc., and re-generate surface info files (curvature, sulcal depth, thickness) stored in the surfinfo/ folder for the subject. All cached files for the subject will be deleted.
- Parameters:
- freesurfer_subjectstr
Freesurfer subject name
- pycortex_subjectstr, optional
Pycortex subject name. By default it uses the freesurfer subject name. It is advised to stick to that convention, if possible (your life will go more smoothly.)
- freesurfer_subject_dirstr, optional
Freesurfer subject directory to pull data from. By default uses the directory given by the environment variable $SUBJECTS_DIR.
- whitematter_surfstr, optional
Which whitematter surface to import as ‘wm’. By default uses ‘smoothwm’, but that surface is smoothed and may not be appropriate. A good alternative is ‘white’.
- autoflattenbool, optional
Whether to automatically cut and flatten the surfaces with autoflatten after importing them (True by default), see autoflatten_subject. This step takes a while, typically 15-30 minutes for both hemispheres; set it to False to skip it and cut and flatten the surfaces yourself (or run autoflatten_subject later). autoflatten is an optional dependency; if it is not installed, a warning is issued and this step is skipped.
- autoflatten_argslist of str, optional
Extra command line arguments passed to
autoflatten run, for example["--backend", "freesurfer"]. Ignored if autoflatten is False.
Notes
This function uses command line functions from freesurfer, so you should make sure to have freesurfer sourced before running this function.
This function will also generate the fiducial surfaces for the subject, which are halfway between the white matter and pial surfaces. The surfaces will be stored in the freesurfer subject’s directory. These fiducial surfaces are used for cutting and flattening.
Imported files
Only the files listed below are copied over. They are read from the freesurfer subject directory,
{freesurfer_subject_dir}/{freesurfer_subject}/, and written into the pycortex filestore entry for the subject,{pycortex_filestore}/{pycortex_subject}/. Flat surfaces are created and imported by autoflatten_subject at the end of this function, unless autoflatten is False; to import flat surfaces that were cut and flattened by hand, use import_flat. Labels and annotations are not imported; use get_label for those.Anatomical volumes, converted with
mri_convert:freesurfer file
pycortex file
contents
mri/T1.mgzanatomicals/raw.nii.gzT1-weighted anatomical
mri/aseg.mgzanatomicals/aseg.nii.gzautomatic segmentation
mri/wm.mgzanatomicals/raw_wm.nii.gzwhite matter segmentation
Surfaces, for both hemispheres (
lhandrh), converted withmris_convert --to-scannerso that they share the coordinate system of the anatomical volumes rather than freesurfer’s TKR coordinate system:freesurfer file
pycortex file
contents
surf/?h.smoothwmsurfaces/wm_?h.giiwhite matter surface
surf/?h.pialsurfaces/pia_?h.giipial surface
surf/?h.inflatedsurfaces/inflated_?h.giiinflated surface
The white matter surface that is imported as
wmis whichever surface is named by the whitematter_surf parameter (smoothwmby default), so the first row above readssurf/?h.{whitematter_surf}.Surface info, where both hemispheres are stored together in a single
.npzfile with the keysleftandright. Note that the values are stored negated with respect to the freesurfer values:freesurfer files
pycortex file
contents
surf/?h.sulcsurface-info/sulcaldepth.npzsulcal depth
surf/?h.thicknesssurface-info/thickness.npzcortical thickness
surf/?h.curvsurface-info/curvature.npzcurvature