Skip to content

Commit

Permalink
Merge pull request #69 from MaxvandenBoom/master
Browse files Browse the repository at this point in the history
Multiple updates and fixes to prepare for publication
  • Loading branch information
dorahermes authored Jan 28, 2023
2 parents a5c2d1e + bbe951a commit 3e87b97
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 765 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Scripts to process the data, detect N1 responses and add tract information:

Scripts to make the figure panels:
- makeFig1A_plotMNI.m
- makeFig1BandC_plotResponsesAge.m
- makeFig1B_subjectResponses.m
- makeFig1C_heatmapResponsesAge.m
- makeFig2and3_transmissionAcrossAge.m


Expand Down
2 changes: 1 addition & 1 deletion external/Violinplot-Matlab/Violin.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
hiwhisker = quartiles(3) + 1.5*IQR;
hiwhisker = min(hiwhisker, max(data(data < hiwhisker)));
if ~isempty(lowhisker) && ~isempty(hiwhisker)
obj.WhiskerPlot = plot([pos pos], [lowhisker hiwhisker]);
obj.WhiskerPlot = plot([pos pos], [lowhisker hiwhisker], 'LineWidth', 1.2);
end
obj.MedianPlot = scatter(pos, quartiles(2), [], [1 1 1], 'filled');

Expand Down
3 changes: 0 additions & 3 deletions functions/read_tsv.m

This file was deleted.

379 changes: 0 additions & 379 deletions scripts/ccepExtra01_plotN1.m

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%
%
% This code is used to create Figure 1C - the normalized CCEPs of all patients in order of age,
% This code is used to the plot for Figure 1C and Figure 3A - the normalized CCEPs of all patients in order of age,
%
%

Expand Down Expand Up @@ -71,7 +71,7 @@


%%
% Figure 1C - Plots for each stimulated and responding region with normalized CCEPs + N1 sorted by age
% Plots for each stimulated and responding region with normalized CCEPs + N1 sorted by age

ttmin = 0.010;
ttmax = .100;
Expand Down Expand Up @@ -101,7 +101,7 @@
set(gca,'XTick',20:20:80,'YTick',[])
axis tight

strSign = [' (p\_fdr = ', num2str(all_p_fdr{iTr}{iSubTr}(iDir + 1)), ')'];
strSign = [' (p\_fdr = ', num2str(all_p_fdr{iTr}{iSubTr}(iDir + 1)), ', n=', num2str(length(sortedCCEPs{iTr}{iSubTr}{iDir + 1}.age)), ')'];
if all_p_fdr{iTr}{iSubTr}(iDir + 1) < .05, strSign = [strSign, ' *']; end
title([rois(iTr).tract_name, ' - ', strSubTitle, strSign]);

Expand Down
33 changes: 19 additions & 14 deletions scripts/makeFig2and3_transmissionAcrossAge.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%
% This script produces Figure 3 of the article
% This script produces the plots for Figure 2 and 3 (B/C) of the article
%


Expand Down Expand Up @@ -127,6 +127,11 @@
n1LatencyMeans(exclMeans) = [];
n1SpeedMeans(exclMeans) = [];

% store the number of age-samples (age can be averages over more than one subject)
out{iTr}{iSubTr}{iDir + 1}.numAges = length(ages);


% initialize statistics variables
lat_cross_linear = NaN(length(n1LatencyMeans), 4); % <age> x <size latency (ms), prediction (ms), p1 (slope), p2 (intercept) of left out>
spd_cross_linear = NaN(length(n1LatencyMeans), 4); % <age> x <size latency (ms), prediction (ms), p1 (slope), p2 (intercept) of left out>
lat_cross_second = NaN(length(n1LatencyMeans), 5); % <age> x <size latency (ms) X prediction (ms) X p1 (age^2) X p2 (age) X p3 (intercept) of left out>
Expand Down Expand Up @@ -441,15 +446,15 @@
% Display in command window the cod and delta for each subplot
% this info is displayed in Figure 3 as well.

long_tracts = {'Y1065_TPAT - Parietal -> Temporal','Y1065_TPAT - Temporal -> Parietal',...
'Y1065_AF - Frontal -> Temporal','Y1065_AF - Temporal -> Frontal',...
'Y1065_SLF2 - Frontal -> Parietal','Y1065_SLF2 - Parietal -> Frontal',...
'Y1065_SLF2 - Frontal -> Central','Y1065_SLF2 - Central -> Frontal'};
long_tracts = { 'Y1065_TPAT - Parietal -> Temporal','Y1065_TPAT - Temporal -> Parietal',...
'Y1065_AF - Frontal -> Temporal','Y1065_AF - Temporal -> Frontal',...
'Y1065_SLF2 - Frontal -> Parietal','Y1065_SLF2 - Parietal -> Frontal',...
'Y1065_SLF2 - Frontal -> Central','Y1065_SLF2 - Central -> Frontal'};
long_cod_lat = NaN(1,length(long_tracts));
long_cod_spd = NaN(1,length(long_tracts));

U_tracts = {'Y842_U - PreCentral -> PostCentral','Y842_U - PostCentral -> PreCentral',...
'Y842_U - Frontal -> Frontal','Y842_U - Parietal -> Parietal'};
'Y842_U - Frontal -> Frontal','Y842_U - Parietal -> Parietal'};
U_cod_lat = NaN(1,length(U_tracts));
U_cod_spd = NaN(1,length(U_tracts));

Expand All @@ -460,13 +465,13 @@
for iDir = [false true]

if strcmp(out{iTr}{iSubTr}{iDir + 1}.lat_fit, 'linear')
fprintf(' - %s: best fit is linear, with COD = %2.0f, and delta %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.lat_cod, out{iTr}{iSubTr}{iDir + 1}.lat_delta)
fprintf(' - %s: n=%2.0f, best fit is linear, with COD = %2.0f, and delta %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.numAges, out{iTr}{iSubTr}{iDir + 1}.lat_cod, out{iTr}{iSubTr}{iDir + 1}.lat_delta)

elseif strcmp(out{iTr}{iSubTr}{iDir + 1}.lat_fit, 'second')

fprintf(' - %s: best fit is second, with COD = %2.0f, and delta: age0-10 = %1.2f, age10-20 = %1.2f, age20-30 = %1.2f, age30-40 = %1.2f, age40-50 = %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.lat_cod, out{iTr}{iSubTr}{iDir + 1}.lat_delta);
fprintf(' - %s: n=%2.0f, best fit is second, with COD = %2.0f, and delta: age0-10 = %1.2f, age10-20 = %1.2f, age20-30 = %1.2f, age30-40 = %1.2f, age40-50 = %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.numAges, out{iTr}{iSubTr}{iDir + 1}.lat_cod, out{iTr}{iSubTr}{iDir + 1}.lat_delta);

end

Expand All @@ -488,13 +493,13 @@
for iDir = [false true]

if strcmp(out{iTr}{iSubTr}{iDir + 1}.spd_fit, 'linear')
fprintf(' - %s: best fit is linear, with COD = %2.0f, and delta %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.spd_cod, out{iTr}{iSubTr}{iDir + 1}.spd_delta)
fprintf(' - %s: n=%2.0f, best fit is linear, with COD = %2.0f, and delta %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.numAges, out{iTr}{iSubTr}{iDir + 1}.spd_cod, out{iTr}{iSubTr}{iDir + 1}.spd_delta)

elseif strcmp(out{iTr}{iSubTr}{iDir + 1}.spd_fit, 'second')

fprintf(' - %s: best fit is second, with COD = %2.0f, and delta: age0-10 = %1.2f, age10-20 = %1.2f, age20-30 = %1.2f, age30-40 = %1.2f, age40-50 = %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.spd_cod, out{iTr}{iSubTr}{iDir + 1}.spd_delta);
fprintf(' - %s: n=%2.0f, best fit is second, with COD = %2.0f, and delta: age0-10 = %1.2f, age10-20 = %1.2f, age20-30 = %1.2f, age30-40 = %1.2f, age40-50 = %1.2f \n', ...
out{iTr}{iSubTr}{iDir + 1}.name, out{iTr}{iSubTr}{iDir + 1}.numAges, out{iTr}{iSubTr}{iDir + 1}.spd_cod, out{iTr}{iSubTr}{iDir + 1}.spd_delta);

end
% get averages
Expand Down
17 changes: 9 additions & 8 deletions scripts/makeSupFig1_only8maSubs.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
%
% This script outputs supplementary figure 1 - relation between age (years) and latency (ms) at different stimulation currents
% This script produces supplementary figure 1 - relation between age (years) and latency (ms) at different stimulation currents
%
% Dorien van Blooijs, Max van den Boom, 2022
% Max van den Boom, Dorien van Blooijs, 2023


clear
close all
Expand All @@ -24,7 +25,7 @@


%%
% ...
% Extract the different currents from the dataset

all_unique_currents =[];
all_currents = struct();
Expand Down Expand Up @@ -104,7 +105,7 @@
all_currents.(['mA', num2str(subject_unique_currents(iCurrent))]) = [];
end

% for this sbuject and current, add the age and latency
% for this subject and current, add the age and latency
ind = length(all_currents.(['mA', num2str(subject_unique_currents(iCurrent))]));
all_currents.(['mA', num2str(subject_unique_currents(iCurrent))])(ind + 1).age = ccepData(iSubj).age;
all_currents.(['mA', num2str(subject_unique_currents(iCurrent))])(ind + 1).latency = subject_currents.(['mA', num2str(subject_unique_currents(iCurrent))]);
Expand Down Expand Up @@ -178,15 +179,15 @@
% plot the points
plot(ages, latencies * 1000, '.', 'Color', curColor, 'MarkerSize', 16, 'DisplayName', [num2str(all_unique_currents(iCurrent)) ' mA (n=', num2str(length(latencies)), ')']);

% check if there are enough points
if length(latencies) >= minDataPoints

[P, S] = polyfit(ages(~isnan(ages) & ~isnan(latencies)), ...
latencies(~isnan(ages) & ~isnan(latencies)) * 1000, 1);
[P, S] = polyfit(ages(~isnan(ages) & ~isnan(latencies)), latencies(~isnan(ages) & ~isnan(latencies)) * 1000, 1);
[y_fit, ~] = polyval(P, ages, S);

% Plot polyfit throught data points
% Plot fit throught data points
plot(ages, y_fit, 'Color', curColor, 'LineWidth', 2, 'DisplayName', ...
['r=' num2str(all_unique_currents_r(iCurrent), 3) ' p=' num2str(all_unique_currents_p_fdr(iCurrent), 3)]);
['\rho=' num2str(all_unique_currents_r(iCurrent), 3) ' p=' num2str(all_unique_currents_p_fdr(iCurrent), 3)]);
end

end
Expand Down
Loading

0 comments on commit 3e87b97

Please sign in to comment.