forked from Julie-Fabre/bombcell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9244c48
commit b7127c4
Showing
3 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
%% ~~ EAJ bombcell pipeline ~~ | ||
% Adjust the paths in the 'set paths' section and the parameters in bc_qualityParamValues | ||
% This pipeline will run bombcell on your data and save the output | ||
|
||
addpath(genpath("C:\Users\Niflheim\Documents\GitHub\External\bombcell")) | ||
addpath(genpath("C:\Users\Niflheim\Documents\GitHub\External\npy-matlab")) | ||
addpath(genpath("C:\Users\Niflheim\Documents\GitHub\External\prettify_matlab")) | ||
|
||
%% set paths | ||
clearvars | ||
sessions = readtable('//oak-smb-giocomo.stanford.edu/groups/giocomo/export/data/Projects/JohnKei_NPH3/WenSorscher2023_revisions/all_sessions.csv'); | ||
%'Z:\WT_Sequences\2023_spring\Preprocessed_Data\Provenance\all_sessions.csv' | ||
for s = 29 | ||
%rec_error = string(sessions{s,'Recording_Error'}); | ||
for probe = 0 | ||
% generate the path to the directory containing the ap.bin file | ||
base_dir = string(sessions{s,'Base_Directory'}); | ||
base_dir = strrep(base_dir, '/', '\'); | ||
ecephys_path = base_dir; | ||
|
||
rec_file_stem = split(string(sessions{s,'File'}),'/'); | ||
rec_file_stem = convertStringsToChars(rec_file_stem); | ||
rec_file_path = sprintf('%s\\%s\\SuperCat\\%s\\supercat_%s\\%s_imec%d',... | ||
ecephys_path, string(sessions{s,'Animal'}),... | ||
rec_file_stem(1:end-3), rec_file_stem,... | ||
rec_file_stem, probe); | ||
|
||
% set variables for BombCell | ||
mainDir = rec_file_path; | ||
ephysKilosortPath = sprintf('%s/imec%d_ks',rec_file_path,probe); | ||
rec_file_base = sprintf('%s/%s_tcat.imec%d.ap',rec_file_path,rec_file_stem, probe); | ||
rawFile = [rec_file_base,'.bin']; | ||
ephysMetaFile = [rec_file_base,'.meta']; | ||
|
||
saveLocation = mainDir; | ||
savePath = fullfile(saveLocation, 'qMetrics'); | ||
|
||
% load data | ||
[spikeTimes_samples, spikeTemplates, templateWaveforms, templateAmplitudes, pcFeatures, ... | ||
pcFeatureIdx, channelPositions] = bc_loadEphysData(ephysKilosortPath); | ||
|
||
% which quality metric parameters to extract and thresholds | ||
param = eaj_qualityParamValues(ephysMetaFile, rawFile, ephysKilosortPath); | ||
% param = bc_qualityParamValuesForUnitMatch(ephysMetaDir, rawFile) % Run this if you want to use UnitMatch after | ||
|
||
%% compute quality metrics | ||
[qMetric, unitType] = bc_runAllQualityMetrics(param, spikeTimes_samples, spikeTemplates, ... | ||
templateWaveforms, templateAmplitudes,pcFeatures,pcFeatureIdx,channelPositions, savePath); | ||
|
||
%% save to cluster_group.tsv | ||
% overwrite ecephys cluster labels if any units were found to be noise | ||
cluster_group_file = [ephysKilosortPath filesep 'cluster_group.tsv']; | ||
cluster_group = readtable(cluster_group_file, 'FileType', 'text', 'Delimiter', '\t'); | ||
cluster_group(unitType==0,'group') = {'noise'}; | ||
writetable(cluster_group, cluster_group_file, 'FileType', 'text', 'Delimiter', '\t'); | ||
|
||
end | ||
end |