-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathputRawCSC.m
More file actions
53 lines (46 loc) · 1.66 KB
/
putRawCSC.m
File metadata and controls
53 lines (46 loc) · 1.66 KB
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
% putRawCSC.m
% demo on how to use Mat2NlxCSC
%
%
% example:
% putRawCSC( filenameOut, timestamps, dataSamples, ['Test header info'] );
% where timestamps and dataSamples are as returned by:
% [timestamps,dataSamples] = getRawCSCData( filename, fromInd, toInd, mode );
%
%urut/MPI/dec11
%urut/feb13 added exporting Fs/validSamples/channelNr to make compatible
%with windows version
%
function putRawCSC( filenameOut, timestamps, dataSamples,ChannelNumbers, SampleFrequencies, NumberOfValidSamples, headerLines )
blocksize = 512;
AppendFile = 0;
ExtractMode = 1;
ModeArray = 1;
NumRecs=length(timestamps);
FieldSelection(1) = 1; %timestamps
FieldSelection(2) = 1; %channel nr
FieldSelection(3) = 1; %sample freq
FieldSelection(4) = 1; % valid samples
FieldSelection(5) = 1; %samples
FieldSelection(6) = 1;%header
HeaderOut{1} = ['######## Neuralynx']; %this is REQUIRED as header prefix
HeaderOut{2} = ['FileExport Mat2NlxCSC-urut unix-vers'];
if iscell(headerLines)
for k=1:length(headerLines)
HeaderOut{2+k} = headerLines{k};
end
else
HeaderOut{3} = [' ' headerLines];
end
% if one row/column, reformat into blocks
if size(dataSamples,1)==1 || size(dataSamples,2)==1
SamplesOut = reshape(dataSamples, blocksize, length(dataSamples)/blocksize);
else
SamplesOut = dataSamples;
end
if AppendFile==0 & exist(filenameOut)
warning(['Append is disabled and file exists already -- need to delete manually, will be corrupt: ' filenameOut]);
end
Mat2NlxCSC( filenameOut, AppendFile, ExtractMode, ModeArray, NumRecs,...
FieldSelection, timestamps, ChannelNumbers, SampleFrequencies,...
NumberOfValidSamples, SamplesOut, HeaderOut' );