cortex.freesurfer.autoflatten_subject

cortex.freesurfer.autoflatten_subject(freesurfer_subject: str, pycortex_subject: str | None = None, freesurfer_subject_dir: str | None = None, autoflatten_args: Sequence[str] | None = None, import_flatmaps: bool = True) → dict[str, str][source]

Automatically cut and flatten a freesurfer subject with autoflatten.

This runs the autoflatten pipeline on the freesurfer subject, which projects a template set of cuts onto the subject’s surfaces and flattens the resulting patches, and then imports the flatmaps into the pycortex database with cortex.freesurfer.import_flat.

autoflatten is an optional dependency; install it with pip install "pycortex[autoflatten]".

Parameters:
freesurfer_subjectstr

Freesurfer subject name.

pycortex_subjectstr, optional

Pycortex subject name to import the flatmaps into. By default it uses the freesurfer subject name.

freesurfer_subject_dirstr, optional

Freesurfer subjects directory to work in. By default uses the directory given by the environment variable $SUBJECTS_DIR.

autoflatten_argslist of str, optional

Extra command line arguments passed to autoflatten run, for example ["--backend", "freesurfer"] or ["--n-cores", "4"]. See autoflatten run --help for the available options. Note that --output-dir must not be changed, since the flat patches are expected in the freesurfer subject’s surf/ directory.

import_flatmapsbool, optional

Whether to import the resulting flatmaps into the pycortex database (True by default). Note that importing the flatmaps deletes the overlays.svg file and all cached files for the pycortex subject, since the flatmaps change.

Returns:
flat_filesdict

Mapping from hemisphere (lh, rh, or just one of them if autoflatten_args selects a single hemisphere) to the flat patch file that autoflatten produced.

Notes

This function requires freesurfer to be sourced, and takes a while to run (typically 15-30 minutes for both hemispheres). Patches that already exist are not recomputed; pass autoflatten_args=["--overwrite"] to force autoflatten to flatten the surfaces again.