-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_row_to_column_CM.m
More file actions
42 lines (41 loc) · 1.45 KB
/
change_row_to_column_CM.m
File metadata and controls
42 lines (41 loc) · 1.45 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
function data=change_row_to_column_CM(data)
%________________________________________________________________________________________________________________________
% Utilized in analysis by Kevin L. Turner
% The Pennsylvania State University, Dept. of Biomedical Engineering
% https://github.com/KL-Turner
%
% Code unchanged with the exception of this title block for record keeping
%
% Last Opened: February 23rd, 2019
%________________________________________________________________________________________________________________________
%
% Helper routine to transform 1d arrays into column vectors that are needed
% by other routines in Chronux
%
% Usage: data=change_row_to_column(data)
%
% Inputs:
% data -- required. If data is a matrix, it is assumed that it is of the
% form samples x channels/trials and it is returned without change. If it
% is a vector, it is transformed to a column vector. If it is a struct
% array of dimension 1, it is again returned as a column vector. If it is a
% struct array with multiple dimensions, it is returned without change
% Note that the routine only looks at the first field of a struct array.
%
% Ouputs:
% data (in the form samples x channels/trials)
%
dtmp=[];
if isstruct(data);
C=length(data);
if C==1;
fnames=fieldnames(data);
eval(['dtmp=data.' fnames{1} ';'])
data=dtmp(:);
end
else
[N,C]=size(data);
if N==1 || C==1;
data=data(:);
end;
end;