Demo_FindRelDevStd.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. %% create artificial datasets and sequences
  2. data_dev = [10,3,3,1;1,3,1,3;3,3,3,3]';
  3. data_std = [2,11,2,2,4,2,4,2;2,2,4,2,4,2,2,2;2,4,2,2,4,4,4,2]';
  4. n_files = size(data_dev,2);
  5. n_dev = size(data_dev,1);
  6. n_std = size(data_std,1);
  7. n_stims = n_dev+n_std;
  8. seq = [1,1,0,1,1,1,0,1,1,0,0,1;0,1,1,1,0,0,1,1,0,1,1,1;1,1,0,1,1,1,0,1,0,1,0,1]';
  9. seqStd = logical(seq);
  10. seqDev = ~seq;
  11. %% shift dev and std sequence by one point and index into it with original std and dev sequence to obtain stds before devs and devs after stds
  12. seqStd_bd = logical([seqDev(2:n_stims,:);zeros(1,n_files)]); % shift original dev sequences by 1 point (forwards)
  13. seqStd_bd = reshape(seqStd_bd(seqStd),n_std,n_files); % index into shifted deviant sequences with original std sequences to obtain stds before devs
  14. seqDev_as = logical([zeros(1,n_files);seqStd(1:n_stims-1,:)]); % shift original std sequences by 1 point (backwards)
  15. seqDev_as = reshape(seqDev_as(seqDev),n_dev,n_files); % index into shifted standard sequences with original dev sequences to obtain dev after stds
  16. %% apply newly generated sequences on dev and std datasets
  17. sample_std = cell(1,n_files);
  18. sample_dev = cell(1,n_files);
  19. for j = 1:n_files
  20. sample_std{1,j} = data_std(seqStd_bd(:,j),j);
  21. sample_dev{1,j} = data_dev(seqDev_as(:,j),j);
  22. end
  23. %% same approach with only one std/dev dataset
  24. data_dev = [10,3,3,1];
  25. data_std = [2,11,2,2,4,2,4,2];
  26. seq = [1,1,0,1,1,1,0,1,1,0,0,1];
  27. seq_std = logical(seq);
  28. seq_dev = ~seq;
  29. seq_std_bd_temp = logical([seq_dev(2:end),zeros(1,1)]);
  30. seqStd_bd = seq_std_bd_temp(seq_std);
  31. seq_dev_as_temp = logical([zeros(1,1),seq_std(1:end-1)]);
  32. seqDev_as = seq_dev_as_temp(seq_dev);
  33. sample_std = data_std(seqStd_bd)
  34. sample_dev = data_dev(seqDev_as)
  35. bla = 1;