-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConvertToJPFormat.m
More file actions
32 lines (25 loc) · 852 Bytes
/
ConvertToJPFormat.m
File metadata and controls
32 lines (25 loc) · 852 Bytes
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
function ConvertToJPFormat(filename,startchan,endchan)
% get max duration
duration = nptReadSorterHdr(['sort' filesep '0001.hdr']);
% open binary file
fid = fopen(filename,'w','ieee-le');
dirlist = dir('*.0*');
trials = size(dirlist,1);
for i = 1:trials
% [path,filename,ext] = nptFileParts(dirlist(i).name);
% trialname = ext(2:length(ext));
fprintf('Reading %s...\n',dirlist(i).name);
[data,numchannels,samplingrate,scanorder,points] = nptReadStreamerFile(dirlist(i).name);
% pad data if necessary
maxpoints = duration * samplingrate;
padpoints = maxpoints-points;
if padpoints~=0
% pzeros = zeros(1,padpoints);
channels = endchan - startchan + 1;
pdata = transpose([data(startchan:endchan,:) zeros(channels,padpoints)]);
else
pdata = transpose(data(startchan:endchan,:));
end
fwrite(fid,pdata,'int16');
end
fclose(fid);