recon_surf.create_annotation

recon_surf.create_annotation.build_annot(all_labels, all_values, col_ids, trg_white, cortex_label_name=None)[source]

Create an annotation from multiple labels.

Here we also consider the label values and overwrite existing labels if values of current are larger (or equal, so the order of the labels matters). No output is written.

Parameters:
all_labelsnpt.ArrayLike

List of all Labels.

all_valuesnpt.ArrayLike

List of all values.

col_idsnpt.ArrayLike

List of col ids.

trg_whiteUnion[str, npt.NDArray]

Target file of white.

cortex_label_nameOptional[str]

Path to the cortex label file. Defaults to None.

Returns:
annot_ids

Ids of build Annotations.

annot_vals

Values of build Annotations.

recon_surf.create_annotation.create_annotation(options, verbose=True)[source]

Map (if required), build and write annotation.

(Main function)

Parameters:
optionsAny

Object holding options hemi: “lh” or “rh” for reading labels colortab: colortab with label ids, names and colors labeldir: dir where to find the label files (when reading) white: path/filename of white surface for the annotation outannot: path to output annotation file cortex: optional path to hemi.cortex for optional masking of annotation to only cortex append: optional, e.g. “.thresh” can be appended to label names (I/O) for exvivo FS labels srcsphere: optional, when mapping: path to src sphere.reg trgsphere: optional, when mapping: path to trg sphere.reg.

verbosebool

True if options should be printed. Defaults to True.

recon_surf.create_annotation.map_multiple_labels(hemi, src_dir, src_labels, src_sphere_name, trg_sphere_name, trg_white_name, trg_sid, out_dir=None, stop_missing=True)[source]

Map a list of labels from one surface (e.g. fsavaerage sphere.reg) to another.

Labels are just names without hemisphere or path, which are passed via hemi, src_dir, out_dir).

Parameters:
hemistr

“lh” or “rh” for reading labels.

src_dirstr

Director of the source file.

src_labelsnpt.ArrayLike

List of labels.

src_sphere_namestr

Filename of source sphere.

trg_sphere_namestr

Filename of target sphere.

trg_white_namestr

Filename of target white.

trg_sidstr

Target subject id.

out_dirOptional[str]

Directory for output, defaults to None.

stop_missingbool

Determines whether to stop on a missing src label file, or continue with a warning. Defaults to True.

Returns:
all_labels

Mapped labels.

all_values

Values of mapped labels.

Raises:
ValueError

Label file missing.

recon_surf.create_annotation.options_parse()[source]

Command line option parser.

Returns:
options

Object holding options.

recon_surf.create_annotation.read_colortable(colortab_name)[source]

Read the colortable of given name.

Parameters:
colortab_namestr

Path and Name of the colortable file.

Returns:
ids

List of ids.

names

List of names.

colors

List of colors corresponding to ids and names.

recon_surf.create_annotation.read_multiple_labels(hemi, input_dir, label_names)[source]

Read multiple label files from input_dir.

Parameters:
hemistr

“lh” or “rh” for reading labels.

input_dirstr

Director of the source.

label_namesnpt.ArrayLike

List of labels.

Returns:
all_labels

Read labels.

all_values

Values of read labels.

recon_surf.create_annotation.write_annot(annot_ids, label_names, colortab_name, out_annot, append='')[source]

Combine the colortable with the annotations ids to write an annotation file.

The annotation file contains colortable information Care needs to be taken that the colortable file has the same number and order of labels as specified in the label_names list.

Parameters:
annot_idsnpt.ArrayLike

List of annotation ids.

label_namesnpt.ArrayLike

List of label names.

colortab_namestr

Path and name of colortable file.

out_annotstr

Path and name of output annotation file.

appendUnion[None, str]

String to append to colour name. Defaults to “”.