Skip to content

Commit 578f601

Browse files
committed
added subplot with plv
1 parent bfe4d22 commit 578f601

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

PNAS_response2Rajendran/meterFreqNoise_simulateExp.m

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,13 @@
378378

379379

380380

381-
%% PLOT ZSCORES IN ONE EXPERIMENT
381+
%% PLOT ZSCORES AND PHASE-LOCKING IN ONE EXPERIMENT
382382

383383
freq_jitter_sd2plot = 0.3;
384384

385385
% allocate variables for the current experiment
386386
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
388388

389389
for partici=1:n_partic
390390

@@ -430,11 +430,34 @@
430430
response(partici,triali,1,:) = resp_standard;
431431
response(partici,triali,2,:) = resp_jittered;
432432

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+
433456
end
434457

435458
end
436459

437-
% calculate meter zscores and do the ttest
460+
% calculate meter zscores
438461
time_avg = squeeze(mean(response,2));
439462

440463
frex_idx = round(frex*N/fs)+1;
@@ -448,20 +471,32 @@
448471
z_meterRel_s = mean(z(:,1,idx_meterRel),3);
449472
z_meterRel_s_jittered = mean(z(:,2,idx_meterRel),3);
450473

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)
458474

459475

460476

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+
461482

462483

463484

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)
464493

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)
465500

466501

467502

0 commit comments

Comments
 (0)