-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_writeJson.m
59 lines (55 loc) · 1.3 KB
/
f_writeJson.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
% -------------------------------------------------------
%
% f_writeJson - Write ECG data into json files
%
% Ver. 1.0.0
%
% Created: Claudia Nagel (13.10.2022)
% Last modified: Claudia Nagel (13.10.2022)
%
% Institute of Biomedical Engineering
% Karlsruhe Institute of Technology
%
% http://www.ibt.kit.edu
%
% Copyright 2000-2020 - All rights reserved.
%
% ------------------------------------------------------
%
% function [] = f_writeJson(signal, Fs, filename)
%
% Inputs:
% signal: ECG signal (LxT vector, L: leads, T: timesteps)
% Fs: sampling rate
% filename: filename the data should be stored in
%
% Outputs:
%
%
% Example Usage:
% f_writeJson(ecg, 500, 'ecg_synthesized.json')
%
% Revision history:
%
%
function [] = f_writeJson(signal, Fs, filename)
% specify all fields in json struct
val.t = 0:1:size(signal,2)-1;
val.ecg.I = signal(1,:);
val.ecg.II = signal(2,:);
val.ecg.III = signal(3,:);
val.ecg.aVR = signal(4,:);
val.ecg.aVL = signal(5,:);
val.ecg.aVF = signal(6,:);
val.ecg.V1 = signal(7,:);
val.ecg.V2 = signal(8,:);
val.ecg.V3 = signal(9,:);
val.ecg.V4 = signal(10,:);
val.ecg.V5 = signal(11,:);
val.ecg.V6 = signal(12,:);
val.Fs = Fs;
json_struct = jsonencode(val);
fid = fopen(filename,'wt');
fprintf(fid, json_struct);
fclose(fid);
end