Skip to content

Instantly share code, notes, and snippets.

@smestern
Last active October 24, 2019 20:06
Show Gist options
  • Save smestern/02777c812bd3a943612c0db912a4d304 to your computer and use it in GitHub Desktop.
Save smestern/02777c812bd3a943612c0db912a4d304 to your computer and use it in GitHub Desktop.
Downloads all of the currently available neuropixels-NWBs from allen insitute
import os
import numpy as np
import pandas as pd
from allensdk.brain_observatory.ecephys.ecephys_project_cache import EcephysProjectCache ##Requires allensdk 1.0.2 or higher
manifest_path = os.path.join("C:\\cell_types\\", "manifest.json") ##Need to use double slashes in python for paths. Data will be saved to this folder
cache = EcephysProjectCache.from_warehouse(manifest=manifest_path) ##Declares the cache object to be called later.
#sessions = cache._get_sessions()
cell_ids_df = cache.get_session_table() ## Returns a session table csv, Its huge and takes ~10min to download the first time.
cell_ids = cell_ids_df.index.values ##Extracts the sessions id from the table
size = len(cell_ids)
for i, cell in enumerate(cell_ids):
print('Downloading session ' + str(cell) + ' number ' + str(i) + ' of ' + str(size))
metrics = cache.get_unit_analysis_metrics_for_session(cell)
session = cache.get_session_data(cell) ##Loops through and dls each cell. Theses are huge
print('Download Complete')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment