write_hdf5_sample

PURPOSE ^

Write HDF5 Sample data

SYNOPSIS ^

function fname = write_and_test;

DESCRIPTION ^

 Write HDF5 Sample data
 Possner, Bulst, Adler "HDF5-based data format for EIT data", Conf. EIT2023
 $Id: write_hdf5_sample.m 7124 2024-12-29 15:18:32Z aadler $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % Write HDF5 Sample data
0002 % Possner, Bulst, Adler "HDF5-based data format for EIT data", Conf. EIT2023
0003 % $Id: write_hdf5_sample.m 7124 2024-12-29 15:18:32Z aadler $
0004 function fname = write_and_test;
0005   fname = 'montreal_data_1995_breathold.h5';
0006   delete(fname)
0007   hdf5_sample_write
0008   [dd,~,stim] = eidors_readdata('montreal_data_1995_breathold.h5','h5','datasetEIT');
0009   imdl = mk_common_model('c2t2',16);
0010   imdl.fwd_model = rmfield(imdl.fwd_model,'meas_select');
0011   imdl.fwd_model.stimulation = stim;
0012   imgr = inv_solve(imdl, dd(:,1), dd);
0013   show_slices(imgr);
0014 
0015 function hdf5_sample_write
0016    load 'montreal_data_1995.mat'
0017    txt = fileread('montreal_data_1995.readme');
0018    h5createwrite('/VERSION',2023.4,'double');
0019    h5createwrite('/patient/Readme',txt,'string');
0020    [stim,msel] = mk_stim_patterns(16,1,[0,1],[0,1],{'no_meas_current'},1);
0021    freq=13000; oo=ones(1,13); FR = 1/7; % 13 meas / frame
0022    stimprot= []; measprot= [];
0023    for i=1:length(stim);
0024       stimprot = [stimprot, stim(i).stim_pattern*oo];
0025       measprot = [measprot, stim(i).meas_pattern'];
0026    end
0027    h5createwrite('/data/datasetEIT/Meas.V.Abs',zc_breathhold(msel,:),'int16');
0028    for i=1:16;
0029       field = sprintf('/data/datasetEIT/protocol/Stim.I.%02d(A)',i);
0030       h5createwrite(field,stimprot(i,:),'int8');
0031       field = sprintf('/data/datasetEIT/protocol/Meas.V.%02d(V)',i);
0032       h5createwrite(field,measprot(i,:),'int8');
0033    end
0034    h5createwrite('/data/datasetEIT/protocol/Stim.I.freq(Hz)',freq,'double');
0035 
0036    h5createwrite('/data/datasetECG/Meas.V.Abs',ecg_breathhold,'int16');
0037    h5createwrite('/data/datasetECG/protocol/Stim.I.01(A)',0,'int8');
0038    h5createwrite('/data/datasetECG/protocol/Stim.I.02(A)',0,'int8');
0039    h5createwrite('/data/datasetECG/protocol/Stim.I.freq(Hz)',0,'double');
0040    h5createwrite('/data/datasetECG/protocol/Meas.V.01(V)', 1,'int8');
0041    h5createwrite('/data/datasetECG/protocol/Meas.V.02(V)',-1,'int8');
0042    h5createwrite('/data/datasetECG/protocol/Meas.V.freq(Hz)',0,'double');
0043    h5createwrite('/data/datasetECG/protocol/Meas.Dtime(s)',FR/16,'double');
0044 
0045 function h5createwrite(DS, data, datatype);
0046    fname = 'montreal_data_1995_breathold.h5';
0047    sz = size(data);
0048    if strcmp(datatype,'string');
0049       ver = eidors_obj('interpreter_version')
0050       if ~ver.isoctave && ver.ver>=10 %only in newer versions
0051          sz=1;
0052          data = convertCharsToStrings(data);
0053       else
0054          data(data>255) = 'e'; % we know this string, it only has e acute
0055          data = uint8(data);
0056          datatype='uint8'; 
0057          sz=length(data);
0058       end
0059    end
0060    h5create(fname,DS,sz, 'Datatype', datatype);
0061    h5write(fname,DS, full(data));

Generated on Sun 29-Dec-2024 11:41:59 by m2html © 2005