neuralib.atlas.util

class neuralib.atlas.util.SourceCoordinates[source]

SourceCoordinates(source, coordinates, axes_repr)

source: str

Alias for field number 0

coordinates: ndarray

(N, 3) with ap, dv, ml

axes_repr: tuple[str, str, str]

Alias for field number 2

property ap: ndarray
property dv: ndarray
property ml: ndarray
static __new__(_cls, source, coordinates, axes_repr=('ap', 'dv', 'ml'))

Create new instance of SourceCoordinates(source, coordinates, axes_repr)

Parameters:
  • source (str)

  • coordinates (ndarray)

  • axes_repr (tuple[str, str, str])

neuralib.atlas.util.iter_source_coordinates(file, *, only_areas=None, region_col=None, hemisphere='both', to_brainrender=True, to_um=True, ret_order=('pRSC', 'aRSC', 'overlap'))[source]

Load allen ccf roi output (merged different color channels).

Parameters:
  • file (Path) – parsed csv file after

  • only_areas (str | list[str] | None) – only show rois in region(s)

  • region_col (str | None) – if None, auto infer, and check the lowest merge level contain all the regions specified

  • hemisphere (Literal['ipsi', 'contra', 'both']) – which brain hemisphere

  • to_brainrender (bool) – convert the coordinates to brain render

  • to_um (bool) – unit to um

  • ret_order (tuple[str, ...] | None) – whether specify the source generator order

Returns:

Iterable of SourceCoordinates

Return type:

Iterable[SourceCoordinates]

neuralib.atlas.util.get_margin_merge_level(df, areas, margin)[source]

Get the lowest or highest merge level (i.e., parsed_csv) containing all the regions

Parameters:
  • df (DataFrame) – parsed csv

  • areas (list[str] | str) – an area or a list of areas

  • margin (Literal['lowest', 'highest']) – get the either lowest of highest merge level for a given area

Returns:

col name if parsed csv

Return type:

str

neuralib.atlas.util.roi_points_converter(dat, to_brainrender=True, to_um=True)[source]

convert coordinates of allenccf roi points from parsed dataframe

Parameters:
  • dat (DataFrame | DataFrame | ndarray) – Dataframe with ‘AP_location’, ‘DV_location’, ‘ML_location’ headers. Or numpy array with Array[float, [N, 3]] or Array[float, 3]

  • to_brainrender (bool) – coordinates to brainrender

  • to_um (bool) – unit to um

Returns:

Array[float, [N, 3]], N: number of roi; 3: AP, DV, ML

Return type:

ndarray

neuralib.atlas.util.create_allen_structure_dict(verbose=False)[source]

Get the acronym/name pairing from structure_tree.csv

Returns:

key: acronym; value: full name

Return type:

dict[str, str]