# Precomputed Unit Analysis Metrics

**URL:** <https://community.brain-map.org/t/precomputed-unit-analysis-metrics/2127>\
**Category:** Technical\
**Tags:** allensdk, brain-observatory-visual-coding, analysis\
**Created:** [February 10, 2023, 5:04pm UTC](https://community.brain-map.org/t/precomputed-unit-analysis-metrics/2127 "2023-02-10T17:04:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PBeech](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PBeech](https://community.brain-map.org/u/PBeech)\
**Post date:** [February 10, 2023, 5:04pm UTC](https://community.brain-map.org/t/precomputed-unit-analysis-metrics/2127/1 "2023-02-10T17:04:26Z")

</div>

Hi,

At the bottom of this page, [Visual Coding – Neuropixels — Allen SDK dev documentation](https://allensdk.readthedocs.io/en/latest/visual_coding_neuropixels.html) it notes to use the “get\_unit\_analysis\_metrics()” method to get metrics of global orientation selectivity, sparseness etc. Additionally, it is mentioned in the Allen SDK documentation release dev.

However, I am having trouble calling this data, as I cant find which module this is part of. I have attempted things such as:

from allensdk.brain\_observatory.ecephys.ecephys\_session import get\_unit\_analysis\_metrics  
from allensdk.brain\_observatory.ecephys.ecephys\_project\_cache import get\_unit\_analysis\_metrics  
from allensdk.brain\_observatory.ecephys.ecephys\_project\_api import get\_unit\_analysis\_metrics  
import allensdk.brain\_observatory.ecephys.ecephys\_project\_api

I have been able to find a table for the calcium imaging data using what I assume is a similar method - “get\_cell\_specimens()” on this page [Brain Observatory — Allen SDK dev documentation](https://allensdk.readthedocs.io/en/latest/brain_observatory.html#precomputed-cell-metrics) (as there is an associated jupyter notebook tutorial) but I am looking for the neuropixel data.

This may be a simple question, but I am having quite a bit of trouble and cant find any answers anywhere else, thus would appreciate any help if you know how to call the table.

---

<div class="post-metadata">

**Author:** ![joshs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/joshs/32/8_2.png) [@joshs](https://community.brain-map.org/u/joshs)\
**Post date:** [February 10, 2023, 5:27pm UTC](https://community.brain-map.org/t/precomputed-unit-analysis-metrics/2127/2 "2023-02-10T17:27:40Z")

</div>

Hello! This method belongs to the `EcephysProjectCache` object (the same one used to download data).

You can create the `cache` object like this:

```auto
from allensdk.brain_observatory.ecephys.ecephys_project_cache import EcephysProjectCache

output_dir = '/local1/ecephys_cache_dir' # customize this
manifest_path = os.path.join(output_dir, "manifest.json")
cache = EcephysProjectCache.from_warehouse(manifest=manifest_path)

```

Then, you can access the analysis metrics like this:

```auto
analysis_metrics1 = cache.get_unit_analysis_metrics_by_session_type('brain_observatory_1.1')

analysis_metrics2 = cache.get_unit_analysis_metrics_by_session_type('functional_connectivity')

```

These steps are documented in [this tutorial](https://allensdk.readthedocs.io/en/latest/_static/examples/nb/ecephys_data_access.html), but we should also make this clear on the landing page!

---

<div class="post-metadata">

**Author:** ![PBeech](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@PBeech](https://community.brain-map.org/u/PBeech)\
**Post date:** [February 10, 2023, 6:16pm UTC](https://community.brain-map.org/t/precomputed-unit-analysis-metrics/2127/3 "2023-02-10T18:16:30Z")

</div>

Thank you for this quick response! This is exactly what I was looking for, thank you.
