-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpspm_get_acqmat.m
71 lines (61 loc) · 2.16 KB
/
pspm_get_acqmat.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
71
function [sts, import, sourceinfo] = pspm_get_acqmat(datafile, import)
% ● Description
% pspm_get_acqmat is the main function for import of exported
% biopac/acknowledge files, version 4.0 or higher (tested on 4.2.0)
% This function is based on sample files, not on proper documentation of the
% file format. Always check your imported data before using it.
% ● Format
% [sts, import, sourceinfo] = pspm_get_acqmat(datafile, import);
% ● Arguments
% datafile:
% import:
% .channel:
% .type:
% .data:
% .units:
% ● History
% Introduced in PsPM 3.0
% Written in 2008-2015 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)
%% Initialise
global settings
if isempty(settings)
pspm_init;
end
sts = -1;
sourceinfo = [];
% load data
% -------------------------------------------------------------------------
inputdata = load(datafile);
% extract individual channels
% -------------------------------------------------------------------------
for k = 1:numel(import)
% define channel number ---
if import{k}.channel > 0
channel = import{k}.channel;
else
channel = pspm_find_channel(cellstr(inputdata.labels), import{k}.type);
if channel < 1, return; end
end
if channel > size(inputdata.labels, 1), 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, inputdata.labels(channel, :));
% define sample rate ---
% catch cases that are not documented and on which we have no example
% data
if numel(inputdata.isi) == 1 && strcmpi(inputdata.isi_units, 'ms')
import{k}.sr = 1000/inputdata.isi;
else
warning('\nUnsupported modality - please notify the developers.\n'); return;
end
if inputdata.start_sample ~= 0
warning('\nUnsupported sampling scheme - please notify the developers.\n'); return;
end
% get data & data units
import{k}.data = double(inputdata.data(:, channel));
import{k}.units = inputdata.units(channel,:);
if strcmpi(settings.channeltypes(import{k}.typeno).data, 'events')
import{k}.marker = 'continuous';
end
end
%% Return values
sts = 1;
return