-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadInTDMSFile.m
More file actions
45 lines (41 loc) · 1.66 KB
/
ReadInTDMSFile.m
File metadata and controls
45 lines (41 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
function [tdmsData]=ReadInTDMSFile(filename)
% function [tdmsData]=ReadInTDMSFile(filename)
%
% Author: Aaron Winder
% Affiliation: Engineering Science and Mechanics, Penn State University
% https://github.com/awinde
%
% DESCRIPTION: Read in the .tdms files acquired using the LabVIEW
% acquisition scripts found at:
% https://github.com/awinde/LabVIEW---NVC-Acquisition
%
% The called function ConvertTDMS was downloaded from:
% http://www.mathworks.com/matlabcentral/fileexchange/44206-converttdms--v10-
%_______________________________________________________________
% PARAMETERS:
% filename - [string] tdms file name with extension
%_______________________________________________________________
% RETURN:
% tdmsData - [structure] contents of the .tdms file organized
% into a structure
%_______________________________________________________________
% Convert .tdms file into a data structure
[tempStruct,~]=convertTDMS(0,filename);
% Retrieve and name the measured data channels
channels = {tempStruct.Data.MeasuredData(:).Name};
omitString = 'Analog_Data'; % LabVIEW adds Analog_Data to the channel name
for c = 1:length(channels)
omitInds = length(omitString)+1:length(channels{c});
tdmsData.Data.(channels{c}(omitInds)) = ...
tempStruct.Data.MeasuredData(c).Data;
end
% Add trial notes to the structure
tdmsData.Info = tempStruct.Data.Root;
% Convert the numeric fields of the trial notes to integers
fnames = fieldnames(tdmsData.Info);
for fn = 1:length(fnames)
[converted,status] = str2num(tdmsData.Info.(fnames{fn}));
if status
tdmsData.Info.(fnames{fn}) = converted;
end
end