-
Notifications
You must be signed in to change notification settings - Fork 0
/
sessions_and_probes.py
26 lines (21 loc) · 1.02 KB
/
sessions_and_probes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import pandas as pd
from pathlib import Path
from allensdk.brain_observatory.ecephys.ecephys_project_cache import EcephysProjectCache
import pickle
"""
Gathering metadata from Ecephys Allen data in the following format:
[Session ID, First Probe ID, Second Probe ID]
The first probe is selected to have recorded from VISpm/VISp and the second from VISp/VISpm correspondingly.
"""
output_dir = Path.home() / 'Desktop' / 'disk1' / 'ecephys_data'
cache = EcephysProjectCache.from_warehouse(manifest=output_dir / 'manifest.json')
probe_df = cache.get_probes()
output_list = []
for session_id in probe_df.ecephys_session_id.unique():
ind_list = probe_df[(probe_df.ecephys_session_id==session_id) & (probe_df['ecephys_structure_acronyms'].apply(lambda x: 'VISp' in x or 'VISpm' in x)) & (probe_df['has_lfp_data'] == True)].index.to_list()
if len(ind_list) == 2:
ind_list = [session_id] + ind_list
output_list.append(ind_list)
with open('VISpm_VISp_probes.pkl', 'wb') as f:
pickle.dump(output_list, f)