|
378 | 378 |
|
379 | 379 |
|
380 | 380 |
|
381 | | -%% PLOT ZSCORES IN ONE EXPERIMENT |
| 381 | +%% PLOT ZSCORES AND PHASE-LOCKING IN ONE EXPERIMENT |
382 | 382 |
|
383 | 383 | freq_jitter_sd2plot = 0.3; |
384 | 384 |
|
385 | 385 | % allocate variables for the current experiment |
386 | 386 | response = zeros(n_partic, n_trials, 2, N); % simulated responses in the time domain |
387 | | - |
| 387 | +phase_locking = zeros(n_partic, n_trials, 2, length(frex)); % phase-locking between stimulus and response for each participant, condition and trial |
388 | 388 |
|
389 | 389 | for partici=1:n_partic |
390 | 390 |
|
|
430 | 430 | response(partici,triali,1,:) = resp_standard; |
431 | 431 | response(partici,triali,2,:) = resp_jittered; |
432 | 432 |
|
| 433 | + |
| 434 | + % calculate stimulus-response phase locking for this trial |
| 435 | + aX_resp_standard_slidingWin = zeros(fft_n_win, length(frex)); |
| 436 | + for wini=1:fft_n_win |
| 437 | + idx = (wini-1)*round(fft_win_dur*fft_win_overlap*fs); |
| 438 | + x = resp_standard(idx+1:idx+round(fft_win_dur*fs)); |
| 439 | + aX = angle(fft(x)); |
| 440 | + aX_resp_standard_slidingWin(wini,:) = aX(fft_win_frex_idx); |
| 441 | + end |
| 442 | + aX_resp_jittered_slidingWin = zeros(fft_n_win, length(frex)); |
| 443 | + for wini=1:fft_n_win |
| 444 | + idx = (wini-1)*round(fft_win_dur*fft_win_overlap*fs); |
| 445 | + x = resp_jittered(idx+1:idx+round(fft_win_dur*fs)); |
| 446 | + aX = angle(fft(x)); |
| 447 | + aX_resp_jittered_slidingWin(wini,:) = aX(fft_win_frex_idx); |
| 448 | + end |
| 449 | + plv_standard = abs(mean(exp(1i*(aX_resp_standard_slidingWin-aX_stim_slidingWin)),1)); |
| 450 | + plv_jittered = abs(mean(exp(1i*(aX_resp_jittered_slidingWin-aX_stim_slidingWin)),1)); |
| 451 | + |
| 452 | + phase_locking(partici,triali,1,:) = plv_standard; |
| 453 | + phase_locking(partici,triali,2,:) = plv_jittered; |
| 454 | + |
| 455 | + |
433 | 456 | end |
434 | 457 |
|
435 | 458 | end |
436 | 459 |
|
437 | | -% calculate meter zscores and do the ttest |
| 460 | +% calculate meter zscores |
438 | 461 | time_avg = squeeze(mean(response,2)); |
439 | 462 |
|
440 | 463 | frex_idx = round(frex*N/fs)+1; |
|
448 | 471 | z_meterRel_s = mean(z(:,1,idx_meterRel),3); |
449 | 472 | z_meterRel_s_jittered = mean(z(:,2,idx_meterRel),3); |
450 | 473 |
|
451 | | -figure('color','white','position',[1069 579 326 290]); |
452 | | -h = axes; |
453 | | -plot([0,1],[z_meterRel_s, z_meterRel_s_jittered], 'r-o', 'MarkerFaceColor', 'red'); |
454 | | -box off |
455 | | -ylabel('meter z-score') |
456 | | -set(gca, 'xlim', [-0.2,1.2], 'XTick', [0,1], 'XTickLabel', {'standard','jittered'}, 'FontSize', 18, ... |
457 | | - 'YTick', h.YLim) |
458 | 474 |
|
459 | 475 |
|
460 | 476 |
|
| 477 | +% calculate phase-locking values |
| 478 | +phase_locking_mean = mean(phase_locking(:,:,:,:),2); % mean over trials |
| 479 | +phase_locking_beat = squeeze(phase_locking_mean(:,:,1,3)); % only the beat frequency |
| 480 | +phase_locking_beat_jittered = squeeze(phase_locking_mean(:,:,2,3)); % only the beat frequency |
| 481 | + |
461 | 482 |
|
462 | 483 |
|
463 | 484 |
|
| 485 | +% PLOT |
| 486 | +figure('color','white','position', [1069 579 235 371]); |
| 487 | +h = subplot(211); |
| 488 | +plot([0,1],[phase_locking_beat, phase_locking_beat_jittered], 'r-o', 'MarkerFaceColor', 'red'); |
| 489 | +box off |
| 490 | +ylabel('phase-locking value') |
| 491 | +set(gca, 'xlim', [-0.2,1.2], 'XTick', [0,1], 'XTickLabel', {}, 'FontSize', 18, ... |
| 492 | + 'YTick', h.YLim) |
464 | 493 |
|
| 494 | +h = subplot(212); |
| 495 | +plot([0,1],[z_meterRel_s, z_meterRel_s_jittered], 'r-o', 'MarkerFaceColor', 'red'); |
| 496 | +box off |
| 497 | +ylabel('meter z-score') |
| 498 | +set(gca, 'xlim', [-0.2,1.2], 'XTick', [0,1], 'XTickLabel', {'standard','jittered'}, 'FontSize', 18, ... |
| 499 | + 'YTick', h.YLim) |
465 | 500 |
|
466 | 501 |
|
467 | 502 |
|
|
0 commit comments