-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbatch_convertAndSort.asv
121 lines (97 loc) · 4.07 KB
/
batch_convertAndSort.asv
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
%% batch_convertAndSort
%
% example script for batch conversion and sorting of raw ephys files.
%
% INSTRUCTIONS:
% - provide script with list of files.
% script will convert each raw file into .dat, will copy masterMegaFile.m
% into each directory, and kiloSort each
% - make sure you have correct path to kiloTools
%% add necessary paths to toolboxes:
cd('D:\Code\Toolboxes\kiloTools');
paths = addPathsForSpikeSorting;
%% boolleans:
performConversion = true;
performKiloSort = false;
%% list of paths to raw ephys files
fs = 40000;
nCh = 24;
Nfilt = nCh*3; % number of clusters to use (2-4 times more than Nchan, should be a multiple of 32)
% set your options:
probeGeometry = 'linear100'; % see probeGeometry2coords.m for options
opts.commonAverageReferencing = false;
opts.specificChannels = false; % either false or (eg) 65:96
if opts.specificChannels
nCh = length(opts.specificChannels);
end
opts.plotProbeVoltage = true;
opts.removeArtifacts = false;
% input your folders:
folderList = {...
'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150717a_msc_pre'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150717b_msc_post'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150719a_msc_pre'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150719b_msc_post'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150721a_msc_pre'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150721b_msc_post'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150724a_msc_pre'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150724b_msc_post'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150726a_msc_pre'...
% 'Y:\LAB PROJECTS\fefSelectiveAttention\sna20150726b_msc_post'...
};
nFiles = numel(folderList);
% please specifiy the string by which you wish to identify your file of
% interest in each of the folders listed in folderList (e.g. 'pl2')
fileIdentifierString =
% Make list of dat files by adding .dat and inserting 'kiloSorted' folder:
rawPath = cell(nFiles,1);
datPathList = cell(nFiles,1);
kiloFolderList = cell(nFiles,1);
fileName = cell(nFiles,1);
for iF = 1:nFiles
fileList = dir(folderList{iF});
idxGood = arrayfun(@(x) ~strcmp(x.name(1), '.'), fileList); % identify files that do not start with '.'
fileList = fileList(idxGood);
idxPl2 = arrayfun(@(x) ~isempty(strfind(x.name, '.pl2')), fileList); % identify file that contain .pl (i.e. .plx or .pl2)
rawFile = fileList(idxPl2).name;
rawPath{iF} = fullfile(folderList{iF}, rawFile);
[~, fileName{iF}] = fileparts(rawPath{iF});
kiloFolderList{iF} = fullfile(folderList{iF}, 'kiloSorted');
datPathList{iF} = fullfile(kiloFolderList{iF}, [fileName{iF} '.dat']);
end
%% (1) convert, (2) copy masterMegaFile into kiloSorted folder, (3) sort:
for iF = 1:nFiles
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
disp(['~~~~~ ' rawPath{iF}])
disp('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
% convert:
if performConversion
if exist(rawPath{iF}, 'file')
convertRawToDat(rawPath{iF}, opts);
end
end
% kiloSort:
if performKiloSort
copyfile(fullfile(paths.kiloTools, 'masterMegaFile.m') ,kiloFolderList{iF});
if exist(datPathList{iF}, 'file')
cd(kiloFolderList{iF})
masterMegaFile(datPathList{iF}, fs, nCh, probeGeometry, Nfilt);
end
end
end
try
load gong
soundsc(y, Fs)
% evalc('soundsc(double(aiffread(''/System/Library/Sounds/Glass.aiff''))'',50000)');
catch
end
%% NOW YOU SORT BY HAND.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% manually curate spikes with PHY %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% and then run batch_mkKsFigs.m %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fin.
%%%%%%%%%%%%%%%%%%%%%