-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_get_wdq.m
56 lines (52 loc) · 1.8 KB
/
pspm_get_wdq.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
function [sts, import, sourceinfo] = pspm_get_wdq(datafile, import)
% ● Description
% pspm_get_wdq is the main function for import of Dataq/Windaq files
% ● Format
% [sts, import, sourceinfo] = pspm_get_wdq(datafile, import);
% ● Arguments
% datafile:
% import:
% ● Outputs
% sts:
% import:
% sourceinfo:
% ● Developer's Notes
% this function uses the conversion routine ReadDataq.m provided by Dataq
% developers. ActiveX control elements provided in the file activex.exe
% provided by Dataq must be installed, too.
% ● History
% Introduced in PsPM 3.0
% Written in 2008-2015 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)
% Maintained in 2022 by Teddy Chao (UCL)
%% Initialise
global settings
if isempty(settings)
pspm_init;
end
sts = -1;
sourceinfo = [];
addpath(pspm_path('Import','wdq'));
% get external file, using Dataq functions
% -------------------------------------------------------------------------
inputdata = ReadDataq(datafile);
% extract individual channels
% -------------------------------------------------------------------------
% loop through import jobs
for k = 1:numel(import)
channel = import{k}.channel;
if channel > size(inputdata.Data, 2)
warning('Channel %1.0f does not exist in data file', channel); return;
end;
import{k}.sr = inputdata.SR; % sample rate per channel
import{k}.data = inputdata.Data(:, channel); % data per channel
import{k}.units = inputdata.Units{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','wdq'));
sts = 1;
return