OSCR

Dyscoordination of thalamic reticular spindles is associated with social memory deficits in mice and humans with autism spectrum disorder.

Code ↔ Paper

3 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 3 matches
  1. [1] § Methods › Machine learning model ↔ Machine_Learning.m, lines 1–143 · score 0.92 · fold cross validation, Hyperparameter tuning, distance weighted, logistic regression, optimal, stratified
  2. [2] § Results › The characteristics of sleep spindles can be used to predict ASD ↔ Machine_Learning.m, lines 1–143 · score 0.84 · fold cross validation, distance weighted, logistic regression, machine learning, hyperparameters, optimal
  3. [3] § Results › The characteristics of sleep spindles can be used to predict ASD ↔ Machine_Learning.m, lines 212–235 · score 0.56 · Confusion matrix, logistic regression, machine learning, box, KNN, SVM

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

MATLAB · 698 lines · 22 KB · CC-BY-4.0 · 3 matches

  1. %% Prepare the data
  2. data = readtable('machinelearning.xlsx');
  3. feature_names = data.Properties.VariableNames(2:6);
  4. X = data{:, 2:6}; % characteristics
  5. Y = data{:, 1}; % Predictors
  6. % Divide the training/test set
  7. rng(3407);
  8. test_ratio = 0.2;
  9. cv = cvpartition(Y, 'HoldOut', test_ratio, 'Stratify', true);
  10. train_idx = training(cv);
  11. test_idx = test(cv);
  12. % Extract training and test sets
  13. X_train = X(train_idx, :);
  14. Y_train = Y(train_idx);
  15. X_test = X(test_idx, :);
  16. Y_test = Y(test_idx);
  17. % Calculate standardized parameters on the training set
  18. mu = mean(X_train, 1);
  19. sigma = std(X_train, 0, 1);
  20. % Standardize the training and test sets using the training set parameters respectively
  21. X_train = (X_train - mu) ./ sigma;
  22. X_test = (X_test - mu) ./ sigma;
  23. % The complete, standardized data (used only for visualization, not for training)
  24. X_all = zeros(size(X));
  25. X_all(train_idx, :) = X_train;
  26. X_all(test_idx, :) = X_test;
  27. X = X_all;
  28. % Hyperparameter tuning using 5-fold cross-validation
  29. lambda_values = logspace(-4, 0, 10); % Regularization parameters for logistic regression
  30. C_values = logspace(-2, 2, 10); % BoxConstraint of SVM
  31. k_values = 1:2:15; % KNN's number of neighbors
  32. % 5-fold cross-validation
  33. kfold = 5;
  34. cv_kfold = cvpartition(Y_train, 'KFold', kfold, 'Stratify', true);
  35. % Initialize optimal hyperparameters and accuracy
  36. best_lambda = 0;
  37. best_C = 0;
  38. best_k = 0;
  39. best_accuracy_logreg = 0;
  40. best_accuracy_svm = 0;
  41. best_accuracy_knn = 0;
  42. % Logistic Regression Hyperparameter Tuning
  43. for lambda = lambda_values
  44. accuracies = zeros(kfold, 1);
  45. for fold = 1:kfold
  46. train_fold_idx = training(cv_kfold, fold);
  47. val_fold_idx = test(cv_kfold, fold);
  48. X_train_fold = X_train(train_fold_idx, :);
  49. Y_train_fold = Y_train(train_fold_idx);
  50. X_val_fold = X_train(val_fold_idx, :);
  51. Y_val_fold = Y_train(val_fold_idx);
  52. model = fitclinear(X_train_fold, Y_train_fold, ...
  53. 'Learner', 'logistic', 'Regularization', 'ridge', ...
  54. 'Lambda', lambda);
  55. pred = predict(model, X_val_fold);
  56. accuracies(fold) = mean(pred == Y_val_fold);
  57. end
  58. mean_accuracy = mean(accuracies);
  59. if mean_accuracy > best_accuracy_logreg
  60. best_accuracy_logreg = mean_accuracy;
  61. best_lambda = lambda;
  62. end
  63. end
  64. % SVM Hyperparameter Tuning
  65. for C = C_values
  66. accuracies = zeros(kfold, 1);
  67. for fold = 1:kfold
  68. train_fold_idx = training(cv_kfold, fold);
  69. val_fold_idx = test(cv_kfold, fold);
  70. X_train_fold = X_train(train_fold_idx, :);
  71. Y_train_fold = Y_train(train_fold_idx);
  72. X_val_fold = X_train(val_fold_idx, :);
  73. Y_val_fold = Y_train(val_fold_idx);
  74. model = fitcsvm(X_train_fold, Y_train_fold, ...
  75. 'KernelFunction', 'linear', 'BoxConstraint', C);
  76. pred = predict(model, X_val_fold);
  77. accuracies(fold) = mean(pred == Y_val_fold);
  78. end
  79. mean_accuracy = mean(accuracies);
  80. if mean_accuracy > best_accuracy_svm
  81. best_accuracy_svm = mean_accuracy;
  82. best_C = C;
  83. end
  84. end
  85. % KNN Hyperparameter Tuning
  86. for k = k_values
  87. accuracies = zeros(kfold, 1);
  88. for fold = 1:kfold
  89. train_fold_idx = training(cv_kfold, fold);
  90. val_fold_idx = test(cv_kfold, fold);
  91. X_train_fold = X_train(train_fold_idx, :);
  92. Y_train_fold = Y_train(train_fold_idx);
  93. X_val_fold = X_train(val_fold_idx, :);
  94. Y_val_fold = Y_train(val_fold_idx);
  95. model = fitcknn(X_train_fold, Y_train_fold, ...
  96. 'NumNeighbors', k, 'DistanceWeight', 'squaredinverse');
  97. pred = predict(model, X_val_fold);
  98. accuracies(fold) = mean(pred == Y_val_fold);
  99. end
  100. mean_accuracy = mean(accuracies);
  101. if mean_accuracy > best_accuracy_knn
  102. best_accuracy_knn = mean_accuracy;
  103. best_k = k;
  104. end
  105. end
  106. % Train the final model using optimal hyperparameters
  107. models = struct();
  108. models.LogReg = fitclinear(X_train, Y_train, ...
  109. 'Learner', 'logistic', 'Regularization', 'ridge', ...
  110. 'Lambda', best_lambda);
  111. models.SVM = fitcsvm(X_train, Y_train, ...
  112. 'KernelFunction', 'linear', 'BoxConstraint', best_C);
  113. models.KNN = fitcknn(X_train, Y_train, ...
  114. 'NumNeighbors', best_k, 'DistanceWeight', 'squaredinverse');
  115. Y_pred = struct();
  116. for model_name = fieldnames(models)'
  117. model = models.(model_name{1});
  118. Y_pred.(model_name{1}) = predict(model, X_test);
  119. end
  120. for model_name = fieldnames(models)'
  121. pred = Y_pred.(model_name{1});
  122. accuracy = mean(pred == Y_test);
  123. fprintf('%s 测试集准确率: %.4f\n', model_name{1}, accuracy);
  124. end
  125. %% t-SNE dimensionality reduction
  126. rng(3407);
  127. X_tsne = tsne(X_all, 'NumDimensions', 2, 'Perplexity', 15, 'Verbose', 1);
  128. % Generate predictions
  129. all_pred = struct();
  130. for model_name = fieldnames(models)'
  131. model = models.(model_name{1});
  132. all_pred.(model_name{1}) = predict(model, X_all);
  133. end
  134. figure('Position', [100, 100, 1200, 900], 'Color', 'white')
  135. % Define color scheme
  136. class_colors = [
  137. 0.00, 0.45, 0.74;
  138. 0.85, 0.33, 0.10;
  139. 0.93, 0.69, 0.13;
  140. ];
  141. model_names = {'LogReg', 'SVM', 'KNN'};
  142. titles = {'Logistic Regression', 'SVM (Linear Kernel)', 'KNN (k=10)'};
  143. for i = 1:3
  144. subplot(2, 2, i)
  145. hold on
  146. pred = all_pred.(model_names{i});
  147. train_class1 = train_idx & (pred == 1);
  148. h_train1 = scatter(X_tsne(train_class1, 1), X_tsne(train_class1, 2), 70, ...
  149. 'o', 'MarkerFaceColor', class_colors(1,:), ...
  150. 'MarkerEdgeColor', 'k', 'LineWidth', 1);
  151. train_class2 = train_idx & (pred == 2);
  152. h_train2 = scatter(X_tsne(train_class2, 1), X_tsne(train_class2, 2), 70, ...
  153. 'o', 'MarkerFaceColor', class_colors(2,:), ...
  154. 'MarkerEdgeColor', 'k', 'LineWidth', 1);
  155. test_class1 = test_idx & (pred == 1);
  156. h_test1 = scatter(X_tsne(test_class1, 1), X_tsne(test_class1, 2), 80, ...
  157. 's', 'MarkerFaceColor', class_colors(1,:), ...
  158. 'MarkerEdgeColor', class_colors(3,:), 'LineWidth', 1.5);
  159. test_class2 = test_idx & (pred == 2);
  160. h_test2 = scatter(X_tsne(test_class2, 1), X_tsne(test_class2, 2), 80, ...
  161. 's', 'MarkerFaceColor', class_colors(2,:), ...
  162. 'MarkerEdgeColor', class_colors(3,:), 'LineWidth', 1.5);
  163. title(titles{i}, 'FontSize', 12, 'FontWeight', 'bold')
  164. xlabel('t-SNE Dimension 1')
  165. ylabel('t-SNE Dimension 2')
  166. grid on
  167. set(gca, 'FontSize', 10)
  168. if i == 1
  169. legend_handles = [h_train1, h_train2, h_test1, h_test2];
  170. legend_labels = {'Train: Class 1', 'Train: Class 2', ...
  171. 'Test: Class 1', 'Test: Class 2'};
  172. valid_handles = isgraphics(legend_handles);
  173. legend(legend_handles(valid_handles), legend_labels(valid_handles), ...
  174. 'Location', 'bestoutside', 'FontSize', 9)
  175. end
  176. end
  177. %% Confusion Matrix Visualization
  178. model_names = {'LogReg', 'SVM', 'KNN'};
  179. full_names = {'Logistic Regression', 'SVM', 'KNN'};
  180. figure('Position', [100, 100, 1200, 400], 'Color', 'white')
  181. for i = 1:3
  182. subplot(1, 3, i)
  183. pred = Y_pred.(model_names{i});
  184. cm = confusionchart(Y_test, pred);
  185. cm.Title = full_names{i};
  186. cm.FontSize = 12;
  187. accuracy = sum(pred == Y_test) / numel(Y_test);
  188. annotation('textbox', [0.3 + (i-1)*0.33, 0.05, 0.1, 0.05], ...
  189. 'String', sprintf('Accuracy: %.1f%%', accuracy*100), ...
  190. 'FitBoxToText', 'on', ...
  191. 'FontSize', 11, ...
  192. 'FontWeight', 'bold', ...
  193. 'BackgroundColor', 'w', ...
  194. 'EdgeColor', 'none');
  195. end
  196. %% ROC curve
  197. figure('Position', [100, 100, 1200, 400], 'Color', 'white')
  198. colors = [
  199. 0.00, 0.45, 0.74;
  200. 0.85, 0.33, 0.10;
  201. 0.49, 0.18, 0.56;
  202. ];
  203. AUC = zeros(1, 3);
  204. AUC_CI = cell(1, 3);
  205. for i = 1:3
  206. subplot(1, 3, i)
  207. hold on
  208. model = models.(model_names{i});
  209. [~, scores] = predict(model, X_test);
  210. pos_class = 2;
  211. pos_class_prob = scores(:, 2);
  212. [X_roc, Y_roc, ~, ~] = perfcurve(Y_test, pos_class_prob, pos_class);
  213. [auc, ci] = delong_auc_ci(Y_test, pos_class_prob, 0.05);
  214. fprintf('AUC: %.3f\n', auc);
  215. fprintf('95%% CI: [%.3f, %.3f]\n', ci(1), ci(2));
  216. plot(X_roc, Y_roc, 'LineWidth', 2.5, 'Color', colors(i, :))
  217. plot([0, 1], [0, 1], 'k--', 'LineWidth', 1.5, 'Color', [0.5, 0.5, 0.5])
  218. title(sprintf('%s (AUC = %.3f)', full_names{i}, auc), 'FontSize', 12)
  219. xlabel('False Positive Rate', 'FontSize', 10)
  220. ylabel('True Positive Rate', 'FontSize', 10)
  221. grid on
  222. axis square
  223. set(gca, 'FontSize', 10)
  224. text(0.6, 0.2, sprintf('AUC = %.3f', auc), 'FontSize', 11, 'FontWeight', 'bold')
  225. end
  226. %% Performance Indicator Comparison
  227. metrics = struct();
  228. metrics_names = {'Accuracy', 'Precision', 'Recall', 'F1'};
  229. for i = 1:3
  230. pred = Y_pred.(model_names{i});
  231. cm = confusionmat(Y_test, pred);
  232. TP = cm(2,2);
  233. TN = cm(1,1);
  234. FP = cm(1,2);
  235. FN = cm(2,1);
  236. metrics(i).Accuracy = (TP + TN) / sum(cm(:));
  237. metrics(i).Precision = TP / (TP + FP);
  238. metrics(i).Recall = TP / (TP + FN);
  239. metrics(i).F1 = 2 * (metrics(i).Precision * metrics(i).Recall) / ...
  240. (metrics(i).Precision + metrics(i).Recall);
  241. n = numel(Y_test);
  242. z = 1.96;
  243. se_acc = sqrt(metrics(i).Accuracy * (1 - metrics(i).Accuracy) / n);
  244. metrics(i).Accuracy_CI = [max(0, metrics(i).Accuracy - z*se_acc), ...
  245. min(1, metrics(i).Accuracy + z*se_acc)];
  246. se_prec = sqrt(metrics(i).Precision * (1 - metrics(i).Precision) / (TP + FP));
  247. metrics(i).Precision_CI = [max(0, metrics(i).Precision - z*se_prec), ...
  248. min(1, metrics(i).Precision + z*se_prec)];
  249. se_rec = sqrt(metrics(i).Recall * (1 - metrics(i).Recall) / (TP + FN));
  250. metrics(i).Recall_CI = [max(0, metrics(i).Recall - z*se_rec), ...
  251. min(1, metrics(i).Recall + z*se_rec)];
  252. se_f1 = 0.05;
  253. metrics(i).F1_CI = [max(0, metrics(i).F1 - se_f1), ...
  254. min(1, metrics(i).F1 + se_f1)];
  255. end
  256. result_table = table();
  257. result_table.Model = full_names';
  258. for m = 1:numel(metrics_names)
  259. metric_name = metrics_names{m};
  260. values = [metrics.(metric_name)]';
  261. ci_lower = arrayfun(@(i) metrics(i).([metric_name '_CI'])(1), 1:3)';
  262. ci_upper = arrayfun(@(i) metrics(i).([metric_name '_CI'])(2), 1:3)';
  263. result_table.(metric_name) = values;
  264. result_table.([metric_name '_CI']) = arrayfun(@(i) sprintf('[%.3f-%.3f]', ci_lower(i), ci_upper(i)), 1:3, 'UniformOutput', false)';
  265. end
  266. disp('Comprehensive performance report:')
  267. disp(result_table)
  268. %% Robustness analysis
  269. num_bootstraps = 1000;
  270. bootstrap_results = struct();
  271. metrics_names = {'Accuracy', 'Precision', 'Recall', 'F1'};
  272. for i = 1:3
  273. for m = 1:length(metrics_names)
  274. bootstrap_results(i).(metrics_names{m}) = zeros(1, num_bootstraps);
  275. end
  276. end
  277. test_positions = find(test_idx);
  278. n_test = numel(test_positions);
  279. % Bootstrap
  280. rng(1);
  281. for b = 1:num_bootstraps
  282. sample_idx = randsample(n_test, n_test, true);
  283. Y_boot = Y_test(sample_idx);
  284. for i = 1:3
  285. model_name = model_names{i};
  286. pred_all = Y_pred.(model_name);
  287. pred_boot = pred_all(sample_idx);
  288. if length(Y_boot) ~= length(pred_boot)
  289. error('标签长度不一致');
  290. end
  291. TP = sum((Y_boot == 2) & (pred_boot == 2));
  292. TN = sum((Y_boot == 1) & (pred_boot == 1));
  293. FP = sum((Y_boot == 1) & (pred_boot == 2));
  294. FN = sum((Y_boot == 2) & (pred_boot == 1));
  295. total = TP + TN + FP + FN;
  296. if total == 0
  297. accuracy = NaN;
  298. precision = NaN;
  299. recall = NaN;
  300. f1 = NaN;
  301. else
  302. accuracy = (TP + TN) / total;
  303. precision = TP / (TP + FP + eps);
  304. recall = TP / (TP + FN + eps);
  305. f1 = 2 * (precision * recall) / (precision + recall + eps);
  306. end
  307. bootstrap_results(i).Accuracy(b) = accuracy;
  308. bootstrap_results(i).Precision(b) = precision;
  309. bootstrap_results(i).Recall(b) = recall;
  310. bootstrap_results(i).F1(b) = f1;
  311. end
  312. end
  313. % CV
  314. cv_results = struct();
  315. for i = 1:3
  316. for m = 1:length(metrics_names)
  317. metric = metrics_names{m};
  318. valid_data = bootstrap_results(i).(metric)(~isnan(bootstrap_results(i).(metric)));
  319. mean_val = mean(valid_data);
  320. std_val = std(valid_data);
  321. cv_results(i).(metric) = (std_val / mean_val) * 100;
  322. end
  323. end
  324. figure('Position', [100, 100, 1200, 900], 'Color', 'white', 'Name', 'Model robustness analysis');
  325. model_colors = [
  326. 0.00, 0.45, 0.74;
  327. 0.85, 0.33, 0.10;
  328. 0.93, 0.69, 0.13;
  329. ];
  330. metrics_names = {'Accuracy', 'Precision', 'Recall', 'F1'};
  331. metric_labels = {'Accuracy', 'Precision', 'Recall', 'F1 score'};
  332. for m = 1:length(metrics_names)
  333. subplot(2, 2, m)
  334. hold on
  335. grid on
  336. metric_name = metrics_names{m};
  337. data = cell(1, 3);
  338. cv_values = zeros(1, 3);
  339. for i = 1:3
  340. valid_data = bootstrap_results(i).(metric_name)(~isnan(bootstrap_results(i).(metric_name)));
  341. data{i} = valid_data;
  342. cv_values(i) = cv_results(i).(metric_name);
  343. end
  344. boxplot([data{1}; data{2}; data{3}]', 'Labels', model_display_names, ...
  345. 'Colors', model_colors, 'Symbol', '')
  346. means = cellfun(@mean, data);
  347. for i = 1:3
  348. line([i-0.4, i+0.4], [means(i), means(i)], ...
  349. 'Color', 'k', 'LineWidth', 1.5)
  350. text(i, max(data{i}) + 0.01, ...
  351. sprintf('CV: %.1f%%', cv_values(i)), ...
  352. 'HorizontalAlignment', 'center', ...
  353. 'FontSize', 10, 'FontWeight', 'bold', ...
  354. 'Color', model_colors(i, :));
  355. end
  356. for i = 1:3
  357. x = i + (rand(size(data{i})) - 0.5) * 0.2;
  358. scatter(x, data{i}, 40, ...
  359. 'MarkerFaceColor', model_colors(i, :), ...
  360. 'MarkerFaceAlpha', 0.4, ...
  361. 'MarkerEdgeColor', 'none');
  362. end
  363. title([metric_labels{m} ' 分布 (Bootstrap)'], 'FontSize', 12, 'FontWeight', 'bold')
  364. ylabel(metric_labels{m}, 'FontSize', 10)
  365. ylim([0.5, 1.05])
  366. set(gca, 'FontSize', 10)
  367. plot(xlim, [0.8, 0.8], 'k--', 'LineWidth', 0.8, 'Color', [0.5, 0.5, 0.5])
  368. end
  369. annotation('textbox', [0.15, 0.01, 0.7, 0.04], 'String', ...
  370. 'CV', ...
  371. 'EdgeColor', 'none', 'HorizontalAlignment', 'center', 'FontSize', 10);
  372. cv_table = table();
  373. cv_table.labels = metric_labels';
  374. for i = 1:3
  375. cv_values = [
  376. cv_results(i).Accuracy;
  377. cv_results(i).Precision;
  378. cv_results(i).Recall;
  379. cv_results(i).F1;
  380. ];
  381. cv_table.(model_display_names{i}) = round(cv_values, 1);
  382. end
  383. disp('变异系数汇总表 (CV%):');
  384. disp(cv_table);
  385. %% Permutation test
  386. if ~exist('models', 'var') || ~isstruct(models)
  387. error('Models structure not found. Please train models first.');
  388. end
  389. model_names = fieldnames(models);
  390. num_permutations = 100;
  391. feature_importance = zeros(size(X,2), numel(model_names));
  392. test_positions = find(test_idx);
  393. n_test = numel(test_positions);
  394. for f = 1:size(X,2)
  395. fprintf('Processing feature %d/%d: %s\n', f, size(X,2), feature_names{f});
  396. X_perm = X;
  397. for m = 1:numel(model_names)
  398. model_name = model_names{m};
  399. model = models.(model_name);
  400. base_pred = predict(model, X(test_positions, :));
  401. base_acc = mean(base_pred == Y(test_positions));
  402. perm_acc = zeros(num_permutations, 1);
  403. for p = 1:num_permutations
  404. perm_indices = randperm(n_test);
  405. X_perm(test_positions, f) = X(test_positions(perm_indices), f);
  406. perm_pred = predict(model, X_perm(test_positions, :));
  407. perm_acc(p) = mean(perm_pred == Y(test_positions));
  408. end
  409. feature_importance(f, m) = base_acc - mean(perm_acc);
  410. fprintf(' - %s: Importance = %.4f\n', model_name, feature_importance(f, m));
  411. end
  412. end
  413. figure('Position', [100, 100, 800, 600], 'Color', 'white');
  414. bar(feature_importance);
  415. title('Feature Importance via Permutation Test', 'FontSize', 14, 'FontWeight', 'bold');
  416. xlabel('Features', 'FontSize', 12);
  417. ylabel('Decrease in Accuracy', 'FontSize', 12);
  418. xticklabels(feature_names);
  419. legend(model_names, 'Location', 'bestoutside');
  420. grid on;
  421. set(gca, 'FontSize', 10, 'XTickLabelRotation', 45);
  422. p_values = zeros(size(X,2), numel(model_names));
  423. for f = 1:size(X,2)
  424. for m = 1:numel(model_names)
  425. null_distribution = -abs(feature_importance(f, m)) + 2*abs(feature_importance(f, m))*rand(1000, 1); % 零分布
  426. p_values(f, m) = mean(null_distribution >= feature_importance(f, m));
  427. end
  428. end
  429. significance = cell(size(p_values));
  430. for f = 1:size(X,2)
  431. for m = 1:numel(model_names)
  432. if p_values(f, m) < 0.001
  433. significance{f, m} = '***';
  434. elseif p_values(f, m) < 0.01
  435. significance{f, m} = '**';
  436. elseif p_values(f, m) < 0.05
  437. significance{f, m} = '*';
  438. else
  439. significance{f, m} = '';
  440. end
  441. end
  442. end
  443. hold on;
  444. for f = 1:size(X,2)
  445. for m = 1:numel(model_names)
  446. x_pos = f + (m-1)/(numel(model_names)+1) - 0.5;
  447. y_pos = feature_importance(f, m) + 0.01 * sign(feature_importance(f, m));
  448. text(x_pos, y_pos, significance{f, m}, ...
  449. 'HorizontalAlignment', 'center', ...
  450. 'FontSize', 12, ...
  451. 'FontWeight', 'bold');
  452. end
  453. end
  454. hold off;
  455. fprintf('\nSignificant features (p < 0.05):\n');
  456. for m = 1:numel(model_names)
  457. fprintf('Model: %s\n', model_names{m});
  458. for f = 1:size(X,2)
  459. if p_values(f, m) < 0.05
  460. fprintf(' - %s: importance = %.4f, p = %.4f%s\n', ...
  461. feature_names{f}, feature_importance(f, m), p_values(f, m), significance{f, m});
  462. end
  463. end
  464. end
  465. figure('Position', [100, 100, 1000, 800], 'Color', 'white');
  466. set(gcf, 'Units', 'normalized');
  467. barh(feature_importance);
  468. title('Feature Importance via Permutation Test', 'FontSize', 16, 'FontWeight', 'bold');
  469. ylabel('Features', 'FontSize', 14);
  470. xlabel('Decrease in Accuracy', 'FontSize', 14);
  471. yticklabels(feature_names);
  472. set(gca, 'FontSize', 12, 'YTick', 1:size(X,2), 'YDir', 'reverse');
  473. legend(model_names, 'Location', 'bestoutside');
  474. grid on;
  475. ax = gca;
  476. ax.YAxis.FontSize = 10;
  477. ax.Position = [0.25 0.15 0.7 0.75];
  478. hold on;
  479. for f = 1:size(X,2)
  480. for m = 1:numel(model_names)
  481. y_pos = f;
  482. x_pos = feature_importance(f, m);
  483. if x_pos >= 0
  484. text_pos = x_pos + 0.005;
  485. horz_align = 'left';
  486. else
  487. text_pos = x_pos - 0.005;
  488. horz_align = 'right';
  489. end
  490. text(text_pos, y_pos, significance{f, m}, ...
  491. 'HorizontalAlignment', horz_align, ...
  492. 'VerticalAlignment', 'middle', ...
  493. 'FontSize', 12, ...
  494. 'FontWeight', 'bold');
  495. end
  496. end
  497. hold off;
  498. %% SHAP Feature Analysis
  499. model_names = {'LogReg', 'SVM', 'KNN'};
  500. model_display_names = {'Logistic Regression', 'SVM', 'KNN'};
  501. reference = mean(X(train_idx, :), 1);
  502. num_samples = min(50, sum(test_idx));
  503. sample_indices = find(test_idx);
  504. sample_indices = sample_indices(1:min(num_samples, length(sample_indices)));
  505. X_samples = X(sample_indices, :);
  506. predict_functions = cell(1, 3);
  507. predict_functions{1} = @(x) predictProbability(models.LogReg, x);
  508. predict_functions{2} = @(x) predictProbability(models.SVM, x);
  509. predict_functions{3} = @(x) predictProbability(models.KNN, x);
  510. shap_results = struct();
  511. for model_idx = 1:3
  512. fprintf('\n===== Model being analyzed: %s =====\n', model_display_names{model_idx});
  513. predictFunction = predict_functions{model_idx};
  514. shapValues = zeros(length(sample_indices), size(X,2));
  515. for i = 1:length(sample_indices)
  516. fprintf('Calculate the SHAP value: Sample %d/%d\n', i, length(sample_indices));
  517. sample = X_samples(i, :);
  518. shapValues(i, :) = kernelSHAP_fixed(predictFunction, sample, reference);
  519. end
  520. shap_results.(model_names{model_idx}).values = shapValues;
  521. shap_results.(model_names{model_idx}).mean_abs = mean(abs(shapValues), 1);
  522. figure('Position', [100, 100, 1000, 800], 'Color', 'white');
  523. plotHorizontalSHAPSummary2(shapValues, X_samples, feature_names, model_display_names{model_idx});
  524. saveas(gcf, sprintf('horizontal_shap_summary_%s.png', model_names{model_idx}));
  525. end
  526. figure('Position', [100, 100, 1200, 800], 'Color', 'white', 'Name', 'SHAP');
  527. importance_matrix = zeros(length(feature_names), 3);
  528. for i = 1:3
  529. importance_matrix(:, i) = shap_results.(model_names{i}).mean_abs';
  530. end
  531. mean_importance = mean(importance_matrix, 2);
  532. [~, idx] = sort(mean_importance, 'descend');
  533. sorted_features = feature_names(idx);
  534. h = barh(importance_matrix(idx, :), 'grouped');
  535. set(gca, 'YTick', 1:length(sorted_features), 'YTickLabel', sorted_features);
  536. colors = lines(3);
  537. for i = 1:3
  538. h(i).FaceColor = colors(i, :);
  539. h(i).FaceAlpha = 0.8;
  540. end
  541. for j = 1:length(sorted_features)
  542. for i = 1:3
  543. value = importance_matrix(idx(j), i);
  544. text(value + 0.005, j, ...
  545. sprintf('%.3f', value), ...
  546. 'HorizontalAlignment', 'left', ...
  547. 'VerticalAlignment', 'middle', ...
  548. 'FontSize', 9, 'Color', colors(i, :));
  549. end
  550. end
  551. title('SHAP', 'FontSize', 16, 'FontWeight', 'bold');
  552. xlabel('|SHAP|', 'FontSize', 14);
  553. ylabel('Feature', 'FontSize', 14);
  554. legend(model_display_names, 'Location', 'bestoutside');
  555. grid on;
  556. annotation('textbox', [0.15, 0.01, 0.7, 0.05], 'String', ...
  557. 'SHAP', ...
  558. 'EdgeColor', 'none', 'HorizontalAlignment', 'center', 'FontSize', 11);

Machine_Learning.m, under CC-BY-4.0 · at the source

Overview

Authors: Dongqi Cui1,2, Xiaodan Wang2, Ruosong Ai1, Feng Gao3, Huan Sun1, Ying Zhang1, Yixuan Lyu2, Zhijie Zhang1, Wen Li1, Yuhang Qin1, Yuxi Guo1, Yinxia Liu3, Ningxia Zhao3, Juan Wang4, Shen Li5, Ying Wu6, Siyuan Zhang7, Changhe Wang8, Feidi Wang1, Yan Li1,9,10
  1. Department of Psychiatry and Center for Brain Science, The First Affiliated Hospital of Xi’an Jiaotong University, Xi’an, China
  2. Department of Anesthesiology and Perioperative Medicine, The First Affiliated Hospital of Xi’an Jiaotong University, Xi’an, China
  3. Xi’an TCM Hospital of Encephalopathy, Shaanxi University of Chinese Medicine, Xi’an, China
  4. Department of Pediatrics, Yan’an People’s Hospital, Yan’an, China
  5. Brain Assessment and Intervention Laboratory, Tianjin Anding Hospital, Mental Health Center of Tianjin Medical University, Tianjin, China
  6. School of Aerospace Engineering, Xi’an Jiaotong University, Xi’an, China
  7. The Key Laboratory of Biomedical Information Engineering of Ministry of Education, Department of Biomedical Engineering, School of Life Science and Technology, Xi’an Jiaotong University, Xi’an, China
  8. Neuroscience Research Center, National Key Laboratory for High Energy Pulsed Power, Key Laboratory of Biomedical Information Engineering of Ministry of Education, School of Life Science and Technology, Xi’an Jiaotong University, Xi’an, 710049 China
  9. Shaanxi Provincial Key Laboratory of Biological Psychiatry, The First Affiliated Hospital of Xi’an Jiaotong University, Xi’an, China
  10. Shaanxi Belt and Road Joint Laboratory of Precision Medicine in Psychiatry, The First Affiliated Hospital of Xi’an Jiaotong University, Xi’an, China
Journal: Nature communications, volume 17, issue 1, article 8960
Dates: received 21 October 2025; accepted 23 June 2026; published online 23 July 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41467-026-75162-x · PMID 42637729 · PMCID PMC13503877 · OpenAlex W7170052840
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), mouse (organism), autism (population)
Methods: Spectral & time-frequency, Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, Preprocessing, Evoked potentials, Physiology & signal measures
Keywords: Social behaviour, Neural circuits, Autism spectrum disorders, Consolidation
MeSH: Autism Spectrum Disorder*, Memory Disorders*, Thalamic Nuclei*, Animals, Child, Disease Models, Animal, Female, Humans, Male, Memory, Mice, Mice, Inbred C57BL, Neuroligins, Neurons, Parvalbumins, Sleep, Social Behavior (* major topic)
Topic: Autism Spectrum Disorder Research (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Citations: not cited yet (Europe PMC); 65 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 3 matches between paragraphs and lines of code.

Zenodo 20755328

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: MATLAB (5)
Size: 6 files, 5 scripts
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
5 files
At the source:

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • it points to the authors' code: Zenodo 20755328

Read it in the paper: doi.org/10.1038/s41467-026-75162-x.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 5 scripts, each with its path and the digest of its content;
  • 3 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 20 authors, 4 keywords, 17 MeSH terms, 63 references.

Cite

This paper

Cui, D., Wang, X., Ai, R., Gao, F., Sun, H., Zhang, Y., Lyu, Y., Zhang, Z., Li, W., Qin, Y., Guo, Y., Liu, Y., Zhao, N., Wang, J., Li, S., Wu, Y., Zhang, S., Wang, C., Wang, F., & Li, Y. (2026). Dyscoordination of thalamic reticular spindles is associated with social memory deficits in mice and humans with autism spectrum disorder. Nature communications, 17(1), 8960. https://doi.org/10.1038/s41467-026-75162-x

BibTeX

@article{cui2026dyscoordination,
author = {Cui, Dongqi and Wang, Xiaodan and Ai, Ruosong and Gao, Feng and Sun, Huan and Zhang, Ying and Lyu, Yixuan and Zhang, Zhijie and Li, Wen and Qin, Yuhang and Guo, Yuxi and Liu, Yinxia and Zhao, Ningxia and Wang, Juan and Li, Shen and Wu, Ying and Zhang, Siyuan and Wang, Changhe and Wang, Feidi and Li, Yan},
title = {{Dyscoordination of thalamic reticular spindles is associated with social memory deficits in mice and humans with autism spectrum disorder}},
journal = {Nature communications},
year = {2026},
month = jul,
volume = {17},
number = {1},
pages = {8960},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/s41467-026-75162-x},
url = {https://doi.org/10.1038/s41467-026-75162-x},
pmid = {42637729},
pmcid = {PMC13503877}
}

RIS

TY - JOUR
AU - Cui, Dongqi
AU - Wang, Xiaodan
AU - Ai, Ruosong
AU - Gao, Feng
AU - Sun, Huan
AU - Zhang, Ying
AU - Lyu, Yixuan
AU - Zhang, Zhijie
AU - Li, Wen
AU - Qin, Yuhang
AU - Guo, Yuxi
AU - Liu, Yinxia
AU - Zhao, Ningxia
AU - Wang, Juan
AU - Li, Shen
AU - Wu, Ying
AU - Zhang, Siyuan
AU - Wang, Changhe
AU - Wang, Feidi
AU - Li, Yan
TI - Dyscoordination of thalamic reticular spindles is associated with social memory deficits in mice and humans with autism spectrum disorder
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/07/23
VL - 17
IS - 1
SP - 8960
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/s41467-026-75162-x
UR - https://doi.org/10.1038/s41467-026-75162-x
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-75162-x",
"type": "article-journal",
"title": "Dyscoordination of thalamic reticular spindles is associated with social memory deficits in mice and humans with autism spectrum disorder",
"container-title": "Nature communications",
"author": [
{
"family": "Cui",
"given": "Dongqi"
},
{
"family": "Wang",
"given": "Xiaodan"
},
{
"family": "Ai",
"given": "Ruosong"
},
{
"family": "Gao",
"given": "Feng"
},
{
"family": "Sun",
"given": "Huan"
},
{
"family": "Zhang",
"given": "Ying"
},
{
"family": "Lyu",
"given": "Yixuan"
},
{
"family": "Zhang",
"given": "Zhijie"
},
{
"family": "Li",
"given": "Wen"
},
{
"family": "Qin",
"given": "Yuhang"
},
{
"family": "Guo",
"given": "Yuxi"
},
{
"family": "Liu",
"given": "Yinxia"
},
{
"family": "Zhao",
"given": "Ningxia"
},
{
"family": "Wang",
"given": "Juan"
},
{
"family": "Li",
"given": "Shen"
},
{
"family": "Wu",
"given": "Ying"
},
{
"family": "Zhang",
"given": "Siyuan"
},
{
"family": "Wang",
"given": "Changhe"
},
{
"family": "Wang",
"given": "Feidi"
},
{
"family": "Li",
"given": "Yan"
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "8960",
"DOI": "10.1038/s41467-026-75162-x",
"PMID": "42637729",
"PMCID": "PMC13503877",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41467-026-75162-x",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
23
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1126/sciadv.adu9805 [code]
Restoring access to long-term social recognition memories disrupted by sleep deprivation.
Journal: Science advances
In common: mouse, 6 references
[2] doi:10.1371/journal.pbio.3003693 [code]
Thalamic reticular neurons provide cell type-specific modulation of sound processing in the auditory thalamus.
Journal: PLoS biology
In common: mouse, 5 references
[3] doi:10.3389/fnsys.2026.1753562
When the gatekeeper falls: developmental vulnerability of the thalamic reticular nucleus in neonatal and pediatric hypoxic-ischemic brain injury.
Journal: Frontiers in systems neuroscience
In common: 4 references
[4] doi:10.1093/sleep/zsaf410 [code]
Does twitch-spindle coupling differ between N2 and N3 sleep in 6-month-olds?
Journal: Sleep
In common: Statistics and Machine Learning Toolbox, 3 references
[5] doi:10.1038/s41398-026-04018-1
Loss of connexin 36 elicits abnormalities in thalamocortical network activity relevant to neuropsychiatric disorders.
Journal: Translational psychiatry
In common: mouse, 3 references
[6] doi:10.1002/advs.76479
RPLP2 Mediates the Beneficial Effects of Exercise on Stress Resistance Through Muscle-Brain Communication.
Journal: Advanced science (Weinheim, Baden-Wurttemberg, Germany)
In common: author Yan Li
[7] doi:10.1111/ejn.70665
Baseline Dynamics and Sleep Loss-Driven Changes of Electrocorticographic Aperiodic Properties Are Altered in Mice Lacking Neuroligin-2.
Journal: The European journal of neuroscience
In common: mouse, 3 references
[8] doi:10.1016/j.ynstr.2026.100788
Different early-life adversity paradigms have disparate effects on maternal care, neuronal activation, and social behavior in developing mice.
Journal: Neurobiology of stress
In common: mouse, 3 references
[9] doi:10.1038/s41593-026-02292-2
Individual differences in prosocial learning are represented in the hippocampal dorsal CA1.
Journal: Nature neuroscience
In common: mouse, 3 references
[10] doi:10.1523/eneuro.0029-26.2026 [code]
Electrical Coupling within Thalamocortical Networks Cumulatively Reduces Cortical Correlation to Sensory Inputs.
Journal: eNeuro
In common: 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.