### Install via Fedora Package Manager Source: https://neurojson.org/jsonlab Install the JSONLab and ZMat packages using the dnf package manager. ```bash sudo dnf install octave-jsonlab sudo dnf install octave-zmat ``` -------------------------------- ### Install via Debian/Ubuntu Package Manager Source: https://neurojson.org/jsonlab Install the JSONLab package using the apt-get package manager. ```bash sudo apt-get install octave-jsonlab ``` -------------------------------- ### Binary Format Processing Source: https://neurojson.org/jsonlab Examples for working with Binary JData, MessagePack, and UBJSON formats. ```matlab % Binary JData with savebj/loadbj (smaller, faster) data = struct('string', 'value', 'array', single([1 2 3])); savebj('', data, 'filename', 'data.bjd'); data = loadbj('data.bjd'); % MessagePack with savemsgpack/loadmsgpack savemsgpack('', data, 'data.msgpk'); data = loadmsgpack('data.msgpk'); % UBJSON with saveubjson/loadubjson saveubjson('', data, 'data.ubj'); data = loadubjson('data.ubj'); ``` -------------------------------- ### Clone JSONLab from GitHub Source: https://neurojson.org/jsonlab Download the source code repository directly from GitHub. ```bash git clone https://github.com/NeuroJSON/jsonlab.git ``` -------------------------------- ### Basic JSONLab Usage Source: https://neurojson.org/jsonlab Demonstrates saving and loading data using standard JSON and the unified savejd/loadjd interface. ```matlab % Save MATLAB data to JSON with savejson data = struct('name', 'JSONLab', 'version', 2.9, 'array', [1,2,3]); savejson('', data, 'filename', 'output.json'); % Load JSON file with loadjson data = loadjson('output.json'); % Unified interface: savejd/loadjd auto-detect format savejd('', data, 'output.json'); data = loadjd('output.json'); ``` -------------------------------- ### Manual MATLAB Path Configuration Source: https://neurojson.org/jsonlab Add the JSONLab directory to the MATLAB search path and refresh the path cache. ```matlab addpath('/path/to/jsonlab'); rehash; ``` -------------------------------- ### Data Linking and Caching Source: https://neurojson.org/jsonlab Download remote datasets and manage local file caching using jdlink and jsoncache. ```matlab % jdlink: dynamically download from REST APIs % Load dataset from NeuroJSON.io with loadjson ds = loadjson('https://neurojson.io:7777/openneuro/ds000001'); % Find linked files with jsonpath links = jsonpath(ds, '$..anat.._DataLink_'); % Download files matching regex pattern with jdlink files = jdlink(links, 'regex', 'sub-01_.*\.nii'); % Check cache location with jsoncache [cache_path, fname] = jsoncache(... 'https://neurojson.io:7777/openneuro/ds000001'); % Files cached in ~/.neurojson/ for fast reuse ``` -------------------------------- ### JData Format Encoding and Decoding Source: https://neurojson.org/jsonlab Shows how to handle complex MATLAB data types, sparse arrays, and compression using JData. ```matlab % JData format: encode complex MATLAB data with jdataencode raw = struct('complex', 2+4i, 'sparse', sparse(eye(5))); encoded = jdataencode(raw); savejson('', encoded); % Decode JData back to MATLAB with jdatadecode decoded = jdatadecode(encoded); % 3D arrays with type preservation data3d = reshape(1:24, 2, 3, 4); savejson('', data3d, 'NestArray', 0); % Compressed arrays in JSON/BJData savejson('', eye(100), 'Compression', 'zlib', 'CompressArraySize', 1); ``` -------------------------------- ### JSONPath Data Querying Source: https://neurojson.org/jsonlab Utilize JSONPath expressions to navigate, slice, and filter nested MATLAB structures. ```matlab % Query data structures with jsonpath data = struct('book', struct('title', {'Yoda', 'Jinn', 'Kenobi'}, ... 'author', {'Master', 'Qui-Gon', 'Obi-Wan'})); % Get nested field titles = jsonpath(data, '$.book.title') % Deep scan with .. operator authors = jsonpath(data, '$..author') % Array slicing [start:end] first_two = jsonpath(data, '$.book.title[0:1]') % Negative indices (last element) last_item = jsonpath(data, '$.book.title[-1]') ``` -------------------------------- ### JDict Attribute Access Source: https://neurojson.org/jsonlab Access and modify nested fields and metadata using xarray-like syntax in MATLAB. ```matlab % jdict: xarray-like attribute access for MATLAB data = struct('exp', struct('trials', rand(10,5))); jd = jdict(data); % Access nested fields with () trials = jd.('exp').('trials'); % Use JSONPath syntax trials = jd.('$.exp.trials'); % Modify values with .v() accessor jd.('exp').('trials').v(1) = 999; % Add xarray-like attributes with {} jd.('exp').('trials'){'dims'} = {'time', 'channels'}; jd.('exp').('trials'){'units'} = 'microvolts'; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.