atlannot.merge_original.JSONread module

Tools to deal with brain hierarchy from the AIBS.

class atlannot.merge_original.JSONread.RegionData(brain_regions)[source]

Bases: object

Extract and process brain region data.

Parameters:

brain_regions (dict) – The brain regions dictionary. Can be obtained from the “msg” key of the brain_regions.json (1.json) file.

filter_region(annotation, allname, children)[source]

Filter a region.

Computes a 3d boolean mask to filter a region and its subregion from the annotations.

Parameters:
  • annotation (np.ndarray) – 3D numpy ndarray of integers ids of the regions.

  • allname (str) – Complete name of the region.

  • children (dict) – Dictionary of region complete name to list of child region ids.

Returns:

filter_ – 3D numpy ndarray of boolean, boolean mask with all the voxels of a region and its children set to True.

Return type:

np.ndarray

find_children(uniques)[source]

Find children.

Finds the children regions of each region id in uniques and its distance from a leaf region in the hierarchy tree. Non leaf regions are included in the children list.

Parameters:

uniques (np.ndarray) – List of unique region ids

Returns:

  • children (dict) – Dictionary of region complete name to list of child region ids.

  • order_ (np.ndarray) – Array of distances from a leaf region in the hierarchy tree for each region in uniques.

find_unique_regions(annotation, top_region_name='Basic cell groups and regions')[source]

Find unique regions.

Finds unique regions ids that are present in an annotation file and are contained in the top_region_name Adds also to the list each parent of the regions present in the annotation file. Dictionaries parameters

Parameters:
  • annotation (np.ndarray) – 3D numpy ndarray of integers ids of the regions.

  • top_region_name (str) – Name of the most broader region included in the uniques.

Returns:

uniques – Array of unique regions id in the annotation file that are included in top_region_name.

Return type:

np.ndarray

static hex_to_rgb(value)[source]

Convert a hexadecimal color into its RGB value counterpart.

Parameters:

value (str) – Hexadecimal color to convert.

Returns:

List of the Red, Green, and Blue components of the color.

Return type:

tuple

return_ids_containing_str_list(str_list)[source]

Return IDs containing all keywords.

Retrieve the list of region id which complete name contains all the keywords in str_list.

Parameters:

str_list (iterable) – List of keyword that the region complete name.

Returns:

id_list – List of region id matching condition

Return type:

list

search_children(object_, lastname_ALL='', lastname='', darken=True)[source]

Explores the hierarchy dictionary to extract brain regions.

Explores the hierarchy dictionary to extract its brain regions and fills internal dictionaries.

Parameters: