-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_get_vario.m
70 lines (60 loc) · 2.05 KB
/
pspm_get_vario.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
63
64
65
66
67
68
69
70
function [sts, import, sourceinfo] = pspm_get_vario(datafile, import)
% ● Description
% pspm_get_vario is the main function for import of VarioPort files
% this function uses the conversion routine getVarioPort.m
% written and maintained by Christoph Berger at the University of Rostock
% ● Format
% [sts, import, sourceinfo] = pspm_get_vario(datafile, import);
% ● Arguments
% datafile:
% import:
% ● Outputs
% sts:
% import:
% sourceinfo:
% ● 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','vario'));
%% get data
[vario, event] = getVarioport_allChannels(datafile);
% extract individual channels
% -------------------------------------------------------------------------
% loop through import jobs ---
for k = 1:numel(import)
if ~strcmpi(import{k}.type, 'marker')
% define channel number ---
if import{k}.channel > 0
channel = import{k}.channel;
else
channel = pspm_find_channel({vario.channel.name}, import{k}.type);
if channel < 1, return; end
end
if channel > size({vario.channel.name}, 2), warning('ID:channel_not_contained_in_file', 'Channel %02.0f not contained in file %s.\n', channel, datafile); return; end;
sourceinfo.channel{k, 1} = sprintf('Channel %02.0f: %s', channel, vario.channel(channel).name);
% sample rate
import{k}.sr = vario.channel(channel).scaled_scan_fac;
% units
import{k}.units = vario.channel(channel).unit;
% get data
import{k}.data = vario.channel(channel).data(:);
else
import{k}.sr = 1; % converted to seconds in getVarioport_allChannels.m
import{k}.data = [event.time];
import{k}.marker = 'timestamp';
import{k}.markerinfo.name = {event.name};
import{k}.markerinfo.value = {event.name};
end
end
%% clear path and return
rmpath(pspm_path('Import','vario'));
sts = 1;
return