-
Notifications
You must be signed in to change notification settings - Fork 3
/
pipeline_utils.py
35 lines (30 loc) · 1.18 KB
/
pipeline_utils.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
27
28
29
30
31
32
33
34
35
import os
import fnmatch
import numpy as np
from sorting.readSGLX import readMeta, SampRate, makeMemMapRaw, ExtractDigital
import scipy.io
import shutil
from pathlib import Path
def find(pattern, path):
result = []
for root, dirs, files in os.walk(path):
for name in files:
if fnmatch.fnmatch(name, pattern):
result.append(os.path.join(root, name))
for name in dirs:
if fnmatch.fnmatch(name, pattern):
result.append(os.path.join(root, name))
return result
def create_config(script_folder, folder):
shutil.copyfile(script_folder + '/config_template.yaml', folder + '/config.yaml')
def extract_sync(config_kilosort):
meta = readMeta(Path(config_kilosort['neuropixel']))
tStart = 0
tEnd = np.floor(float(meta['fileTimeSecs']))
sRate = SampRate(meta)
firstSamp = int(sRate * tStart)
lastSamp = int(sRate * tEnd)
rawData = makeMemMapRaw(Path(config_kilosort['neuropixel']), meta)
sync_data = dict([])
sync_data['sync'] = ExtractDigital(rawData, firstSamp, lastSamp, 0, [6], meta)
scipy.io.savemat(config_kilosort['neuropixel_folder'] + '/sync.mat', sync_data, do_compression=True)