ClearMap.Analysis package

ClearMap analysis and statistics toolbox.

This part of ClearMap provides a toolbox for the statistical analysis and visualization of detected cells or structures and region specific analysis of annotated data.

For cleared mouse brains aligned to the Allen brain atlas, a wide range of statistical analysis tools with respect to the annotated brain regions in the atlas is supported.

Key modules are:

Module Description
Voxelization Voxelization of cells for visualization and analysis
Statistics Statistical tools for the analysis of detected cells
Label Tools to analyse data with respect to annotated references

ClearMap.Analysis.Label module

Label and annotation info from Allen Brain Atlas (v2)

Notes

  • The annotation file is assumed to be in ‘./Data/Annotation/annotation_25_right.tif’ but can be set in the constant DefaultLabeledImageFile
  • The mapping between labels and brain area information is found in the ‘./Data/ARA2_annotation_info.csv’ file. In the ‘./Data/ARA2_annotation_info_collapse.csv’ file a cross marks an area to which all sub-areas can be collapsed. The location of this file is set in DefaultAnnotationFile.
  • For consistency certain labels of the Allen brain atlas without annotation were assigned to their correct parent regions.
  • A collapse column in the mapping file was added to allow for a region based collapse of statistics based on the inheritance structure of the annotated regions. These might need to be adjusted to the particular scientific question.

References

DefaultLabeledImageFile = '/home/mtllab/Programs/ClearMap/idisco/ClearMap/Test/Data/Annotation/annotation_25_right.tif'

str: default volumetric annotated image file

This file is by default the Allen brain annotated mouse atlas with 25um isotropic resolution.

DefaultAnnotationFile = '/home/mtllab/Programs/ClearMap/idisco/ClearMap/Data/ARA2_annotation_info_collapse.csv'

str: default list of labels in the annotated image and names of annotated regions

This file is by default the labels for the Allen brain annotated mouse atlas with 25um isotropic resolution.

An extra column for collapse indicates how to automatically collapse data into the different brain regions if the collapse option is given.

class LabelRecord(id, name, acronym, color, parent, collapse)

Bases: tuple

Structure of a label for a annotated region

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

acronym

Alias for field number 2

collapse

Alias for field number 5

color

Alias for field number 3

id

Alias for field number 0

name

Alias for field number 1

parent

Alias for field number 4

class LabelInfo(slf, annotationFile='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Data/ARA2_annotation_info_collapse.csv')[source]

Bases: object

Class that holds information of the annotated regions

ids = None
names = None
acronyms = None
colors = None
parents = None
levels = None
collapse = None
collapseMap = None
initialize(slf, annotationFile='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Data/ARA2_annotation_info_collapse.csv')[source]
name(slf, iid)[source]
acronym(slf, iid)[source]
color(slf, iid)[source]
parent(slf, iid)[source]
level(slf, iid)[source]
toLabelAtLevel(slf, iid, level)[source]
toLabelAtCollapseMap(slf, iid)[source]
toLabelAtCollapse(slf, iid)[source]
Label = <ClearMap.Analysis.Label.LabelInfo object>

Information on the annotated regions

initialize(annotationFile='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Data/ARA2_annotation_info_collapse.csv')[source]
labelAtLevel(label, level)[source]
labelAtCollapse(label)[source]
labelPoints(points, labeledImage='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Test/Data/Annotation/annotation_25_right.tif', level=None, collapse=None)[source]
countPointsInRegions(points, labeledImage='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Test/Data/Annotation/annotation_25_right.tif', intensities=None, intensityRow=0, level=None, allIds=False, sort=True, returnIds=True, returnCounts=False, collapse=None)[source]
labelToName(label)[source]
labelToAcronym(label)[source]
labelToColor(label)[source]
writePAL(filename, cols)[source]
writeLUT(filename, cols)[source]
makeColorPalette(filename=None)[source]

Creates a pal file for imaris based on label colors

makeColorAnnotations(filename, labeledImage=None)[source]
test()[source]

Test Label module

ClearMap.Analysis.Statistics module

Create some statistics to test significant changes in voxelized and labeled data

TODO: cleanup / make generic

readDataGroup(filenames, combine=True, **args)[source]

Turn a list of filenames for data into a numpy stack

readPointsGroup(filenames, **args)[source]

Turn a list of filenames for points into a numpy stack

tTestVoxelization(group1, group2, signed=False, removeNaN=True, pcutoff=None)[source]

t-Test on differences between the individual voxels in group1 and group2, group is a array of voxelizations

cutoffPValues(pvals, pcutoff=0.05)[source]
colorPValues(pvals, psign, positive=[1, 0], negative=[0, 1], pcutoff=None, positivetrend=[0, 0, 1, 0], negativetrend=[0, 0, 0, 1], pmax=None)[source]
mean(group, **args)[source]
std(group, **args)[source]
var(group, **args)[source]
thresholdPoints(points, intensities, threshold=0, row=0)[source]

Threshold points by intensities

weightsFromPrecentiles(intensities, percentiles=[25, 50, 75, 100])[source]
countPointsGroupInRegions(pointGroup, labeledImage='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Test/Data/Annotation/annotation_25_right.tif', intensityGroup=None, intensityRow=0, returnIds=True, returnCounts=False, collapse=None)[source]

Generates a table of counts for the various point datasets in pointGroup

tTestPointsInRegions(pointCounts1, pointCounts2, labeledImage='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Test/Data/Annotation/annotation_25_right.tif', signed=False, removeNaN=True, pcutoff=None, equal_var=False)[source]

t-Test on differences in counts of points in labeled regions

testCompletedCumulatives(data, method='AndersonDarling', offset=None, plot=False)[source]

Test if data sets have the same number / intensity distribution by adding max intensity counts to the smaller sized data sets and performing a distribution comparison test

testCompletedInvertedCumulatives(data, method='AndersonDarling', offset=None, plot=False)[source]

Test if data sets have the same number / intensity distribution by adding zero intensity counts to the smaller sized data sets and performing a distribution comparison test on the reversed cumulative distribution

testCompletedCumulativesInSpheres(points1, intensities1, points2, intensities2, dataSize='/home/mtllab/Programs/ClearMap/idisco/ClearMap/Test/Data/Annotation/annotation_25_right.tif', radius=100, method='AndresonDarling')[source]

Performs completed cumulative distribution tests for each pixel using points in a ball centered at that cooridnates, returns 4 arrays p value, statistic value, number in each group

test()[source]

Test the statistics array

ClearMap.Analysis.Voxelization module

Converts point data into voxel image data for visulaization and analysis

voxelize(points, dataSize=None, sink=None, voxelizeParameter=None, method='Spherical', size=(5, 5, 5), weights=None)[source]

Converts a list of points into an volumetric image array

Parameters:
  • points (array) – point data array

  • dataSize (tuple) – size of final image

  • sink (str, array or None) – the location to write or return the resulting voxelization image, if None return array

  • voxelizeParameter (dict) –

    Name Type Descritption
    method (str or None) method for voxelization: ‘Spherical’, ‘Rectangular’ or ‘Pixel’
    size (tuple) size parameter for the voxelization
    weights (array or None) weights for each point, None is uniform weights
Returns:

(array) – volumetric data of smeared out points

voxelizePixel(points, dataSize=None, weights=None)[source]

Mark pixels/voxels of each point in an image array

Parameters:
  • points (array) – point data array
  • dataSize (tuple or None) – size of the final output data, if None size is determined by maximal point coordinates
  • weights (array or None) – weights for each points, if None weights are all 1s.
Returns:

(array) – volumetric data with with points marked in voxels

test()[source]

Test voxelization module