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
| function SaveDataMAT(Path, fName, SmartXXX, RawDataset, srcPath, trials, IChansAdded, Nms, varargin)
global Nms
%Titles for synchronization modes
SynModes=[{'maximum value'}, {'minimum value'},{'global extremum'}, ...
{'begin of decrease'},{'begin of increase'},{'specific value'}];
%define MATRIX size for data saving
d3=size(SmartXXX,1); %the NUMBER of Trials (i.e. files)
d12=zeros(d3,3);
for dz=1:d3 %CYCLE by FILES
for dtype=1:3 %CYCLE by data type
d12(dz,dtype)=size(SmartXXX{dz}{4}{dtype},1);
end
end
dz12=max(d12,[],1); %vector-array (3 elems.) of MAX sizes for kinemat., EMG, FC
nLabs=SmartXXX{1}{3}(:); %The Number of labels of each type
opCell=cell(3,1);
%define structure array size for data saving
for dtype=1:3 %CYCLE by data type
ouDat=zeros(dz12(dtype),nLabs(dtype), d3);
%If data of varios length - equalize the lengths by adding NaN values
for dz=1:d3 %CYCLE by FILES
difz=dz12(dtype)-d12(dz,dtype);
if difz>0 ouDat(:, :, dz)=[SmartXXX{dz}{4}{dtype}; NaN(difz,nLabs(dtype))];
else ouDat(:, :, dz)=SmartXXX{dz}{4}{dtype}; end
end
opCell{dtype}=ouDat;
end
ffreq=[{'Frequency-kinematics'},{'Frequency-EMG'},{'Frequency-Force Platform'}];
ffreq(2,:)=num2cell(SmartXXX{1}{1});
% outdat - structure to save in .MAT-file
% build this structure from information loaded
%& recieved during data processing
outdat = struct('SourcePath', [], 'Trials',[],'Kinematics', [],'EMG',[], ...
'ForcePlate',[],'Frequencies',[], 'Labels',[],'DataStruct',[],'RawDataStruct',[]);
outdat.Kinematics=opCell{1};
outdat.EMG=opCell{2};
outdat.ForcePlate=opCell{3};
outdat.Frequencies=ffreq;
outdat.Labels=SmartXXX{1}{2};
outdat.DataStruct=SmartXXX{1}{3};
outdat.RawDataStruct=RawDataset;
outdat.SourcePath=srcPath;
outdat.Trials=trials;
outdat.AddedChansInfo=IChansAdded;
outdat.StartTime=SmartXXX{1}{7};
if size(varargin,2)>0 %data were synchronized - synchro data mode
s1=char(SynModes(varargin{1})); %Mode of synchronization
s=sprintf('Data synchronized on label %s (by %s)',varargin{2},s1); %which label was used for synchronization
% varargin=> SynModes(sMode), synLabel
outdat.SynchrInfo=s;
end
%SAVING marker information
MInfo=cell(d3,1); %place allocation for info of markers
for ntr=1:d3 %CYCLE by TRIALS
if size(SmartXXX{ntr},2)==8 %THERE is info of MARKERS
MInfo{ntr}=SmartXXX{ntr}{8};
end
end
outdat.MarkerInfo=MInfo;
outdat.MarkerNumber=Nms; %MAX marker number
save([Path, strrep(fName, 'tdf', 'mat')], 'outdat');
end |
Partager