From 19ffbbf503d66295f6cf17d70affa6f130b03c86 Mon Sep 17 00:00:00 2001 From: 4gwe Date: Thu, 13 Aug 2026 14:52:07 +0200 Subject: [PATCH] Support segmented AcqKnowledge imports --- src/pspm_get_acqmat.m | 15 ++++++++++----- test/pspm_get_acqmat_test.m | 32 +++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/pspm_get_acqmat.m b/src/pspm_get_acqmat.m index 63736337b..1947ed344 100644 --- a/src/pspm_get_acqmat.m +++ b/src/pspm_get_acqmat.m @@ -29,12 +29,21 @@ pspm_init; end sts = -1; -sourceinfo = []; +sourceinfo = struct(); % load data % ------------------------------------------------------------------------- inputdata = load(datafile); +% store original recording offset +sourceinfo.start_sample = inputdata.start_sample; +sourceinfo.start_sample_unit = inputdata.isi_units; + +if inputdata.start_sample ~= 0 + warning('ID:acqmat_nonzero_start', ... + 'AcqKnowledge data starts at %g %s relative to the original recording.', ... + inputdata.start_sample, strtrim(inputdata.isi_units)); +end % extract individual channels % ------------------------------------------------------------------------- @@ -60,10 +69,6 @@ warning('\nUnsupported modality - please notify the developers.\n'); return; end - if inputdata.start_sample ~= 0 - warning('\nUnsupported sampling scheme - please notify the developers.\n'); return; - end - % get data & data units import{k}.data = double(inputdata.data(:, channel)); import{k}.units = inputdata.units(channel,:); diff --git a/test/pspm_get_acqmat_test.m b/test/pspm_get_acqmat_test.m index e8d4862d4..c139a8c2a 100644 --- a/test/pspm_get_acqmat_test.m +++ b/test/pspm_get_acqmat_test.m @@ -28,5 +28,35 @@ function invalid_datafile(this) import = this.assign_chantype_number(import); this.verifyWarning(@()pspm_get_acqmat(fn, import), 'ID:channel_not_contained_in_file'); end + function nonzero_start_sample(this) + + inputdata = load('ImportTestData/acq/Acq_exported_SCR_Marker.mat'); + + % Simulate AcqKnowledge export starting later in original recording + first_sample = 1001; + last_sample = min(2000, size(inputdata.data, 1)); + + inputdata.data = inputdata.data(first_sample:last_sample, :); + inputdata.start_sample = inputdata.start_sample + ... + (first_sample - 1) * inputdata.isi; + + fn = [tempname '.mat']; + save(fn, '-struct', 'inputdata'); + cleaner = onCleanup(@() delete(fn)); + + import{1} = struct('type', 'scr', 'channel', 1); + import{2} = struct('type', 'marker', 'channel', 2); + import = this.assign_chantype_number(import); + + [sts, output, sourceinfo] = this.verifyWarning( ... + @() pspm_get_acqmat(fn, import), ... + 'ID:acqmat_nonzero_start'); + + this.verifyEqual(sts, 1); + this.verifyEqual(sourceinfo.start_sample, inputdata.start_sample); + this.verifyEqual(sourceinfo.start_sample_unit, inputdata.isi_units); + this.verifyEqual(output{1}.data, double(inputdata.data(:, 1))); + + end end -end \ No newline at end of file +end