Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import element_interface

dj.config['database.host'] = 'database.eflab.org:3306'
dj.config['database.username'] = 'maria'
dj.config['database.password'] = 'Spike@Thr200'


experiment_dir = '/mnt/lab/data01/OpenEphys'
db_prefix = 'lab_npx_'
Expand Down
6 changes: 4 additions & 2 deletions element_array_ephys/ephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,12 @@ def make(self, key):
for channel_idx, channel_info in channel2electrode_map.items()
]
elif acq_software == "Open Ephys":
#print(session_dir)
print("Hey Im Here!!")
print(session_dir)
dataset = openephys.OpenEphys(session_dir)
#print(dataset.probes.items())
print(dataset.probes.items())
for serial_number, probe_data in dataset.probes.items():
print(f"Serial Number is {str(serial_number)} while inserted probeserial is: {inserted_probe_serial_number}")
if str(serial_number) == inserted_probe_serial_number:
break
else:
Expand Down
103 changes: 103 additions & 0 deletions populate_ephys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
## Imports
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pathlib import Path
import os
# import numcodecs
import datajoint as dj

## Database specifics
experiment_dir = '/mnt/lab/data01/OpenEphys'
db_prefix = 'lab_npx_'

dj.config['database.host'] = 'database.eflab.org:3306'
dj.config["enable_python_native_blobs"] = True
dj.config['custom'] = {'database_prefix': db_prefix,'ephys_root_data_dir': experiment_dir}


from build_pipeline import Subject, Session, Recording, probe, ephys, ephys_report

def get_key():
while True:
# Get user inputs
animal_id = input("Enter animal_id: ").strip()
session = input("Enter session: ").strip()
insertion_number = input("Enter insertion number: ").strip()

# Print and confirm
print("\nYou entered:")
print(f" animal_id : {animal_id}")
print(f" session : {session}")
print(f" insertion number : {insertion_number}")
confirm = input("Are these the correct inputs? (yes/no): ").strip().lower()


# safety check to confirm the inputs
if confirm == "yes":
break
else:
print("Let's try again...\n")

# Pick Probe
print("\nNow let's choose a probe:")
print(probe.Probe())
probes = probe.Probe.fetch(format="frame")
print(probes)
probe_idx = input("pick the index of your choice")
print(probe.iloc(3))

key = {'animal_id' : int(animal_id), 'session': int(session), 'insertion_number' : int(insertion_number)}
print(f'processing key: {key}')
return key , probe_idx


def populate_ephys(key,probe_idx):
'''
A function that correctly checks and populates the Ephys schema with all its subsequent tables.
'''


# TODO choose a different probe when they exist
ephys.ProbeInsertion.insert1(
dict(
key,
probe=(probe.Probe()).fetch('probe')[probe_idx],
), skip_duplicates=True
)

ephys.EphysRecording().populate(key, display_progress=True)



key['paramset_idx']=3
file_path = (ephys.EphysRecording.EphysFile() & key).fetch('file_path')
ks_path = file_path[0]+'/kilosort4/sorter_output'
ephys.ClusteringTask.insert1(
dict(
key,
task_mode="load", # load or trigger
clustering_output_dir=ks_path,
), skip_duplicates=True
)

ephys.Clustering.populate(key, display_progress=True)
ephys.CuratedClustering.populate(key, display_progress=True)
ephys.QualityMetrics.populate(key, display_progress=True)




def main():
key = get_key()
print(f"Populating the Ephys schema for key:\n {key} ... ")
populate_ephys(key)


if __name__ == "__main__":
main()





Loading