bachlab / PsPM

A matlab suite for Psycho-Physiological Modelling
GNU General Public License v3.0
43 stars 10 forks source link

Split_session generates unexpected trials #198

Closed teddychao closed 3 years ago

teddychao commented 3 years ago

Summary

_pspm_splitsession generates unexpected trials during preparing for the DCM of the SCR data.

Steps to Reproduce

  1. Reproduce the sample data.
  2. Check the number temporal trials.

Expected Results

_pspm_splitsession generates the same number of trials as expected.

Actual Results

_pspm_splitsession generates additional trials (could be more than one additional trial).

Technical Info

teddychao commented 3 years ago

This bug should be resolved prior to implementing trim to split_sessions. However, this bug must be re-tested after that implementation.

dominikbach commented 3 years ago

This is the REASON for the bug:

After detecting the last marker in a trial (variable sto) around line 189, the mean interval (weirdly called "space") between markers in the session is added to the timing of that marker, to define the stop point of the session. THIS IS WRONG for two reasons: (a) The user may already have defined options.suffix>0, which will be added further down. (b) More importantly: this does not account for markers (beginning of next session) that occur within that interval, whereas the implementation of options.suffix does this. The SOLUTION for both issues is to replace the value of options.suffix with the value of "mean_space" if options.suffix == 0 and do nothing otherwise.

Suggested IMPLEMENTATION: (1) replace lines 196-203 with: stop_time = mrk(sto); (2) add after this: if options.suffix == 0 if sta == sto || options.randomITI suffix(s) = mean(diff(mrk)); else suffix(s) = mean(diff(mrk(sta:sto))); end else suffix(s) = options.suffix; end

(3) replace lines 229-235 with if (splitpoint(sn,2) + options.suffix) > ininfos.duration sto_p = ininfos.duration; suffix(sn) = ininfos.duration - splitpoint(sn,2); else sto_p = splitpoint(sn,2) + suffix(sn); end

(4) from here to end, find "sto_suffix" & replace with "suffix(sn)"