SWC Reader

class dendrotweaks.morphology.io.reader.SWCReader[source]

Bases: object

Reads an SWC file and returns a DataFrame.

read_file(path_to_swc_file: str) DataFrame[source]

Read the SWC file and return a DataFrame enriched with domain & color metadata.

static rename_domain(df, type_idx: int, new_domain_name: str, new_color: str)[source]

Rename a domain in the DataFrame by changing the domain name and color for a given type index.

static replace_domain(df, old_type_idx: int, new_type_idx: int)[source]

Replace a domain in the DataFrame by changing the type index, domain name, and color.

Parameters:
  • df (pd.DataFrame) – The DataFrame containing the SWC data (generated by read_file).

  • old_type_idx (int) – The type index of the domain to be replaced.

  • new_type_idx (int) – The type index of the new domain.

static remove_domain(df, type_idx: int)[source]

Remove a domain from the DataFrame by dropping all rows with the given type index.

static plot_raw_data(df, ax, **kwargs)[source]

Plot the raw data from the SWC file using the DataFrame.

Parameters:
  • df (pd.DataFrame) – The DataFrame containing the SWC data (generated by read_file).

  • ax (matplotlib.pyplot.Axes) – The axes to plot on.