-
Notifications
You must be signed in to change notification settings - Fork 1
/
extractLFPBinaryFilesAbdel.m
59 lines (48 loc) · 1.99 KB
/
extractLFPBinaryFilesAbdel.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
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
function extractLFPBinaryFilesAbdel(fileNameMask, useRefs)
%
%extractLFPBinaryFiles(fileNameMask)
%extractLFPBinaryFiles(fileNameMask, useRefs)
%
%Extracts and saves LFP information from a .rec file. The extracted files
%are saved in a new subfolder in the same directory as the .rec file.
%
%fileNameMask: this is the name of the rec file without the .rec
%extention (example: 'myfile' for myfile.rec). If multiple .rec files need
%to be stitched together, you can use the part of the filename that all
%files have in common, assuming the first part is the same (example:
%'myfile' for myfile_part1.rec and myfile_part2.rec). The files will be
%stiched together sorted by the time when the files were created.
%
%useRefs (default 0): this determines whether or not the saved files are
%utilizing the digital reference settings in the .rec file. A value of 1
%turns referencing on.
if (nargin < 2)
useRefs = 0;
elseif (useRefs > 1) || (useRefs < 0)
error('useRefs argument must be either 0 or 1');
end
recFiles = dir([fileNameMask,'*.rec']);
recFileString = [];
recFileDates = [];
for i=1:length(recFiles)
recFileDates = [recFileDates;recFiles(i).datenum];
end
[s, sind] = sort(recFileDates);
for i=1:length(sind)
recFileString = [recFileString ' -rec ' recFiles(sind(i)).name];
end
%Find the path to the extraction programs
trodesPath = which('trodes_path_placeholder.m');
trodesPath = fileparts(trodesPath);
%Beacuse the path may have spaces in it, we deal with it differently in
%windows vs mac/linux
disp(['"',fullfile(trodesPath,'exportLFP'),'"', recFileString, ' -output ', fileNameMask]);
if ispc
eval(['!"',fullfile(trodesPath,'exportLFP'),'"', recFileString,' -usespikefilters',' 0',...
' -lowpass',' -1',' -highpass',' -1', ' -userefs',' 0',...
' -outputrate',' 30000',' -output ', fileNameMask]);
else
escapeChar = '\ ';
trodesPath = strrep(trodesPath, ' ', escapeChar);
eval(['!',fullfile(trodesPath,'exportLFP'), recFileString, ' -output ', fileNameMask]);
end