-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_get_wdq_n.m
62 lines (58 loc) · 2.19 KB
/
pspm_get_wdq_n.m
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
function [sts, import, sourceinfo] = pspm_get_wdq_n(datafile, import)
% ● Description
% pspm_get_wdq_n is a function to import of Dataq/Windaq files
% ● Format
% [sts, import, sourceinfo] = pspm_get_wdq_n(datafile, import);
% ● Arguments
% datafile:
% import:
% ● Outputs
% sts:
% import:
% sourceinfo:
% ● Developer's Notes
% This function does not use the ActiveX control elements provided by
% Dataq developers. Instead it reads the binary file according to the
% documentation published by dataq
% (http://www.dataq.com/resources/techinfo/ff.htm).
% The current called routine nReadDataq.m may not provide as many data
% (check the commented header of the routine nReadDataq for more
% information) as the ActiveX control elements do, but the function is
% independent of cpu architecture. Which means it does not require a 32-bit
% Matlab-Version.
% ● History
% Introduced in PsPM 3.0
% Written in 2012-2015 by Tobias Moser (University of Zurich)
% Maintained in 2022 by Teddy Chao (UCL)
%% initialise
global settings
if isempty(settings)
pspm_init;
end
sts = -1;
sourceinfo = [];
addpath(pspm_path('Import','nwdq'));
% get external file, using Dataq functions
% -------------------------------------------------------------------------
[inputinfo, inputdata] = nReadDataq(datafile);
% extract individual channels
% -------------------------------------------------------------------------
% loop through import jobs
for k = 1:numel(import)
channel = import{k}.channel;
if channel > size(inputdata, 2)
warning('ID:channel_not_contained_in_file', 'Channel %1.0f does not exist in data file', channel); return;
end;
import{k}.sr = inputinfo.sampleRatePerChannel; % sample rate per channel
import{k}.data = inputdata{channel}; % data per channel
import{k}.units = inputinfo.engineeringUnitsTag(channel, :);
sourceinfo.channel{k, 1} = sprintf('Channel %02.0f', channel);
if strcmpi(settings.channeltypes(import{k}.typeno).data, 'events')
import{k}.marker = 'continuous';
end;
end;
% clear path and return
% -------------------------------------------------------------------------
rmpath(pspm_path('Import','nwdq'));
sts = 1;
return