0001 function write_ibex_mat(fname, fmdl, imgs, frame_rate)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 [llROI, rlROI, thROI] = get_ROIs(fmdl);
0016 imgs(isnan(imgs))= 0;
0017 data = create_data(imgs, frame_rate, thROI, llROI, rlROI );
0018 save(fname,'data');
0019
0020 function [llung_ROI, rlung_ROI, thorax_ROI] = get_ROIs(fmdl);
0021 lmi = length(fmdl.mat_idx);
0022 img = mk_image(fmdl, 1);
0023 if lmi==1;
0024 error('Need mat_idx regions to segment lungs');
0025 elseif lmi==2;
0026 img.elem_data(fmdl.mat_idx{2}) = 0.3;
0027 else
0028 img.elem_data(fmdl.mat_idx{2}) = 0.3;
0029 img.elem_data(fmdl.mat_idx{3}) = 0.3;
0030 end
0031 img.calc_colours.npoints = 32;
0032 ROI = calc_slices(img,1);
0033 if ~(size(ROI)==[32,32])
0034 error('image size must be 32×32');
0035 end
0036
0037 thorax_ROI= ~isnan(ROI);
0038 lung_ROI = thorax_ROI & (ROI==0.3);
0039 xpts = linspace(-1,1,32);
0040 rlung_ROI = lung_ROI & (xpts<0);
0041 llung_ROI = lung_ROI & (xpts>0);
0042
0043 function data = create_data(imgs, FR, thorax_ROI, llung_ROI, rlung_ROI);
0044 data.imageRate = FR;
0045
0046 data.patient.ROI.Inside =thorax_ROI*100;
0047 data.patient.ROI.RightLung =rlung_ROI*100;
0048 data.patient.ROI.LeftLung =llung_ROI*100;
0049 data.patient.ROI.Heart =zeros(size(imgs,1),size(imgs,2));
0050
0051
0052 data.patient.halfChest = 'NaN';
0053 data.patient.height = 'NaN';
0054 data.patient.weight = 'NaN';
0055 data.patient.gender = 'NaN';
0056
0057 data.measurement.Position.transversal = zeros (1,size(imgs,3));
0058 data.measurement.Position.longitudinal = zeros (1,size(imgs,3));
0059 data.measurement.ImageQuality = 100*ones(1,size(imgs,3));
0060 data.measurement.ElectrodeQuality = zeros(size(imgs,3),32);
0061 data.measurement.ZeroRef = imgs;
0062
0063 data.injctionPattern= 'NaN';
0064 data.SensorBelt.NumEl= 'NaN';
0065
0066 data.measurement.CompositValue=squeeze(sum(sum(imgs,2),1));
0067
0068