From d0e706c4e6774b3ea224d3acbbe7cc85bfb8ca91 Mon Sep 17 00:00:00 2001 From: 4gwe Date: Mon, 16 Mar 2026 08:59:13 +0100 Subject: [PATCH 1/6] Fix pspm_convert_au2unit to work correctly with files and add a test --- src/pspm_convert_au2unit.m | 2 +- test/pspm_convert_au2unit_test.m | 178 ++++++++++++++++++++++++++++++- 2 files changed, 175 insertions(+), 5 deletions(-) diff --git a/src/pspm_convert_au2unit.m b/src/pspm_convert_au2unit.m index 55b6667ad..e15ebc25a 100644 --- a/src/pspm_convert_au2unit.m +++ b/src/pspm_convert_au2unit.m @@ -163,7 +163,7 @@ [sts, channeldata, infos, pos_of_channel(i)] = pspm_load_channel(alldata, channel{i}, 'pupil'); if sts < 1, return; end % recursive call to avoid the formula being stated twice in the same function - [sts, convert_data.data{i}] = pspm_convert_au2unit(channeldata.data, unit, distance, record_method, ... + [sts, convert_data{i}.data] = pspm_convert_au2unit(channeldata.data, unit, distance, record_method, ... multiplicator, reference_distance, reference_unit, options); if sts < 1, return; end convert_data{i}.header = channeldata.header; diff --git a/test/pspm_convert_au2unit_test.m b/test/pspm_convert_au2unit_test.m index b13056d9b..079d5ccd3 100644 --- a/test/pspm_convert_au2unit_test.m +++ b/test/pspm_convert_au2unit_test.m @@ -1,6 +1,176 @@ classdef pspm_convert_au2unit_test < pspm_testcase - % ● Description - % unittest class for the pspm_convert_au2unit function - % ● Authorship - % (C) 2019 Eshref Yozdemir (University of Zurich) +% ● Description +% unittest class for the pspm_convert_au2unit function +% ● Authorship +% (C) 2019 Eshref Yozdemir (University of Zurich) +% Updated in 2026 by Bernhard von Raußendorf + +methods (Test) + +%% data mode +% [sts, converted_data] = pspm_convert_au2unit(data, unit, distance, record_method, +% multiplicator, reference_distance, reference_unit, options) +function testDiameterSameUnits(testCase) + [sts, out] = pspm_convert_au2unit(20, 'mm', 60, 'diameter', 0.1, 50, 'mm'); + testCase.verifyEqual(sts, 1); + testCase.verifyEqual(out, 2.4); end +function testDiameterUnitConversion(testCase) + [sts, out] = pspm_convert_au2unit(30, 'cm', 6, 'diameter', 0.2, 50, 'mm'); + testCase.verifyEqual(sts, 1); + testCase.verifyEqual(out, 0.72); +end +function testAreaSameUnits(testCase) + [sts, out] = pspm_convert_au2unit(100, 'mm', 60, 'area', 0.1, 50, 'mm'); + testCase.verifyEqual(sts, 1); + testCase.verifyEqual(out, 1.2); +end +function testAreaUnitConversion(testCase) + [sts, out] = pspm_convert_au2unit(400, 'mm', 100, 'area', 0.1, 100, 'm'); + testCase.verifyEqual(sts, 1); + testCase.verifyEqual(out, 2, 'AbsTol', 1e-12); +end +function testVectorAreaSameUnits(testCase) + [sts, out] = pspm_convert_au2unit([25 36 49], 'mm', 80, 'area', 0.05, 40, 'mm'); + testCase.verifyEqual(sts, 1); + testCase.verifyEqual(out, [0.5 0.6 0.7], 'AbsTol', 1e-12); +end +function testVectorAreaUnitConversion(testCase) + [sts,out]=pspm_convert_au2unit([100 400 900],'mm',100,'area',0.1,50,'m'); + testCase.verifyEqual(sts,1); + testCase.verifyEqual(out,[2 4 6],'AbsTol',1e-12); +end + +%% Error handeling +function testErrorHandling(testCase) + % invalid inputs + [sts,out] = pspm_convert_au2unit(); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + + [sts,out] = pspm_convert_au2unit(20); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + + [sts,out] = pspm_convert_au2unit(20,'mm'); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + + [sts,out] = pspm_convert_au2unit(20,'mm',60); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + % invalid unit inputs + [sts,out] = pspm_convert_au2unit(20,'mm',60,'wrong',0.1,50,'mm'); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + + [sts,out] = pspm_convert_au2unit(20,'mm','far','diameter',0.1,50,'mm'); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + + [sts,out] = pspm_convert_au2unit(20,'mm',60,'diameter','bad',50,'mm'); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); + + [sts,out] = pspm_convert_au2unit(20,'mm',60,'diameter',0.1,'bad','mm'); + testCase.verifyEqual(sts,-1); + testCase.verifyEmpty(out); +end + +%% Pspm files + + +function testFileRoundTripConvertAu2Unit(testCase) + + fn = '/home/bernd/git/PsPM/ImportTestData/eyelink/pspm_u_sc4b31.mat'; + fn_roundtrip = '/home/bernd/git/PsPM/ImportTestData/eyelink/pspm_u_sc4b31_au.mat'; + + % copy file + S = load(fn); + save(fn_roundtrip, '-struct', 'S'); + + unit = 'mm'; + distance = 600; + record_method = 'diameter'; + multiplicator = 0.04; + reference_distance = 500; + reference_unit = 'mm'; + + options = struct(); + options.channel = 'pupil'; + options.channel_action = 'replace'; + + %% 1) Original laden + [sts, infos, data] = pspm_load_data(fn); + testCase.verifyEqual(sts, 1); + + + %% 3) Originalkanal mit Einheiten laden + [sts, original_channel, ~, pos] = pspm_load_channel(fn, options.channel, 'pupil'); + testCase.verifyEqual(sts, 1); + + %% 4) Werte künstlich zurück in arbitrary units rechnen + au_data = unit2au(original_channel.data, unit, distance, record_method, ... + multiplicator, reference_distance, reference_unit); + + %% 5) AU-Kanal in die neue Datei schreiben + newdata = original_channel; + newdata.data = au_data; + newdata.header.units = 'au'; + + [sts, info_write] = pspm_write_channel( ... + fn_roundtrip, newdata, 'replace', struct('channel', pos)); + testCase.verifyEqual(sts, 1); + + %% 6) Neue Datei wieder mit convert_au2unit umrechnen + [sts, outchannel] = pspm_convert_au2unit( ... + fn_roundtrip, unit, distance, record_method, ... + multiplicator, reference_distance, reference_unit, ... + struct('channel', pos, 'channel_action', 'replace')); + testCase.verifyEqual(sts, 1); + + %% 7) Rekonvertierten Kanal laden + [sts, reconverted_channel] = pspm_load_channel(fn_roundtrip, outchannel, 'pupil'); + testCase.verifyEqual(sts, 1); + + %% 8) Vergleich + testCase.verifyEqual(reconverted_channel.data, original_channel.data, 'AbsTol', 1e-12); + testCase.verifyEqual(reconverted_channel.header.units, unit); + + %% optional cleanup + if exist(fn_roundtrip, 'file') + delete(fn_roundtrip); + end +end + + + + + + + + +end +end + +function data = unit2au(outchannel, unit, distance, record_method, ... + multiplicator, reference_distance, reference_unit) + + [~, outchannel_ref] = pspm_convert_unit(outchannel, unit, reference_unit); + [~, distance_ref] = pspm_convert_unit(distance, unit, reference_unit); + + switch lower(record_method) + case 'diameter' + data = outchannel_ref ./ ... + (multiplicator * (distance_ref / reference_distance)); + case 'area' + data = (outchannel_ref ./ ... + (multiplicator * (distance_ref / reference_distance))).^2; + otherwise + error('Invalid record_method'); + end +end + + + + From 2773414f8867d3218b61b92fdb2ae470b919e3d8 Mon Sep 17 00:00:00 2001 From: 4gwe Date: Sun, 29 Mar 2026 19:53:22 +0200 Subject: [PATCH 2/6] pspm_write_channel does no longer use units with pspm_select_channels and update to pspm_cfg_selector_channel_action helptext --- src/pspm_cfg/pspm_cfg_selector_channel_action.m | 2 +- src/pspm_write_channel.m | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pspm_cfg/pspm_cfg_selector_channel_action.m b/src/pspm_cfg/pspm_cfg_selector_channel_action.m index 1e3e71bba..e82e3ab2d 100644 --- a/src/pspm_cfg/pspm_cfg_selector_channel_action.m +++ b/src/pspm_cfg/pspm_cfg_selector_channel_action.m @@ -6,4 +6,4 @@ channel_action.values = {'add', 'replace'}; channel_action.labels = {'Add', 'Replace'}; channel_action.val = {'add'}; -channel_action.help = {'Choose whether to add a new channel, or to replace the last existing channel of the same type and with the same units (if any).'}; +channel_action.help = {'Choose whether to add a new channel, or to replace the processed channel.'}; diff --git a/src/pspm_write_channel.m b/src/pspm_write_channel.m index 2f3dbd7d0..b716b8963 100644 --- a/src/pspm_write_channel.m +++ b/src/pspm_write_channel.m @@ -111,7 +111,7 @@ for iChannel = 1:numel(newdata) warning off [sts, ~, pos_of_channels] = pspm_select_channels(data, ... - newdata{iChannel}.header.chantype, newdata{iChannel}.header.units); + newdata{iChannel}.header.chantype); warning on if sts < 1 channeli(iChannel) = 0; @@ -132,8 +132,7 @@ warning off sts = pspm_select_channels( ... data(options.channel(iChannel)), ... - newdata{iChannel}.header.chantype, ... - newdata{iChannel}.header.units); + newdata{iChannel}.header.chantype); warning on if sts < 1 channeli(iChannel) = 0; From f8476ec6433743971b47e3ac04d0990ba377f4e6 Mon Sep 17 00:00:00 2001 From: 4gwe Date: Wed, 1 Apr 2026 17:02:56 +0200 Subject: [PATCH 3/6] pspm_convert_au2unit uses now the pspm_convert_area2diameter and updated error handling, and updated pspm_convert_au2unit_test. --- src/pspm_convert_au2unit.m | 21 +++++++---- test/pspm_convert_au2unit_test.m | 63 +++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/src/pspm_convert_au2unit.m b/src/pspm_convert_au2unit.m index e15ebc25a..207c44042 100644 --- a/src/pspm_convert_au2unit.m +++ b/src/pspm_convert_au2unit.m @@ -11,7 +11,7 @@ % input data if the recording method is area. This is performed to always % return linear units. % Using the given variables, the following calculations are performed: -% 0. Take square root of data if recording is 'area'. +% 0. Take 2*sqrt(data/pi) of data if recording is 'area'. % 1. Let from unit to reference_unit converted recording distance be Dconv. % 2. x ← A*(Dconv/Dref)*x % 3. Convert x from ref_unit to unit. @@ -169,19 +169,26 @@ convert_data{i}.header = channeldata.header; convert_data{i}.header.units = unit; end - [f_sts, f_info] = pspm_write_channel(fn, convert_data, options.channel_action, struct('channel', pos_of_channel)); - if f_sts < 1, return; end + [sts, f_info] = pspm_write_channel(fn, convert_data, options.channel_action, struct('channel', pos_of_channel)); + if sts < 1, return; end outchannel = f_info.channel; % convert data case 'data' convert_data = data; if strcmpi(record_method, 'area') - convert_data = sqrt(convert_data); + [f_sts, convert_data] = pspm_convert_area2diameter(convert_data); + if f_sts < 1, return; end end - [~, distance] = pspm_convert_unit(distance, unit, reference_unit); + + [f_sts, distance] = pspm_convert_unit(distance, unit, reference_unit); + if f_sts < 1, return; end convert_data = multiplicator * (distance / reference_distance) * convert_data; + %% convert data from reference_unit to unit - [~, convert_data] = pspm_convert_unit(convert_data, reference_unit, unit); + [f_sts, convert_data] = pspm_convert_unit(convert_data, reference_unit, unit); + if f_sts < 1, return; end outchannel = convert_data; + sts = 1; end -sts = 1; + +end \ No newline at end of file diff --git a/test/pspm_convert_au2unit_test.m b/test/pspm_convert_au2unit_test.m index 079d5ccd3..45c5a6c92 100644 --- a/test/pspm_convert_au2unit_test.m +++ b/test/pspm_convert_au2unit_test.m @@ -21,24 +21,70 @@ function testDiameterUnitConversion(testCase) testCase.verifyEqual(out, 0.72); end function testAreaSameUnits(testCase) - [sts, out] = pspm_convert_au2unit(100, 'mm', 60, 'area', 0.1, 50, 'mm'); + data = 100; + [sts, out] = pspm_convert_au2unit(data, 'mm', 60, 'area', 0.1, 50, 'mm'); testCase.verifyEqual(sts, 1); - testCase.verifyEqual(out, 1.2); + + % expected with formula diameter = 2.*sqrt(area./pi); + expected_from_formula = 0.1 * (60 / 50) * 2*sqrt(data./pi); + testCase.verifyEqual(out, expected_from_formula); + + % expected with [sts, diameter] = pspm_convert_area2diameter(area) + [sts, diam] = pspm_convert_area2diameter(data); + expected_from_pspm = 0.1 * (60 / 50) * diam; + testCase.verifyEqual(out, expected_from_pspm); + end function testAreaUnitConversion(testCase) - [sts, out] = pspm_convert_au2unit(400, 'mm', 100, 'area', 0.1, 100, 'm'); + data = 400; + [sts, out] = pspm_convert_au2unit(data, 'mm', 100, 'area', 0.1, 100, 'm'); % reference_unit in m testCase.verifyEqual(sts, 1); - testCase.verifyEqual(out, 2, 'AbsTol', 1e-12); + + + % expected with formula diameter = 2.*sqrt(area./pi); + % ref. units in m: Dconv 100mm -> 0.1 m and A(Dconv/Dref) m -> mm (*1000) + expected_from_formula = 0.1 * (0.1 / 100) * 2 * sqrt(data ./ pi) * 1000; + testCase.verifyEqual(out, expected_from_formula); + + % expected with [sts, diameter] = pspm_convert_area2diameter(area) + [sts, diam] = pspm_convert_area2diameter(data); + expected_from_pspm = 0.1 * (0.1 / 100) * diam * 1000; + testCase.verifyEqual(out, expected_from_pspm); + + + end function testVectorAreaSameUnits(testCase) - [sts, out] = pspm_convert_au2unit([25 36 49], 'mm', 80, 'area', 0.05, 40, 'mm'); + data = [25 36 49] + [sts, out] = pspm_convert_au2unit(data, 'mm', 80, 'area', 0.05, 40, 'mm'); testCase.verifyEqual(sts, 1); - testCase.verifyEqual(out, [0.5 0.6 0.7], 'AbsTol', 1e-12); + + + % expected with formula diameter = 2.*sqrt(area./pi); + expected_from_formula = 0.05 * (80 / 40) * 2 * sqrt(data ./ pi) ; + testCase.verifyEqual(out, expected_from_formula); + + % expected with [sts, diameter] = pspm_convert_area2diameter(area) + [sts, diam] = pspm_convert_area2diameter(data); + expected_from_pspm = 0.05 * (80 / 40) * diam ; + testCase.verifyEqual(out, expected_from_pspm); + end function testVectorAreaUnitConversion(testCase) - [sts,out]=pspm_convert_au2unit([100 400 900],'mm',100,'area',0.1,50,'m'); + data = [100 400 900]; + [sts,out]=pspm_convert_au2unit(data,'mm',100,'area',0.1,50,'m'); testCase.verifyEqual(sts,1); - testCase.verifyEqual(out,[2 4 6],'AbsTol',1e-12); + + % expected with formula diameter = 2.*sqrt(area./pi); + expected_from_formula = 0.1 * (0.1 / 50) * 2 * sqrt(data ./ pi) * 1000 ; + testCase.verifyEqual(out, expected_from_formula); + + % expected with [sts, diameter] = pspm_convert_area2diameter(area) + [sts, diam] = pspm_convert_area2diameter(data); + expected_from_pspm = 0.1 * (0.1 / 50) * diam * 1000; + testCase.verifyEqual(out, expected_from_pspm); + + end %% Error handeling @@ -79,7 +125,6 @@ function testErrorHandling(testCase) %% Pspm files - function testFileRoundTripConvertAu2Unit(testCase) fn = '/home/bernd/git/PsPM/ImportTestData/eyelink/pspm_u_sc4b31.mat'; From 867e3248b385d07798dd018b8d1c787e6a15becf Mon Sep 17 00:00:00 2001 From: 4gwe Date: Wed, 1 Apr 2026 17:17:12 +0200 Subject: [PATCH 4/6] updated pspm_convert_gaze_test to the new pspm_write_channels new way to call pspm_select_channels --- test/pspm_convert_gaze_test.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pspm_convert_gaze_test.m b/test/pspm_convert_gaze_test.m index c839b1275..bb934957d 100644 --- a/test/pspm_convert_gaze_test.m +++ b/test/pspm_convert_gaze_test.m @@ -98,7 +98,7 @@ function conversion(this, target, from, channel_action) this.verifyTrue(~isempty(out_channel)); if strcmpi(target, 'sps') extra = 1; - elseif strcmpi(channel_action, 'add') || ~strcmpi(target, from) + elseif strcmpi(channel_action, 'add') %|| ~strcmpi(target, from) extra = 2; else extra = 0; From fc654e60709aaef2b77e7d1cf5d560a03618711c Mon Sep 17 00:00:00 2001 From: 4gwe Date: Thu, 2 Apr 2026 11:19:31 +0200 Subject: [PATCH 5/6] updated pspm_write_channel_test to the new pspm_write_channels new way to call pspm_select_channels --- test/pspm_write_channel_test.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/pspm_write_channel_test.m b/test/pspm_write_channel_test.m index dcafb9099..1931e3c7f 100644 --- a/test/pspm_write_channel_test.m +++ b/test/pspm_write_channel_test.m @@ -197,11 +197,11 @@ function test_replace_units(this) gen_data.data{1}.header.units = 'degree'; [~, ~] = this.verifyWarningFree(@() pspm_write_channel(this.testdatafile, gen_data.data{1}, 'replace')); [~, post_unit_change.infos, post_unit_change.data] = pspm_load_data(this.testdatafile); - % should be one more channel as degrees did not exist - this.verifyEqual(length(post_unit_change.data), length(new.data) + 1); + % should be the same nr. of channels + this.verifyEqual(length(post_unit_change.data), length(new.data)); % assert one mm gaze channel and one degree gaze channel - this.verifyEqual(length(find(cellfun(@(c) strcmp(c.header.units, 'mm') && ... - strcmp(c.header.chantype, 'gaze_x_l'), post_unit_change.data))), 1); + % this.verifyEqual(length(find(cellfun(@(c) strcmp(c.header.units, 'mm') && ... + % strcmp(c.header.chantype, 'gaze_x_l'), post_unit_change.data))), 1); this.verifyEqual(length(find(cellfun(@(c) strcmp(c.header.units, 'degree') && ... strcmp(c.header.chantype, 'gaze_x_l'), post_unit_change.data))), 1); end From c3cb9d8274a93f60923230839968b394a6a017d0 Mon Sep 17 00:00:00 2001 From: 4gwe Date: Thu, 2 Apr 2026 12:48:05 +0200 Subject: [PATCH 6/6] small updates to test/pspm_convert_au2unit_test.m --- test/pspm_convert_au2unit_test.m | 61 ++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/test/pspm_convert_au2unit_test.m b/test/pspm_convert_au2unit_test.m index 45c5a6c92..2fb4c0551 100644 --- a/test/pspm_convert_au2unit_test.m +++ b/test/pspm_convert_au2unit_test.m @@ -83,7 +83,25 @@ function testVectorAreaUnitConversion(testCase) [sts, diam] = pspm_convert_area2diameter(data); expected_from_pspm = 0.1 * (0.1 / 50) * diam * 1000; testCase.verifyEqual(out, expected_from_pspm); +end +function testVectorAreaUnitConversionTEST(testCase) + data = [100 400 900]; + [sts,out]=pspm_convert_au2unit(data,'mm',100,'area',0.1,50,'mm'); + testCase.verifyEqual(sts,1); + % + % % expected with formula diameter = 2.*sqrt(area./pi); + % expected_from_formula = 0.1 * (0.1 / 50) * 2 * sqrt(data ./ pi) * 1000 ; + % testCase.verifyEqual(out, expected_from_formula); + % + % % expected with [sts, diameter] = pspm_convert_area2diameter(area) + % [sts, diam] = pspm_convert_area2diameter(data); + % expected_from_pspm = 0.1 * (0.1 / 50) * diam * 1000; + % testCase.verifyEqual(out, expected_from_pspm); + + data2 = unit2au(out,'mm',100,'area',0.1,50,'mm'); + testCase.verifyEqual(data , data2, 'AbsTol', 1e-12); + end @@ -124,9 +142,7 @@ function testErrorHandling(testCase) end %% Pspm files - function testFileRoundTripConvertAu2Unit(testCase) - fn = '/home/bernd/git/PsPM/ImportTestData/eyelink/pspm_u_sc4b31.mat'; fn_roundtrip = '/home/bernd/git/PsPM/ImportTestData/eyelink/pspm_u_sc4b31_au.mat'; @@ -145,72 +161,65 @@ function testFileRoundTripConvertAu2Unit(testCase) options.channel = 'pupil'; options.channel_action = 'replace'; - %% 1) Original laden + %% 1) load original file [sts, infos, data] = pspm_load_data(fn); testCase.verifyEqual(sts, 1); - - %% 3) Originalkanal mit Einheiten laden + %% 2) load pupil channel [sts, original_channel, ~, pos] = pspm_load_channel(fn, options.channel, 'pupil'); testCase.verifyEqual(sts, 1); - %% 4) Werte künstlich zurück in arbitrary units rechnen + %% 3) change units to au au_data = unit2au(original_channel.data, unit, distance, record_method, ... multiplicator, reference_distance, reference_unit); - %% 5) AU-Kanal in die neue Datei schreiben newdata = original_channel; newdata.data = au_data; newdata.header.units = 'au'; - [sts, info_write] = pspm_write_channel( ... - fn_roundtrip, newdata, 'replace', struct('channel', pos)); + [sts, info_write] = pspm_write_channel(fn_roundtrip, newdata, 'replace', struct('channel', pos)); testCase.verifyEqual(sts, 1); - %% 6) Neue Datei wieder mit convert_au2unit umrechnen + %% 4) convert back to units [sts, outchannel] = pspm_convert_au2unit( ... fn_roundtrip, unit, distance, record_method, ... multiplicator, reference_distance, reference_unit, ... struct('channel', pos, 'channel_action', 'replace')); testCase.verifyEqual(sts, 1); - %% 7) Rekonvertierten Kanal laden + %% 5) load converted channel [sts, reconverted_channel] = pspm_load_channel(fn_roundtrip, outchannel, 'pupil'); testCase.verifyEqual(sts, 1); - %% 8) Vergleich + %% 8) Test testCase.verifyEqual(reconverted_channel.data, original_channel.data, 'AbsTol', 1e-12); testCase.verifyEqual(reconverted_channel.header.units, unit); - %% optional cleanup + %% cleanup if exist(fn_roundtrip, 'file') delete(fn_roundtrip); end end - - - - - - - end end function data = unit2au(outchannel, unit, distance, record_method, ... multiplicator, reference_distance, reference_unit) - [~, outchannel_ref] = pspm_convert_unit(outchannel, unit, reference_unit); - [~, distance_ref] = pspm_convert_unit(distance, unit, reference_unit); + % [~, outchannel_ref] = pspm_convert_unit(outchannel, unit, reference_unit); + % [~, distance_conv] = pspm_convert_unit(distance, unit, reference_unit); switch lower(record_method) case 'diameter' - data = outchannel_ref ./ ... - (multiplicator * (distance_ref / reference_distance)); + data = outchannel ./ ... + (multiplicator * (distance / reference_distance )); case 'area' - data = (outchannel_ref ./ ... - (multiplicator * (distance_ref / reference_distance))).^2; + + data = (outchannel ./ ... + (multiplicator * ( distance/ reference_distance))); + data = ((data./2).^2 ).*pi; + otherwise error('Invalid record_method'); end