Skip to content

Segment Properties

Note

Autogeneration of the function reference does not capture the full range of segment properties. Please see the documentation for the individual segment types if you want to build segment properties manually.

SegmentProperties(ids, label_property=None, description_property=None, tag_properties=None, string_properties=None, number_properties=None)

from_dataframe(df, id_col='pt_root_id', label_col=None, description_col=None, string_cols=None, number_cols=None, tag_value_cols=None, tag_bool_cols=None, tag_descriptions=None, allow_disambiguation=True, label_separator='_', label_format_map=None, prepend_col_name=False) classmethod

Generate a segment property object from a pandas dataframe based on column

Parameters:

  • df (DataFrame) –

    Dataframe containing propeties

  • id_col (str, default: 'pt_root_id' ) –

    Name of the column with object ids, by default "pt_root_id"

  • label_col (Optional[str, list[str]], default: None ) –

    Name of column or columns to use for producing labels, by default None. If multiple columns are provided, they will be concatenated with the label_separator. Null values are skipped.

  • description_col (Optional[str], default: None ) –

    Name of column to use for producing descriptions, by default None

  • string_cols (Optional[Union[str, list[str]]], default: None ) –

    Column (or list of columns) to use for string properties, by default None.

  • number_cols (Optional[Union[str, list[str]]], default: None ) –

    Column (or list of columns) to use for numeric properties, by default None.

  • tag_value_cols (Optional[list[str]], default: None ) –

    Column (or list of columns) to generate tags based on unique values. Each column produces one tag per row based on the value, by default None

  • tag_bool_cols (Optional[list[str]], default: None ) –

    List of columns to generate tags based on boolean values where each column is a tag, and each id gets the tag if it has a True in its row. By default None.

  • tag_descriptions (Optional[dict], default: None ) –

    Dictionary of tag values to long-form tag descriptions, by default None. Tags without a key/value are passed through directly.

  • allow_disambiguation (bool, default: True ) –

    If True, will prepend the column name in the case of duplicate tags, by default True.

  • label_separator (str, default: '_' ) –

    Separator to use when assembling multiple columns into a label, by default "_"

  • label_format_map (Optional[str], default: None ) –

    Format string to use for label formatting, by default None. If provided, will override the label separator and use the format string to format the label via the "format" function, replacing the column names in {..} with the values. For example, "{cell_class}: {cell_type}_{region}" would pluck values from the columns "cell_class", "cell_type", and "region". Label columns will be ignored and the format string is not validated.

  • prepend_col_name (bool, default: False ) –

    If True, will prepend the column name to tag values, by default False. This will effectively disambiguate all tags as well.

Returns:

from_dict(seg_prop_dict) classmethod

Generate a segment property object from a segment property dictionary

Parameters:

  • seg_prop_dict (dict) –

    Segment property dictionary, as imported from the json.

Returns:

to_dataframe()

Converts the segment properties to a pandas dataframe

to_dict()

Converts the segment properties to a dictionary for use in neuroglancer

prop_filter(attr, value)

Filters out None for optional attributes for use in 'attrs.asdict' conversion