neuralib.atlas.ccf.query

class neuralib.atlas.ccf.query.RoiAreaQuery[source]

class for finding a subset of rois from a specific area

__init__(parsed_df, area, source_order=None, force_set_show_col_level=None)[source]
Parameters:
  • parsed_df (pl.DataFrame) – parsed dataframe from ccf pipeline

  • area (Area) – area name

  • source_order (tuple[Source, ...] | None) – order of the unique sources

  • force_set_show_col_level (int | None) –

    force set show col to which level. use case: if a low level area name is classified and show in high level (i.e., TH). Then directly specify the level number instead of auto inferred by _hierarchical_query()

    Please use carefully

    Note that it results in subregions mixed in different level

    for example, if one level contain both HIP and HPF, it will quantify and calculate the percentage together, however, they are not in the same level for actual allen tree level. it’s due to the raw data issue (Rois are not classified correctly initially in allenCCF pipeline)

classmethod by(df, area, *, source_order=None, force_set_show_col_level=None)[source]

Query which area

Parameters:
  • df (pl.DataFrame) – ccf parsed dataframe

  • area (Area) – area name

  • source_order (tuple[Source, ...] | None) – order of the unique sources

  • force_set_show_col_level (int | None) –

    force set show col to which level. use case: if a low level area name is classified and show in high level (i.e., TH). Then directly specify the level number instead of auto inferred by _hierarchical_query()

    Please use carefully

    Note that it results in subregions mixed in different level

    for example, if one level contain both HIP and HPF, it will quantify and calculate the percentage together, however, they are not in the same level for actual allen tree level. it’s due to the raw data issue (Rois are not classified correctly initially in allenCCF pipeline)

Returns:

Return type:

Self

property query_col: str

which column for the area name query (base column query source)

property show_col: str

highest merge level column for a given area (to show)

get_subregion_result(unit, supply_overlap=True)[source]

Get subregion results

Parameters:
  • unit (str) – {‘n_rois’, ‘percent’}

  • supply_overlap (bool) – add overlap roi counts into other channel(s)

Returns:

SubregionResult

Return type:

SubregionResult

class neuralib.atlas.ccf.query.SubregionResult[source]
source_query: RoiAreaQuery

source query

unit: str

Note that percent are normalized by queried dataframe

data: DataFrame
  • Optional with animal col:

    ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬────────┐
    │ source  ┆ VISam   ┆ VISp    ┆ VISpm   ┆ VISl    ┆ VISal   ┆ VISpor  ┆ VISli   ┆ VISpl   ┆ VISC   │
    │ ---     ┆ ---     ┆ ---     ┆ ---     ┆ ---     ┆ ---     ┆ ---     ┆ ---     ┆ ---     ┆ ---    │
    │ str     ┆ f64     ┆ f64     ┆ f64     ┆ f64     ┆ f64     ┆ f64     ┆ f64     ┆ f64     ┆ f64    │
    ╞═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪════════╡
    │ aRSC    ┆ 25.4669 ┆ 34.0318 ┆ 23.0979 ┆ 6.42369 ┆ 6.37813 ┆ 1.77676 ┆ 2.27790 ┆ 0.0     ┆ 0.5466 │
    │         ┆ 7       ┆ 91      ┆ 5       ┆         ┆ 2       ┆ 5       ┆ 4       ┆         ┆ 97     │
    │ pRSC    ┆ 15.1445 ┆ 36.1079 ┆ 29.5568 ┆ 10.7129 ┆ 3.04431 ┆ 2.38921 ┆ 1.92678 ┆ 1.07899 ┆ 0.0385 │
    │         ┆ 09      ┆         ┆ 4       ┆ 09      ┆ 6       ┆         ┆ 2       ┆ 8       ┆ 36     │
    │ overlap ┆ 48.5294 ┆ 8.82352 ┆ 31.25   ┆ 4.04411 ┆ 3.30882 ┆ 2.57352 ┆ 1.10294 ┆ 0.0     ┆ 0.3676 │
    │         ┆ 12      ┆ 9       ┆         ┆ 8       ┆ 4       ┆ 9       ┆ 1       ┆         ┆ 47     │
    └─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴────────┘
    
roi_profile: DataFrame

roi profile:

┌─────────┬────────┬───────┬────────────┐
│ source  ┆ n_rois ┆ len   ┆ total_perc │
│ ---     ┆ ---    ┆ ---   ┆ ---        │
│ str     ┆ u32    ┆ u32   ┆ f64        │
╞═════════╪════════╪═══════╪════════════╡
│ aRSC    ┆ 899    ┆ 11403 ┆ 0.078839   │
│ pRSC    ┆ 6744   ┆ 26280 ┆ 0.256621   │
│ overlap ┆ 225    ┆ 3470  ┆ 0.064841   │
└─────────┴────────┴───────┴────────────┘
del_overlap()[source]

keep same source_query but delete the overlap data and roi_profile

Return type:

Self

with_animal(animal)[source]

add animal col for batch/statistic purpose

Parameters:

animal (str)

Return type:

Self

property sources: list[str]

list of sources

property channel_weight: DataFrame

fraction foreach source in all rois

__init__(source_query, unit, data, roi_profile)

Method generated by attrs for class SubregionResult.

Parameters:
  • source_query (RoiAreaQuery)

  • unit (str)

  • data (DataFrame)

  • roi_profile (DataFrame)

Return type:

None

property weight_list: list[float]

list of perc

property values: DataFrame

numerical data without source column

property areas: list[str]

list of areas

property n_areas: int

number of areas

property n_rois_info: list[str]

info for plotting