-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtrialDataExample.m
28 lines (22 loc) · 1.17 KB
/
trialDataExample.m
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
% dsPath = '/Volumes/pixin/will_sort/Pierre_20180609_08';
kilosortDatasetPath = '/path/to/kilosort_output';
% build path to channel map file
channelMapFile '/path/to/neuropixel-utils/map_files/neuropixPhase3A_kilosortChanMap.mat');
% load the kilosort dataset
ds = Kilosort.Dataset(kilosortDatasetPath, channelMapFile);
ds.load();
% Figure out where trials start and stop
% tsi is TrialSegmentationInfo that stores this info
% this will load trialSegmentationInfo.mat file if present, but the first time will parse the sync from raw imec.ap.bin file
imecAPBinFile = '/path/to/data.imec.ap.bin';
tsi = NeuropixelExpt.DataLoad.readTrialInfo(imecAPBinFile);
% trial_ids is the list of trial ids for the behavioral data you want to merge into
% e.g. from TrialData object
trial_ids = td.getParam('trialId');
% segment the kilosort dataset into trials, with the final arrays matching
% trial_ids (and missing trials being empty)
% so seg will have numel(trial_ids) trials in it regardless of how many trials are found in the ImecDataFile
seg = Kilosort.TrialSegmentedDataset(ds08, tsi, trial_ids);
% merge into trial data
td = td.dropSpikeChannels();
td = seg.addSpikesToTrialData(td, 'npix');