paradigma 0.1.5__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. paradigma/__init__.py +1 -3
  2. paradigma/constants.py +35 -0
  3. paradigma/feature_extraction.py +678 -0
  4. paradigma/gait_analysis.py +413 -0
  5. paradigma/gait_analysis_config.py +244 -0
  6. paradigma/heart_rate_analysis.py +127 -0
  7. paradigma/heart_rate_analysis_config.py +9 -0
  8. paradigma/heart_rate_util.py +173 -0
  9. paradigma/imu_preprocessing.py +229 -0
  10. paradigma/ppg/classifier/LR_PPG_quality.pkl +0 -0
  11. paradigma/ppg/classifier/LR_model.mat +0 -0
  12. paradigma/ppg/feat_extraction/acc_feature.m +20 -0
  13. paradigma/ppg/feat_extraction/peakdet.m +64 -0
  14. paradigma/ppg/feat_extraction/ppg_features.m +53 -0
  15. paradigma/ppg/glob_functions/extract_hr_segments.m +37 -0
  16. paradigma/ppg/glob_functions/extract_overlapping_segments.m +23 -0
  17. paradigma/ppg/glob_functions/jsonlab/AUTHORS.txt +41 -0
  18. paradigma/ppg/glob_functions/jsonlab/ChangeLog.txt +74 -0
  19. paradigma/ppg/glob_functions/jsonlab/LICENSE_BSD.txt +25 -0
  20. paradigma/ppg/glob_functions/jsonlab/LICENSE_GPLv3.txt +699 -0
  21. paradigma/ppg/glob_functions/jsonlab/README.txt +394 -0
  22. paradigma/ppg/glob_functions/jsonlab/examples/.svn/entries +368 -0
  23. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_jsonlab_basic.m.svn-base +180 -0
  24. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/demo_ubjson_basic.m.svn-base +180 -0
  25. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example1.json.svn-base +23 -0
  26. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example2.json.svn-base +22 -0
  27. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example3.json.svn-base +11 -0
  28. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/example4.json.svn-base +34 -0
  29. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_basictest.matlab.svn-base +662 -0
  30. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.m.svn-base +27 -0
  31. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_selftest.matlab.svn-base +144 -0
  32. paradigma/ppg/glob_functions/jsonlab/examples/.svn/text-base/jsonlab_speedtest.m.svn-base +21 -0
  33. paradigma/ppg/glob_functions/jsonlab/examples/demo_jsonlab_basic.m +180 -0
  34. paradigma/ppg/glob_functions/jsonlab/examples/demo_ubjson_basic.m +180 -0
  35. paradigma/ppg/glob_functions/jsonlab/examples/example1.json +23 -0
  36. paradigma/ppg/glob_functions/jsonlab/examples/example2.json +22 -0
  37. paradigma/ppg/glob_functions/jsonlab/examples/example3.json +11 -0
  38. paradigma/ppg/glob_functions/jsonlab/examples/example4.json +34 -0
  39. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_basictest.matlab +662 -0
  40. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.m +27 -0
  41. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_selftest.matlab +144 -0
  42. paradigma/ppg/glob_functions/jsonlab/examples/jsonlab_speedtest.m +21 -0
  43. paradigma/ppg/glob_functions/jsonlab/jsonopt.m +32 -0
  44. paradigma/ppg/glob_functions/jsonlab/loadjson.m +566 -0
  45. paradigma/ppg/glob_functions/jsonlab/loadubjson.m +528 -0
  46. paradigma/ppg/glob_functions/jsonlab/mergestruct.m +33 -0
  47. paradigma/ppg/glob_functions/jsonlab/savejson.m +475 -0
  48. paradigma/ppg/glob_functions/jsonlab/saveubjson.m +504 -0
  49. paradigma/ppg/glob_functions/jsonlab/varargin2struct.m +40 -0
  50. paradigma/ppg/glob_functions/sample_prob_final.m +49 -0
  51. paradigma/ppg/glob_functions/synchronization.m +76 -0
  52. paradigma/ppg/glob_functions/tsdf_scan_meta.m +22 -0
  53. paradigma/ppg/hr_functions/Long_TFD_JOT.m +37 -0
  54. paradigma/ppg/hr_functions/PPG_TFD_HR.m +59 -0
  55. paradigma/ppg/hr_functions/TFD toolbox JOT/.gitignore +4 -0
  56. paradigma/ppg/hr_functions/TFD toolbox JOT/CHANGELOG.md +23 -0
  57. paradigma/ppg/hr_functions/TFD toolbox JOT/LICENCE.md +27 -0
  58. paradigma/ppg/hr_functions/TFD toolbox JOT/README.md +251 -0
  59. paradigma/ppg/hr_functions/TFD toolbox JOT/README.pdf +0 -0
  60. paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_kern.m +142 -0
  61. paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_Doppler_lag_kern.m +314 -0
  62. paradigma/ppg/hr_functions/TFD toolbox JOT/common/gen_lag_kern.m +123 -0
  63. paradigma/ppg/hr_functions/TFD toolbox JOT/dec_tfd.m +154 -0
  64. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_di_gdtfd.m +194 -0
  65. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_li_gdtfd.m +200 -0
  66. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_nonsep_gdtfd.m +229 -0
  67. paradigma/ppg/hr_functions/TFD toolbox JOT/decimated_TFDs/dec_sep_gdtfd.m +241 -0
  68. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/di_gdtfd.m +157 -0
  69. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/li_gdtfd.m +190 -0
  70. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/nonsep_gdtfd.m +196 -0
  71. paradigma/ppg/hr_functions/TFD toolbox JOT/full_TFDs/sep_gdtfd.m +199 -0
  72. paradigma/ppg/hr_functions/TFD toolbox JOT/full_tfd.m +144 -0
  73. paradigma/ppg/hr_functions/TFD toolbox JOT/load_curdir.m +13 -0
  74. paradigma/ppg/hr_functions/TFD toolbox JOT/pics/decimated_TFDs_examples.png +0 -0
  75. paradigma/ppg/hr_functions/TFD toolbox JOT/pics/full_TFDs_examples.png +0 -0
  76. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/check_dec_params_seq.m +79 -0
  77. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispEE.m +9 -0
  78. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/dispVars.m +26 -0
  79. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/disp_bytes.m +25 -0
  80. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_full.m +40 -0
  81. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/fold_vector_half.m +34 -0
  82. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/gen_LFM.m +29 -0
  83. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_analytic_signal.m +76 -0
  84. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/get_window.m +176 -0
  85. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/isreal_fn.m +11 -0
  86. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/padWin.m +97 -0
  87. paradigma/ppg/hr_functions/TFD toolbox JOT/utils/vtfd.m +149 -0
  88. paradigma/ppg/preprocessing/preprocessing_imu.m +15 -0
  89. paradigma/ppg/preprocessing/preprocessing_ppg.m +13 -0
  90. paradigma/ppg_preprocessing.py +313 -0
  91. paradigma/preprocessing_config.py +64 -0
  92. paradigma/quantification.py +58 -0
  93. paradigma/tremor/TremorFeaturesAndClassification.m +345 -0
  94. paradigma/tremor/feat_extraction/DerivativesExtract.m +22 -0
  95. paradigma/tremor/feat_extraction/ExtractBandSignalsRMS.m +72 -0
  96. paradigma/tremor/feat_extraction/MFCCExtract.m +100 -0
  97. paradigma/tremor/feat_extraction/PSDBandPower.m +52 -0
  98. paradigma/tremor/feat_extraction/PSDEst.m +63 -0
  99. paradigma/tremor/feat_extraction/PSDExtrAxis.m +88 -0
  100. paradigma/tremor/feat_extraction/PSDExtrOpt.m +95 -0
  101. paradigma/tremor/preprocessing/InterpData.m +32 -0
  102. paradigma/tremor/weekly_aggregates/WeeklyAggregates.m +295 -0
  103. paradigma/util.py +50 -0
  104. paradigma/windowing.py +217 -0
  105. paradigma-0.2.0.dist-info/LICENSE +192 -0
  106. paradigma-0.2.0.dist-info/METADATA +58 -0
  107. paradigma-0.2.0.dist-info/RECORD +108 -0
  108. paradigma/dummy.py +0 -3
  109. paradigma-0.1.5.dist-info/LICENSE +0 -201
  110. paradigma-0.1.5.dist-info/METADATA +0 -18
  111. paradigma-0.1.5.dist-info/RECORD +0 -6
  112. {paradigma-0.1.5.dist-info → paradigma-0.2.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,394 @@
1
+ ===============================================================================
2
+ = JSONLab =
3
+ = An open-source MATLAB/Octave JSON encoder and decoder =
4
+ ===============================================================================
5
+
6
+ *Copyright (C) 2011-2015 Qianqian Fang <fangq at nmr.mgh.harvard.edu>
7
+ *License: BSD or GNU General Public License version 3 (GPL v3), see License*.txt
8
+ *Version: 1.0 (Optimus - Final)
9
+
10
+ -------------------------------------------------------------------------------
11
+
12
+ Table of Content:
13
+
14
+ I. Introduction
15
+ II. Installation
16
+ III.Using JSONLab
17
+ IV. Known Issues and TODOs
18
+ V. Contribution and feedback
19
+
20
+ -------------------------------------------------------------------------------
21
+
22
+ I. Introduction
23
+
24
+ JSON ([http://www.json.org/ JavaScript Object Notation]) is a highly portable,
25
+ human-readable and "[http://en.wikipedia.org/wiki/JSON fat-free]" text format
26
+ to represent complex and hierarchical data. It is as powerful as
27
+ [http://en.wikipedia.org/wiki/XML XML], but less verbose. JSON format is widely
28
+ used for data-exchange in applications, and is essential for the wild success
29
+ of [http://en.wikipedia.org/wiki/Ajax_(programming) Ajax] and
30
+ [http://en.wikipedia.org/wiki/Web_2.0 Web2.0].
31
+
32
+ UBJSON (Universal Binary JSON) is a binary JSON format, specifically
33
+ optimized for compact file size and better performance while keeping
34
+ the semantics as simple as the text-based JSON format. Using the UBJSON
35
+ format allows to wrap complex binary data in a flexible and extensible
36
+ structure, making it possible to process complex and large dataset
37
+ without accuracy loss due to text conversions.
38
+
39
+ We envision that both JSON and its binary version will serve as part of
40
+ the mainstream data-exchange formats for scientific research in the future.
41
+ It will provide the flexibility and generality achieved by other popular
42
+ general-purpose file specifications, such as
43
+ [http://www.hdfgroup.org/HDF5/whatishdf5.html HDF5], with significantly
44
+ reduced complexity and enhanced performance.
45
+
46
+ JSONLab is a free and open-source implementation of a JSON/UBJSON encoder
47
+ and a decoder in the native MATLAB language. It can be used to convert a MATLAB
48
+ data structure (array, struct, cell, struct array and cell array) into
49
+ JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB
50
+ data structure. JSONLab supports both MATLAB and
51
+ [http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone).
52
+
53
+ -------------------------------------------------------------------------------
54
+
55
+ II. Installation
56
+
57
+ The installation of JSONLab is no different than any other simple
58
+ MATLAB toolbox. You only need to download/unzip the JSONLab package
59
+ to a folder, and add the folder's path to MATLAB/Octave's path list
60
+ by using the following command:
61
+
62
+ addpath('/path/to/jsonlab');
63
+
64
+ If you want to add this path permanently, you need to type "pathtool",
65
+ browse to the jsonlab root folder and add to the list, then click "Save".
66
+ Then, run "rehash" in MATLAB, and type "which loadjson", if you see an
67
+ output, that means JSONLab is installed for MATLAB/Octave.
68
+
69
+ -------------------------------------------------------------------------------
70
+
71
+ III.Using JSONLab
72
+
73
+ JSONLab provides two functions, loadjson.m -- a MATLAB->JSON decoder,
74
+ and savejson.m -- a MATLAB->JSON encoder, for the text-based JSON, and
75
+ two equivallent functions -- loadubjson and saveubjson for the binary
76
+ JSON. The detailed help info for the four functions can be found below:
77
+
78
+ === loadjson.m ===
79
+ <pre>
80
+ data=loadjson(fname,opt)
81
+ or
82
+ data=loadjson(fname,'param1',value1,'param2',value2,...)
83
+
84
+ parse a JSON (JavaScript Object Notation) file or string
85
+
86
+ authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
87
+ created on 2011/09/09, including previous works from
88
+
89
+ Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
90
+ created on 2009/11/02
91
+ Fran�ois Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
92
+ created on 2009/03/22
93
+ Joel Feenstra:
94
+ http://www.mathworks.com/matlabcentral/fileexchange/20565
95
+ created on 2008/07/03
96
+
97
+ $Id: loadjson.m 452 2014-11-22 16:43:33Z fangq $
98
+
99
+ input:
100
+ fname: input file name, if fname contains "{}" or "[]", fname
101
+ will be interpreted as a JSON string
102
+ opt: a struct to store parsing options, opt can be replaced by
103
+ a list of ('param',value) pairs - the param string is equivallent
104
+ to a field in opt. opt can have the following
105
+ fields (first in [.|.] is the default)
106
+
107
+ opt.SimplifyCell [0|1]: if set to 1, loadjson will call cell2mat
108
+ for each element of the JSON data, and group
109
+ arrays based on the cell2mat rules.
110
+ opt.FastArrayParser [1|0 or integer]: if set to 1, use a
111
+ speed-optimized array parser when loading an
112
+ array object. The fast array parser may
113
+ collapse block arrays into a single large
114
+ array similar to rules defined in cell2mat; 0 to
115
+ use a legacy parser; if set to a larger-than-1
116
+ value, this option will specify the minimum
117
+ dimension to enable the fast array parser. For
118
+ example, if the input is a 3D array, setting
119
+ FastArrayParser to 1 will return a 3D array;
120
+ setting to 2 will return a cell array of 2D
121
+ arrays; setting to 3 will return to a 2D cell
122
+ array of 1D vectors; setting to 4 will return a
123
+ 3D cell array.
124
+ opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
125
+
126
+ output:
127
+ dat: a cell array, where {...} blocks are converted into cell arrays,
128
+ and [...] are converted to arrays
129
+
130
+ examples:
131
+ dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
132
+ dat=loadjson(['examples' filesep 'example1.json'])
133
+ dat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',1)
134
+ </pre>
135
+
136
+ === savejson.m ===
137
+
138
+ <pre>
139
+ json=savejson(rootname,obj,filename)
140
+ or
141
+ json=savejson(rootname,obj,opt)
142
+ json=savejson(rootname,obj,'param1',value1,'param2',value2,...)
143
+
144
+ convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
145
+ Object Notation) string
146
+
147
+ author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
148
+ created on 2011/09/09
149
+
150
+ $Id: savejson.m 458 2014-12-19 22:17:17Z fangq $
151
+
152
+ input:
153
+ rootname: the name of the root-object, when set to '', the root name
154
+ is ignored, however, when opt.ForceRootName is set to 1 (see below),
155
+ the MATLAB variable name will be used as the root name.
156
+ obj: a MATLAB object (array, cell, cell array, struct, struct array).
157
+ filename: a string for the file name to save the output JSON data.
158
+ opt: a struct for additional options, ignore to use default values.
159
+ opt can have the following fields (first in [.|.] is the default)
160
+
161
+ opt.FileName [''|string]: a file name to save the output JSON data
162
+ opt.FloatFormat ['%.10g'|string]: format to show each numeric element
163
+ of a 1D/2D array;
164
+ opt.ArrayIndent [1|0]: if 1, output explicit data array with
165
+ precedent indentation; if 0, no indentation
166
+ opt.ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
167
+ array in JSON array format; if sets to 1, an
168
+ array will be shown as a struct with fields
169
+ "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
170
+ sparse arrays, the non-zero elements will be
171
+ saved to _ArrayData_ field in triplet-format i.e.
172
+ (ix,iy,val) and "_ArrayIsSparse_" will be added
173
+ with a value of 1; for a complex array, the
174
+ _ArrayData_ array will include two columns
175
+ (4 for sparse) to record the real and imaginary
176
+ parts, and also "_ArrayIsComplex_":1 is added.
177
+ opt.ParseLogical [0|1]: if this is set to 1, logical array elem
178
+ will use true/false rather than 1/0.
179
+ opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
180
+ numerical element will be shown without a square
181
+ bracket, unless it is the root object; if 0, square
182
+ brackets are forced for any numerical arrays.
183
+ opt.ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
184
+ will use the name of the passed obj variable as the
185
+ root object name; if obj is an expression and
186
+ does not have a name, 'root' will be used; if this
187
+ is set to 0 and rootname is empty, the root level
188
+ will be merged down to the lower level.
189
+ opt.Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
190
+ to represent +/-Inf. The matched pattern is '([-+]*)Inf'
191
+ and $1 represents the sign. For those who want to use
192
+ 1e999 to represent Inf, they can set opt.Inf to '$11e999'
193
+ opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
194
+ to represent NaN
195
+ opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
196
+ for example, if opt.JSONP='foo', the JSON data is
197
+ wrapped inside a function call as 'foo(...);'
198
+ opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson
199
+ back to the string form
200
+ opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
201
+ opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
202
+
203
+ opt can be replaced by a list of ('param',value) pairs. The param
204
+ string is equivallent to a field in opt and is case sensitive.
205
+ output:
206
+ json: a string in the JSON format (see http://json.org)
207
+
208
+ examples:
209
+ jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
210
+ 'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
211
+ 'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
212
+ 2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
213
+ 'MeshCreator','FangQ','MeshTitle','T6 Cube',...
214
+ 'SpecialData',[nan, inf, -inf]);
215
+ savejson('jmesh',jsonmesh)
216
+ savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')
217
+ </pre>
218
+
219
+ === loadubjson.m ===
220
+
221
+ <pre>
222
+ data=loadubjson(fname,opt)
223
+ or
224
+ data=loadubjson(fname,'param1',value1,'param2',value2,...)
225
+
226
+ parse a JSON (JavaScript Object Notation) file or string
227
+
228
+ authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
229
+ created on 2013/08/01
230
+
231
+ $Id: loadubjson.m 436 2014-08-05 20:51:40Z fangq $
232
+
233
+ input:
234
+ fname: input file name, if fname contains "{}" or "[]", fname
235
+ will be interpreted as a UBJSON string
236
+ opt: a struct to store parsing options, opt can be replaced by
237
+ a list of ('param',value) pairs - the param string is equivallent
238
+ to a field in opt. opt can have the following
239
+ fields (first in [.|.] is the default)
240
+
241
+ opt.SimplifyCell [0|1]: if set to 1, loadubjson will call cell2mat
242
+ for each element of the JSON data, and group
243
+ arrays based on the cell2mat rules.
244
+ opt.IntEndian [B|L]: specify the endianness of the integer fields
245
+ in the UBJSON input data. B - Big-Endian format for
246
+ integers (as required in the UBJSON specification);
247
+ L - input integer fields are in Little-Endian order.
248
+
249
+ output:
250
+ dat: a cell array, where {...} blocks are converted into cell arrays,
251
+ and [...] are converted to arrays
252
+
253
+ examples:
254
+ obj=struct('string','value','array',[1 2 3]);
255
+ ubjdata=saveubjson('obj',obj);
256
+ dat=loadubjson(ubjdata)
257
+ dat=loadubjson(['examples' filesep 'example1.ubj'])
258
+ dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',1)
259
+ </pre>
260
+
261
+ === saveubjson.m ===
262
+
263
+ <pre>
264
+ json=saveubjson(rootname,obj,filename)
265
+ or
266
+ json=saveubjson(rootname,obj,opt)
267
+ json=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
268
+
269
+ convert a MATLAB object (cell, struct or array) into a Universal
270
+ Binary JSON (UBJSON) binary string
271
+
272
+ author: Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
273
+ created on 2013/08/17
274
+
275
+ $Id: saveubjson.m 440 2014-09-17 19:59:45Z fangq $
276
+
277
+ input:
278
+ rootname: the name of the root-object, when set to '', the root name
279
+ is ignored, however, when opt.ForceRootName is set to 1 (see below),
280
+ the MATLAB variable name will be used as the root name.
281
+ obj: a MATLAB object (array, cell, cell array, struct, struct array)
282
+ filename: a string for the file name to save the output UBJSON data
283
+ opt: a struct for additional options, ignore to use default values.
284
+ opt can have the following fields (first in [.|.] is the default)
285
+
286
+ opt.FileName [''|string]: a file name to save the output JSON data
287
+ opt.ArrayToStruct[0|1]: when set to 0, saveubjson outputs 1D/2D
288
+ array in JSON array format; if sets to 1, an
289
+ array will be shown as a struct with fields
290
+ "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
291
+ sparse arrays, the non-zero elements will be
292
+ saved to _ArrayData_ field in triplet-format i.e.
293
+ (ix,iy,val) and "_ArrayIsSparse_" will be added
294
+ with a value of 1; for a complex array, the
295
+ _ArrayData_ array will include two columns
296
+ (4 for sparse) to record the real and imaginary
297
+ parts, and also "_ArrayIsComplex_":1 is added.
298
+ opt.ParseLogical [1|0]: if this is set to 1, logical array elem
299
+ will use true/false rather than 1/0.
300
+ opt.NoRowBracket [1|0]: if this is set to 1, arrays with a single
301
+ numerical element will be shown without a square
302
+ bracket, unless it is the root object; if 0, square
303
+ brackets are forced for any numerical arrays.
304
+ opt.ForceRootName [0|1]: when set to 1 and rootname is empty, saveubjson
305
+ will use the name of the passed obj variable as the
306
+ root object name; if obj is an expression and
307
+ does not have a name, 'root' will be used; if this
308
+ is set to 0 and rootname is empty, the root level
309
+ will be merged down to the lower level.
310
+ opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
311
+ for example, if opt.JSON='foo', the JSON data is
312
+ wrapped inside a function call as 'foo(...);'
313
+ opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson
314
+ back to the string form
315
+
316
+ opt can be replaced by a list of ('param',value) pairs. The param
317
+ string is equivallent to a field in opt and is case sensitive.
318
+ output:
319
+ json: a binary string in the UBJSON format (see http://ubjson.org)
320
+
321
+ examples:
322
+ jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
323
+ 'MeshTetra',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
324
+ 'MeshTri',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
325
+ 2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
326
+ 'MeshCreator','FangQ','MeshTitle','T6 Cube',...
327
+ 'SpecialData',[nan, inf, -inf]);
328
+ saveubjson('jsonmesh',jsonmesh)
329
+ saveubjson('jsonmesh',jsonmesh,'meshdata.ubj')
330
+ </pre>
331
+
332
+
333
+ === examples ===
334
+
335
+ Under the "examples" folder, you can find several scripts to demonstrate the
336
+ basic utilities of JSONLab. Running the "demo_jsonlab_basic.m" script, you
337
+ will see the conversions from MATLAB data structure to JSON text and backward.
338
+ In "jsonlab_selftest.m", we load complex JSON files downloaded from the Internet
339
+ and validate the loadjson/savejson functions for regression testing purposes.
340
+ Similarly, a "demo_ubjson_basic.m" script is provided to test the saveubjson
341
+ and loadubjson pairs for various matlab data structures.
342
+
343
+ Please run these examples and understand how JSONLab works before you use
344
+ it to process your data.
345
+
346
+ -------------------------------------------------------------------------------
347
+
348
+ IV. Known Issues and TODOs
349
+
350
+ JSONLab has several known limitations. We are striving to make it more general
351
+ and robust. Hopefully in a few future releases, the limitations become less.
352
+
353
+ Here are the known issues:
354
+
355
+ # 3D or higher dimensional cell/struct-arrays will be converted to 2D arrays;
356
+ # When processing names containing multi-byte characters, Octave and MATLAB \
357
+ can give different field-names; you can use feature('DefaultCharacterSet','latin1') \
358
+ in MATLAB to get consistant results
359
+ # savejson can not handle class and dataset.
360
+ # saveubjson converts a logical array into a uint8 ([U]) array
361
+ # an unofficial N-D array count syntax is implemented in saveubjson. We are \
362
+ actively communicating with the UBJSON spec maintainer to investigate the \
363
+ possibility of making it upstream
364
+ # loadubjson can not parse all UBJSON Specification (Draft 9) compliant \
365
+ files, however, it can parse all UBJSON files produced by saveubjson.
366
+
367
+ -------------------------------------------------------------------------------
368
+
369
+ V. Contribution and feedback
370
+
371
+ JSONLab is an open-source project. This means you can not only use it and modify
372
+ it as you wish, but also you can contribute your changes back to JSONLab so
373
+ that everyone else can enjoy the improvement. For anyone who want to contribute,
374
+ please download JSONLab source code from it's subversion repository by using the
375
+ following command:
376
+
377
+ svn checkout svn://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab jsonlab
378
+
379
+ You can make changes to the files as needed. Once you are satisfied with your
380
+ changes, and ready to share it with others, please cd the root directory of
381
+ JSONLab, and type
382
+
383
+ svn diff > yourname_featurename.patch
384
+
385
+ You then email the .patch file to JSONLab's maintainer, Qianqian Fang, at
386
+ the email address shown in the beginning of this file. Qianqian will review
387
+ the changes and commit it to the subversion if they are satisfactory.
388
+
389
+ We appreciate any suggestions and feedbacks from you. Please use iso2mesh's
390
+ mailing list to report any questions you may have with JSONLab:
391
+
392
+ http://groups.google.com/group/iso2mesh-users?hl=en&pli=1
393
+
394
+ (Subscription to the mailing list is needed in order to post messages).