Skip to content

Commit

Permalink
Merge pull request #70 from MaxvandenBoom/master
Browse files Browse the repository at this point in the history
Supplement Fig 3 y-axis now in ms, updates some script names and output folder; corrected p-values outputted for fig 6-7
  • Loading branch information
dorahermes authored Feb 3, 2023
2 parents 3e87b97 + 54d92ec commit faf1dff
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 190 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Scripts to process the data, detect N1 responses and add tract information:
- scripts/ccep04_averageConnections.m

Scripts to make the figure panels:
- makeFig1A_plotMNI.m
- makeFig1A_and_SupFig9_plotMNI.m
- makeFig1B_subjectResponses.m
- makeFig1C_heatmapResponsesAge.m
- makeFig2and3_transmissionAcrossAge.m
- makeFig1C_and_Fig3A_heatmaps.m
- makeFig2_and_Fig3BC_transmissionAges.m


To make all functions work, an m-file called personalDataPath.m should be stored in the root dir. This file should have the following content:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%
% This script creates the images for Figure 1A that depict a MNI surface with tracts, subtracts, ROIs and electrodes
% This script produces the images for:
% - Figure 1A - that depict a MNI surface with tracts, subtracts, ROIs and electrodes
% - Supplemental Figure 9 - distribution of electrodes over different age groups
%
% Max van den Boom, Jaap van der Aar, Giulio Castegnaro, Dora Hermes, Dorien van Blooijs, 2022
%
Expand Down Expand Up @@ -275,7 +277,10 @@
ieeg_viewLight(v_d(1), v_d(2))

% save the image
figureName = fullfile(myDataPath.output, 'derivatives', 'render', ['leftMNIpial_', rois(iTr).tract_name, '_', strrep(rois(iTr).sub_tract(iSubTr).name, '-', ''), '.png']);
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', ['leftMNIpial_', rois(iTr).tract_name, '_', strrep(rois(iTr).sub_tract(iSubTr).name, '-', ''), '.png']);
set(gcf, 'PaperPositionMode', 'auto')
set(hFig, 'Visible', 'on');
print('-dpng', '-r300', figureName)
Expand Down Expand Up @@ -408,7 +413,11 @@
figure(hFigElec);
set(hFigElec, 'renderer', 'Painters')
set(hFigElec, 'PaperPositionMode', 'auto')
figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS9_ElecCoverage');

if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS9_ElecCoverage');
print('-dpng', '-r300', figureName)
print('-depsc', '-r300', figureName)
%close(hFigElec)
6 changes: 3 additions & 3 deletions scripts/makeFig1B_subjectResponses.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
%
% save
%
if ~exist(fullfile(myDataPath.output,'derivatives', 'age'), 'dir')
mkdir(fullfile(myDataPath.output,'derivatives', 'age'));
if ~exist(fullfile(myDataPath.output,'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output,'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output,'derivatives', 'age', ['CCEPexamples_6subjects', '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);
figureName = fullfile(myDataPath.output,'derivatives', 'images', ['CCEPexamples_6subjects', '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);

set(gcf, 'renderer', 'Painters')
set(gcf, 'PaperPositionMode', 'auto')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
%
% save
%
if ~exist(fullfile(myDataPath.output,'derivatives', 'age'), 'dir')
mkdir(fullfile(myDataPath.output,'derivatives', 'age'));
if ~exist(fullfile(myDataPath.output,'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output,'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output,'derivatives', 'age', ['sortedAge_tmax' int2str(ttmax * 1000), '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);
figureName = fullfile(myDataPath.output,'derivatives', 'images', ['sortedAge_tmax' int2str(ttmax * 1000), '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);

set(gcf, 'PaperPositionMode', 'auto')
print('-dpng', '-r300', figureName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@
set(gca, 'YGrid', 'on', 'XGrid', 'off');

% save latency figure
if ~exist(fullfile(myDataPath.output, 'derivatives', 'age'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'age'));
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'age', ['ageVsLatency', '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);
figureName = fullfile(myDataPath.output, 'derivatives', 'images', ['ageVsLatency', '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);
set(gcf,'PaperPositionMode', 'auto');
print('-dpng', '-r300', figureName);
print('-depsc', '-r300', figureName);
Expand Down Expand Up @@ -432,7 +432,10 @@
set(gca, 'YGrid', 'on', 'XGrid', 'off');

% save speed figure
figureName = fullfile(myDataPath.output, 'derivatives', 'age', ['ageVsSpeed', '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', ['ageVsSpeed', '_', rois(iTr).tract_name, '_', strrep(strSubTitle, ' -> ', '_')]);
set(gcf,'PaperPositionMode', 'auto');
print('-dpng', '-r300', figureName);
print('-depsc', '-r300', figureName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@
legend()

% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'age'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'age'));
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end

figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS1_corrAgeVslatency_8mA');
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS1_corrAgeVslatency_8mA');
set(gcf, 'PaperPositionMode', 'auto')
print('-dpng', '-r300', figureName)
print('-depsc', '-r300', figureName)
Expand Down
41 changes: 28 additions & 13 deletions scripts/makeSupFig2to5_responses.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
out{iRow, iCol}.subjectsN1Values = subjectsN1Values;

% calculate and store the r and p for the age vs variance in latency
[varlat_r, varlat_p] = corr(subjectsN1Values(~isnan(subjectsN1Values(:, 1)) & ~isnan(subjectsN1Values(:, 3)), 1), ...
subjectsN1Values(~isnan(subjectsN1Values(:, 1)) & ~isnan(subjectsN1Values(:, 3)), 3), 'Type', 'Spearman');
[varlat_r, varlat_p] = corr(subjectsN1Values(~isnan(subjectsN1Values(:, 1)) & ~isnan(subjectsN1Values(:, 4)), 1), ...
subjectsN1Values(~isnan(subjectsN1Values(:, 1)) & ~isnan(subjectsN1Values(:, 4)), 4), 'Type', 'Spearman');
out{iRow, iCol}.varlat_r = varlat_r;
out{iRow, iCol}.varlat_p = varlat_p;
all_varlat_p(end + 1, :) = [iRow, iCol, varlat_p];
Expand Down Expand Up @@ -178,15 +178,17 @@
end
end


figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS2_AgeVsRatioN1s');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS2_AgeVsRatioN1s');
set(gcf,'PaperPositionMode', 'auto')
print('-dpng', '-r300', figureName)
print('-depsc', '-r300', figureName)




%%
% Generate supplementary figure 3 that displays the variance in latencies for each of the connections between the end-point areas

Expand All @@ -198,27 +200,31 @@

% age vs variance latencies
subplot(size(conn_matrix, 1), size(conn_matrix, 2), outInd); hold on;
plot(subjectsN1Values(:, 1), 1000 * subjectsN1Values(:, 3), 'k.', 'MarkerSize', 10);
plot(subjectsN1Values(:, 1), subjectsN1Values(:, 4), 'k.', 'MarkerSize', 10);

% determine the number of samples
n = sum(~isnan(subjectsN1Values(:, 3)));

%
title(strrep(out{iRow, iCol}.name, '_', '\_'));
xlim([0 60]); ylim([0 1]);
xlim([0 60]);
ylim([0 (max(subjectsN1Values(:, 4)))])
if iRow == size(conn_matrix, 1), xlabel('Age (years)'); end
if iCol == 1, ylabel('Varience in N1 latency (ms)'); end

%
text(40, 0.9, ['\rho=', num2str(round(out{iRow, iCol}.varlat_r, 2)), ' (n=', num2str(n, 2), ')']);
text(40, 0.8, ['P_f_d_r=', num2str(round(out{iRow, iCol}.varlat_p_fdr, 2))]);
text(40, max(subjectsN1Values(:, 4)) * .9, ['\rho=', num2str(round(out{iRow, iCol}.varlat_r, 2)), ' (n=', num2str(n, 2), ')']);
text(40, max(subjectsN1Values(:, 4)) * .8, ['P_f_d_r=', num2str(round(out{iRow, iCol}.varlat_p_fdr, 2))]);

hold off;
end
end


figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS3_AgeVsLatVar_N1');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS3_AgeVsLatVar_N1');
set(gcf,'PaperPositionMode', 'auto')
print('-dpng', '-r300', figureName)
print('-depsc', '-r300', figureName)
Expand Down Expand Up @@ -273,7 +279,11 @@
end
set(gca, 'XTick', 20:20:100)

figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS4_MeanVsVariance_N1');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS4_MeanVsVariance_N1');
set(gcf,'PaperPositionMode', 'auto');
print('-dpng', '-r300', figureName);
print('-depsc', '-r300', figureName);
Expand Down Expand Up @@ -328,12 +338,17 @@
end
end

figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS5_MeanVsFWHM');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS5_MeanVsFWHM');
set(gcf,'PaperPositionMode', 'auto');
print('-dpng', '-r300', figureName);
print('-depsc', '-r300', figureName);



%
%
%
Expand Down
16 changes: 14 additions & 2 deletions scripts/makeSupFig6and7_exploreSOZ.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
[~, ~, ~, p_vals_resp_FDR] = fdr_bh([n1Latencies(p_indices_resp).respSOZ_p], 0.05, 'pdep');
[~, ~, ~, p_vals_stim_FDR] = fdr_bh([n1Latencies(p_indices_stim).stimSOZ_p], 0.05, 'pdep');

% print the FDR correct p-values
disp(['Response SOZvsNon-SOZ corrected p-values: ', char(strjoin(string(p_vals_resp_FDR), ', '))]);
disp(['Stim SOZvsNon-SOZ corrected p-values: ', char(strjoin(string(p_vals_stim_FDR), ', '))]);

% put FDR p-values back into the table
for respIdx = 1:length(p_indices_resp)
n1Latencies(p_indices_resp(respIdx)).respSOZ_pFDR = p_vals_resp_FDR(respIdx);
Expand Down Expand Up @@ -339,7 +343,11 @@
lgd.FontSize = 20;
set(gcf,'color', 'w');

figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS6_LatencyRespSOZ');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS6_LatencyRespSOZ');
set(gcf, 'renderer', 'Painters')
set(gcf,'PaperPositionMode', 'auto')
print('-dpng', '-r300', figureName)
Expand Down Expand Up @@ -424,7 +432,11 @@
lgd.FontSize = 20;
set(gcf,'color', 'w');

figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS7_LatencyStimSOZ');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS7_LatencyStimSOZ');
set(gcf, 'renderer', 'Painters')
set(gcf, 'PaperPositionMode', 'auto')
print('-dpng', '-r300', figureName)
Expand Down
8 changes: 5 additions & 3 deletions scripts/makeSupFig8_volumeConduction.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@
xlabel('Standard deviation (ms)')
ylabel('Number of stimulation pairs')

figureName = fullfile(myDataPath.output, 'derivatives', 'age', 'SupFigS8_volumeConductionCheck');
% save
if ~exist(fullfile(myDataPath.output, 'derivatives', 'images'), 'dir')
mkdir(fullfile(myDataPath.output, 'derivatives', 'images'));
end
figureName = fullfile(myDataPath.output, 'derivatives', 'images', 'SupFigS8_volumeConductionCheck');
set(gcf, 'PaperPositionMode', 'auto')
print('-dpng', '-r300', '-painters', figureName)
print('-depsc2', '-r300', '-painters', figureName)



Loading

0 comments on commit faf1dff

Please sign in to comment.