Hypercapnia dissociates neuronal and hemodynamic responses impairing neurovascular coupling and functional brain connectivity.
One block of code here has a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.
The 1 match
- [1] § Methods › Dynamic functional connectivity analysis ↔ dfc_state_analysis.m, lines 864 to 924 · score 0.56 · cross correlation, state transition, lag, duration, dFC, window · block
oscr:b:D0YNQZQXHKK1Q-F· Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
MATLAB · 1,383 lines · 67 KB · CC-BY-4.0 · 1 match
- close all; clc; clearvars;
- %% dFC state analysis: FL (10 Hz, 1 Hz), neural, and fMRI
- %
- % Required files in the working directory:
- % dFC_10Hz.mat
- % dFC_1Hz.mat
- % dFC_fMRI.mat
- % dFC_neural.mat
- %
- % Expected data dimensions: [num_regions x num_regions x num_windows x num_animals]
- %% Load data
- load('dFC_10Hz.mat');
- load('dFC_neural.mat');
- load('dFC_fMRI.mat');
- load('dFC_1Hz.mat');
- % Optional colormaps
- % cm_turbo_custom = load_colormap_safe('turbo_custom.mat', 'turbo_custom', parula(256));
- % cm_turbo_custom_endWhite = load_colormap_safe('turbo_custom_endWhite.mat', 'turbo_custom_endWhite', parula(256));
- % cm_custom_blueToRed = load_colormap_safe('custom_blueToRed.mat', 'custom_blueToRed', parula(256));
- % cm_custom_blue2red_2 = load_colormap_safe('custom_blue2red_2.mat', 'custom_blue2red_2', parula(256));
- rng('threefry');
- %% Parameters
- num_regions = size(dFC_10Hz, 1);
- num_animals = size(dFC_10Hz, 4);
- num_replicates = 20;
- max_clusters = 10;
- window_size_10Hz = 300;
- step_size_10Hz = 10;
- window_size_fMRI = 30;
- step_size_fMRI = 1;
- window_size_1Hz = 30;
- step_size_1Hz = 1;
- sampling_rate_10Hz = 10;
- sampling_rate_fMRI = 1;
- sampling_rate_1Hz = 1;
- num_windows_neural = size(dFC_neural, 3);
- num_windows_fMRI = size(dFC_fMRI, 3);
- num_windows_10Hz = size(dFC_10Hz, 3);
- num_windows_1Hz = size(dFC_1Hz, 3);
- optimal_num_clusters_combined = 6;
- optimal_num_clusters_fMRI = 5;
- % Region re-ordering for visualization
- new_order = [1:10, 11, 23, 12:15, 24, 16, 17, 18, 19, 20, 21, 22, 25, ...
- 26:35, 36, 48, 37:40, 49, 41, 42, 43, 44, 45, 46, 47, 50];
- %% CO2 timing
- % Start indices are subject-specific only for subject 3.
- co2_on_periods = [175, 535];
- co2_on_periods_sub3 = [235, 595];
- co2_duration = 165; % chosen analysis duration after accounting for windowing
- co2_on_duration_fMRI = co2_duration;
- co2_on_indices_10Hz = round(co2_on_periods * sampling_rate_10Hz / step_size_10Hz);
- co2_on_indices_10Hz_sub3 = round(co2_on_periods_sub3 * sampling_rate_10Hz / step_size_10Hz);
- co2_on_indices_fMRI = round(co2_on_periods * sampling_rate_fMRI / step_size_fMRI);
- co2_on_indices_fMRI_sub3 = round(co2_on_periods_sub3 * sampling_rate_fMRI / step_size_fMRI);
- co2_on_indices_1Hz = round(co2_on_periods * sampling_rate_1Hz / step_size_1Hz);
- co2_on_indices_1Hz_sub3 = round(co2_on_periods_sub3 * sampling_rate_1Hz / step_size_1Hz);
- %% Reshape data for clustering
- hemodynamic_10Hz_data = reshape(dFC_10Hz, num_regions * num_regions, [])';
- hemodynamic_1Hz_data = reshape(dFC_1Hz, num_regions * num_regions, [])';
- combined_hemodynamic_data = [hemodynamic_10Hz_data; hemodynamic_1Hz_data];
- fMRI_data = reshape(dFC_fMRI, num_regions * num_regions, [])';
- neural_data = reshape(dFC_neural, num_regions * num_regions, [])';
- %% K-means clustering
- rng('philox');
- [idx_combined, centroids_combined] = kmeans(combined_hemodynamic_data, ...
- optimal_num_clusters_combined, 'Replicates', num_replicates);
- idx_10Hz = reshape(idx_combined(1:size(hemodynamic_10Hz_data, 1)), num_windows_10Hz, num_animals);
- idx_1Hz = reshape(idx_combined(size(hemodynamic_10Hz_data, 1) + 1:end), num_windows_1Hz, num_animals);
- rng('philox');
- [idx_fMRI, centroids_fMRI] = kmeans(fMRI_data, optimal_num_clusters_fMRI, ...
- 'Replicates', num_replicates);
- idx_fMRI = reshape(idx_fMRI, num_windows_fMRI, num_animals);
- %% Remove states observed in only one subject, then fill missing labels by nearest centroid
- [idx_10Hz, removed_states_10Hz] = remove_single_subject_states(idx_10Hz);
- [idx_1Hz, removed_states_1Hz] = remove_single_subject_states(idx_1Hz);
- [idx_fMRI, removed_states_fMRI] = remove_single_subject_states(idx_fMRI);
- if ~isempty(removed_states_10Hz)
- fprintf('FL 10 Hz states removed for single-subject occurrence: %s\n', mat2str(removed_states_10Hz));
- end
- if ~isempty(removed_states_1Hz)
- fprintf('FL 1 Hz states removed for single-subject occurrence: %s\n', mat2str(removed_states_1Hz));
- end
- if ~isempty(removed_states_fMRI)
- fprintf('fMRI states removed for single-subject occurrence: %s\n', mat2str(removed_states_fMRI));
- end
- distance_matrix_combined = pdist2(centroids_combined, centroids_combined);
- distance_matrix_fMRI = pdist2(centroids_fMRI, centroids_fMRI);
- idx_10Hz = replace_nan_states_with_closest(idx_10Hz, distance_matrix_combined);
- idx_1Hz = replace_nan_states_with_closest(idx_1Hz, distance_matrix_combined);
- idx_fMRI = replace_nan_states_with_closest(idx_fMRI, distance_matrix_fMRI);
- %% Plot identified state centroids and mean neural dFC
- neural_plot = mean(dFC_neural, [3 4]);
- neural_2plot = neural_plot(new_order, new_order);
- figure('Position', [100 100 500 900]);
- for k = 1:optimal_num_clusters_combined
- FL_plot = reshape(centroids_combined(k, :), num_regions, num_regions);
- FL_2plot = FL_plot(new_order, new_order);
- subplot(ceil(optimal_num_clusters_combined / 2), 2, k);
- imagesc(FL_2plot);
- axis square;
- caxis([-1 1]);
- colormap(parula);
- title(sprintf('Identified State %d - FL', k));
- xlabel('Region'); ylabel('Region');
- end
- figure('Position', [100 100 500 900]);
- for k = 1:optimal_num_clusters_fMRI
- fMRI_plot = reshape(centroids_fMRI(k, :), num_regions, num_regions);
- fMRI_2plot = fMRI_plot(new_order, new_order);
- subplot(ceil(optimal_num_clusters_fMRI / 2), 2, k);
- imagesc(fMRI_2plot);
- axis square;
- caxis([-0.4 0.4]);
- colorbar;
- colormap(parula);
- title(sprintf('Identified State %d - fMRI', k));
- xlabel('Region'); ylabel('Region');
- end
- figure;
- imagesc(neural_2plot);
- axis square;
- colorbar;
- caxis([-1 1]);
- colormap(parula);
- title('Mean neural dFC');
- xlabel('Region'); ylabel('Region');
- %% Compare hemodynamic state centroids with neural dFC windows
- state_neural_similarity_combined = nan(optimal_num_clusters_combined, num_animals);
- state_neural_similarity_fMRI = nan(optimal_num_clusters_fMRI, num_animals);
- for k = 1:optimal_num_clusters_combined
- hemo_state = centroids_combined(k, :);
- for animal = 1:num_animals
- neural_dFC = neural_data((animal - 1) * num_windows_neural + (1:num_windows_neural), :);
- state_neural_similarity_combined(k, animal) = mean(corr(hemo_state', neural_dFC', 'Rows', 'pairwise'));
- end
- end
- for k = 1:optimal_num_clusters_fMRI
- hemo_state = centroids_fMRI(k, :);
- for animal = 1:num_animals
- neural_dFC = neural_data((animal - 1) * num_windows_neural + (1:num_windows_neural), :);
- state_neural_similarity_fMRI(k, animal) = mean(corr(hemo_state', neural_dFC', 'Rows', 'pairwise'));
- end
- end
- figure;
- subplot(2, 1, 1);
- imagesc(state_neural_similarity_combined);
- colorbar;
- colormap(cm_turbo_custom);
- clim([0.25 0.85]);
- title('Similarity between FL states and neural dFC windows');
- xlabel('Animal'); ylabel('FL state');
- subplot(2, 1, 2);
- imagesc(state_neural_similarity_fMRI);
- colorbar;
- colormap(cm_turbo_custom);
- clim([0.3 0.6]);
- title('Similarity between fMRI states and neural dFC windows');
- xlabel('Animal'); ylabel('fMRI state');
- add_jitter = @(values, scale) values + scale * (rand(size(values)) - 0.5);
- jitter_scale = 0.1;
- colors = lines(num_animals);
- figure('Position', [100, 100, 1000, 800]);
- subplot(2, 1, 1); hold on;
- for animal = 1:num_animals
- y_values = state_neural_similarity_combined(:, animal);
- x_values = 1:length(y_values);
- scatter(add_jitter(x_values, jitter_scale), y_values, 50, colors(animal, :), ...
- 'filled', 'DisplayName', sprintf('Animal %d', animal));
- end
- mean_values_combined = mean(state_neural_similarity_combined, 2, 'omitnan');
- for state = 1:length(mean_values_combined)
- plot([state - 0.4, state + 0.4], [mean_values_combined(state), mean_values_combined(state)], 'k-', 'LineWidth', 2);
- end
- title('FL state similarity to neural dFC windows');
- xlabel('FL state'); ylabel('Similarity'); legend('show', 'Location', 'eastoutside'); grid on; hold off;
- subplot(2, 1, 2); hold on;
- for animal = 1:num_animals
- y_values = state_neural_similarity_fMRI(:, animal);
- x_values = 1:length(y_values);
- scatter(add_jitter(x_values, jitter_scale), y_values, 50, colors(animal, :), ...
- 'filled', 'DisplayName', sprintf('Animal %d', animal));
- end
- mean_values_fMRI = mean(state_neural_similarity_fMRI, 2, 'omitnan');
- for state = 1:length(mean_values_fMRI)
- plot([state - 0.4, state + 0.4], [mean_values_fMRI(state), mean_values_fMRI(state)], 'k-', 'LineWidth', 2);
- end
- title('fMRI state similarity to neural dFC windows');
- xlabel('fMRI state'); ylabel('Similarity'); legend('show', 'Location', 'eastoutside'); grid on; hold off;
- %% Similarity between FL and fMRI state centroids
- similarity_fMRI_combined = corr(centroids_fMRI', centroids_combined', 'Rows', 'pairwise');
- similarity_fMRI_states = corr(centroids_fMRI', 'Rows', 'pairwise');
- similarity_FL_states = corr(centroids_combined', 'Rows', 'pairwise');
- figure;
- imagesc(similarity_fMRI_combined);
- colorbar;
- colormap(cm_turbo_custom);
- title('Similarity between fMRI states and FL states');
- xlabel('FL state'); ylabel('fMRI state');
- figure;
- imagesc(similarity_fMRI_states);
- colorbar;
- colormap(cm_turbo_custom_endWhite);
- caxis([0.65 0.9]);
- title('Similarity between fMRI states');
- xlabel('fMRI state'); ylabel('fMRI state');
- figure;
- imagesc(similarity_FL_states);
- colorbar;
- colormap(cm_turbo_custom_endWhite);
- caxis([0.6 0.96]);
- title('Similarity between FL states');
- xlabel('FL state'); ylabel('FL state');
- %% State distributions and transition matrices during CO2 on/off
- state_dist_10Hz_on = zeros(optimal_num_clusters_combined, num_animals);
- state_dist_10Hz_off = zeros(optimal_num_clusters_combined, num_animals);
- state_dist_1Hz_on = zeros(optimal_num_clusters_combined, num_animals);
- state_dist_1Hz_off = zeros(optimal_num_clusters_combined, num_animals);
- state_dist_fMRI_on = zeros(optimal_num_clusters_fMRI, num_animals);
- state_dist_fMRI_off = zeros(optimal_num_clusters_fMRI, num_animals);
- trans_mat_fMRI_on = zeros(optimal_num_clusters_fMRI, optimal_num_clusters_fMRI, num_animals);
- trans_mat_fMRI_off = zeros(optimal_num_clusters_fMRI, optimal_num_clusters_fMRI, num_animals);
- trans_mat_10Hz_on = zeros(optimal_num_clusters_combined, optimal_num_clusters_combined, num_animals);
- trans_mat_10Hz_off = zeros(optimal_num_clusters_combined, optimal_num_clusters_combined, num_animals);
- trans_mat_1Hz_on = zeros(optimal_num_clusters_combined, optimal_num_clusters_combined, num_animals);
- trans_mat_1Hz_off = zeros(optimal_num_clusters_combined, optimal_num_clusters_combined, num_animals);
- for animal = 1:num_animals
- [starts_10Hz, starts_1Hz, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- ends_10Hz = starts_10Hz + co2_duration;
- ends_1Hz = starts_1Hz + co2_duration;
- ends_fMRI = starts_fMRI + co2_duration;
- off_starts_fMRI = [1, ends_fMRI + window_size_fMRI / 2];
- off_ends_fMRI = [starts_fMRI - window_size_fMRI / 2, num_windows_fMRI];
- off_starts_10Hz = [1, ends_10Hz + window_size_10Hz / sampling_rate_10Hz / 2];
- off_ends_10Hz = [starts_10Hz - window_size_10Hz / sampling_rate_10Hz / 2, num_windows_10Hz];
- off_starts_1Hz = [1, ends_1Hz + window_size_1Hz / 2];
- off_ends_1Hz = [starts_1Hz - window_size_1Hz / 2, num_windows_1Hz];
- % CO2-on state counts and transitions
- for cycle = 1:length(starts_10Hz)
- state_dist_10Hz_on(:, animal) = state_dist_10Hz_on(:, animal) + count_states_in_range(idx_10Hz(:, animal), starts_10Hz(cycle), min(ends_10Hz(cycle), num_windows_10Hz), optimal_num_clusters_combined);
- state_dist_1Hz_on(:, animal) = state_dist_1Hz_on(:, animal) + count_states_in_range(idx_1Hz(:, animal), starts_1Hz(cycle), min(ends_1Hz(cycle), num_windows_1Hz), optimal_num_clusters_combined);
- state_dist_fMRI_on(:, animal) = state_dist_fMRI_on(:, animal) + count_states_in_range(idx_fMRI(:, animal), starts_fMRI(cycle), min(ends_fMRI(cycle), num_windows_fMRI), optimal_num_clusters_fMRI);
- trans_mat_10Hz_on(:, :, animal) = trans_mat_10Hz_on(:, :, animal) + count_transitions_in_range(idx_10Hz(:, animal), starts_10Hz(cycle), min(ends_10Hz(cycle), num_windows_10Hz), optimal_num_clusters_combined);
- trans_mat_1Hz_on(:, :, animal) = trans_mat_1Hz_on(:, :, animal) + count_transitions_in_range(idx_1Hz(:, animal), starts_1Hz(cycle), min(ends_1Hz(cycle), num_windows_1Hz), optimal_num_clusters_combined);
- trans_mat_fMRI_on(:, :, animal) = trans_mat_fMRI_on(:, :, animal) + count_transitions_in_range(idx_fMRI(:, animal), starts_fMRI(cycle), min(ends_fMRI(cycle), num_windows_fMRI), optimal_num_clusters_fMRI);
- end
- % CO2-off state counts and transitions
- for cycle = 1:length(off_starts_10Hz)
- state_dist_10Hz_off(:, animal) = state_dist_10Hz_off(:, animal) + count_states_in_range(idx_10Hz(:, animal), max(1, round(off_starts_10Hz(cycle))), min(round(off_ends_10Hz(cycle)), num_windows_10Hz), optimal_num_clusters_combined);
- state_dist_1Hz_off(:, animal) = state_dist_1Hz_off(:, animal) + count_states_in_range(idx_1Hz(:, animal), max(1, round(off_starts_1Hz(cycle))), min(round(off_ends_1Hz(cycle)), num_windows_1Hz), optimal_num_clusters_combined);
- state_dist_fMRI_off(:, animal) = state_dist_fMRI_off(:, animal) + count_states_in_range(idx_fMRI(:, animal), max(1, round(off_starts_fMRI(cycle))), min(round(off_ends_fMRI(cycle)), num_windows_fMRI), optimal_num_clusters_fMRI);
- trans_mat_10Hz_off(:, :, animal) = trans_mat_10Hz_off(:, :, animal) + count_transitions_in_range(idx_10Hz(:, animal), max(1, round(off_starts_10Hz(cycle))), min(round(off_ends_10Hz(cycle)), num_windows_10Hz), optimal_num_clusters_combined);
- trans_mat_1Hz_off(:, :, animal) = trans_mat_1Hz_off(:, :, animal) + count_transitions_in_range(idx_1Hz(:, animal), max(1, round(off_starts_1Hz(cycle))), min(round(off_ends_1Hz(cycle)), num_windows_1Hz), optimal_num_clusters_combined);
- trans_mat_fMRI_off(:, :, animal) = trans_mat_fMRI_off(:, :, animal) + count_transitions_in_range(idx_fMRI(:, animal), max(1, round(off_starts_fMRI(cycle))), min(round(off_ends_fMRI(cycle)), num_windows_fMRI), optimal_num_clusters_fMRI);
- end
- end
- % Normalize per animal
- state_dist_10Hz_on = normalize_columns(state_dist_10Hz_on);
- state_dist_10Hz_off = normalize_columns(state_dist_10Hz_off);
- state_dist_1Hz_on = normalize_columns(state_dist_1Hz_on);
- state_dist_1Hz_off = normalize_columns(state_dist_1Hz_off);
- state_dist_fMRI_on = normalize_columns(state_dist_fMRI_on);
- state_dist_fMRI_off = normalize_columns(state_dist_fMRI_off);
- mean_state_dist_10Hz_on = mean(state_dist_10Hz_on, 2, 'omitnan');
- mean_state_dist_10Hz_off = mean(state_dist_10Hz_off, 2, 'omitnan');
- mean_state_dist_1Hz_on = mean(state_dist_1Hz_on, 2, 'omitnan');
- mean_state_dist_1Hz_off = mean(state_dist_1Hz_off, 2, 'omitnan');
- mean_state_dist_fMRI_on = mean(state_dist_fMRI_on, 2, 'omitnan');
- mean_state_dist_fMRI_off = mean(state_dist_fMRI_off, 2, 'omitnan');
- sem_state_dist_10Hz_on = std(state_dist_10Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_state_dist_10Hz_off = std(state_dist_10Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_state_dist_1Hz_on = std(state_dist_1Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_state_dist_1Hz_off = std(state_dist_1Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_state_dist_fMRI_on = std(state_dist_fMRI_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_state_dist_fMRI_off = std(state_dist_fMRI_off, 0, 2, 'omitnan') / sqrt(num_animals);
- p_values_state_10Hz = nan(optimal_num_clusters_combined, 1);
- p_values_state_1Hz = nan(optimal_num_clusters_combined, 1);
- p_values_state_fMRI = nan(optimal_num_clusters_fMRI, 1);
- for i = 1:optimal_num_clusters_combined
- p_values_state_10Hz(i) = safe_paired_ttest(state_dist_10Hz_on(i, :), state_dist_10Hz_off(i, :));
- p_values_state_1Hz(i) = safe_paired_ttest(state_dist_1Hz_on(i, :), state_dist_1Hz_off(i, :));
- end
- for i = 1:optimal_num_clusters_fMRI
- p_values_state_fMRI(i) = safe_paired_ttest(state_dist_fMRI_on(i, :), state_dist_fMRI_off(i, :));
- end
- fprintf('P-values for state distributions - FL 10 Hz:\n'); disp(p_values_state_10Hz);
- fprintf('P-values for state distributions - FL 1 Hz:\n'); disp(p_values_state_1Hz);
- fprintf('P-values for state distributions - fMRI:\n'); disp(p_values_state_fMRI);
- figure('Position', [0 0 400 900]);
- plot_grouped_bars_with_paired_points(3, 1, 1, mean_state_dist_10Hz_on, mean_state_dist_10Hz_off, sem_state_dist_10Hz_on, sem_state_dist_10Hz_off, state_dist_10Hz_on, state_dist_10Hz_off, 'State Distribution - FL 10 Hz', 'Proportion', 1:optimal_num_clusters_combined, [0 0.68]);
- plot_grouped_bars_with_paired_points(3, 1, 2, mean_state_dist_1Hz_on, mean_state_dist_1Hz_off, sem_state_dist_1Hz_on, sem_state_dist_1Hz_off, state_dist_1Hz_on, state_dist_1Hz_off, 'State Distribution - FL 1 Hz', 'Proportion', 1:optimal_num_clusters_combined, [0 0.38]);
- plot_grouped_bars_with_paired_points(3, 1, 3, mean_state_dist_fMRI_on, mean_state_dist_fMRI_off, sem_state_dist_fMRI_on, sem_state_dist_fMRI_off, state_dist_fMRI_on, state_dist_fMRI_off, 'State Distribution - fMRI', 'Proportion', 1:optimal_num_clusters_fMRI, [0 0.83]);
- sgtitle('State distributions for FL 10 Hz, FL 1 Hz, and fMRI (CO2 on/off)');
- %% Transition probability matrices
- trans_matrix_10Hz = trans_mat_10Hz_on + trans_mat_10Hz_off;
- trans_matrix_1Hz = trans_mat_1Hz_on + trans_mat_1Hz_off;
- trans_matrix_fMRI = trans_mat_fMRI_on + trans_mat_fMRI_off;
- trans_prob_10Hz = normalize_transition_tensor(trans_matrix_10Hz);
- trans_prob_10Hz_on = normalize_transition_tensor(trans_mat_10Hz_on);
- trans_prob_10Hz_off = normalize_transition_tensor(trans_mat_10Hz_off);
- trans_prob_1Hz = normalize_transition_tensor(trans_matrix_1Hz);
- trans_prob_1Hz_on = normalize_transition_tensor(trans_mat_1Hz_on);
- trans_prob_1Hz_off = normalize_transition_tensor(trans_mat_1Hz_off);
- trans_prob_fMRI = normalize_transition_tensor(trans_matrix_fMRI);
- trans_prob_fMRI_on = normalize_transition_tensor(trans_mat_fMRI_on);
- trans_prob_fMRI_off = normalize_transition_tensor(trans_mat_fMRI_off);
- avg_trans_mat_10Hz_on = mean(trans_prob_10Hz_on, 3, 'omitnan');
- avg_trans_mat_10Hz_off = mean(trans_prob_10Hz_off, 3, 'omitnan');
- avg_trans_mat_1Hz_on = mean(trans_prob_1Hz_on, 3, 'omitnan');
- avg_trans_mat_1Hz_off = mean(trans_prob_1Hz_off, 3, 'omitnan');
- avg_trans_mat_fMRI_on = mean(trans_prob_fMRI_on, 3, 'omitnan');
- avg_trans_mat_fMRI_off = mean(trans_prob_fMRI_off, 3, 'omitnan');
- p_values_trans_10Hz = nan(optimal_num_clusters_combined, optimal_num_clusters_combined);
- p_values_trans_1Hz = nan(optimal_num_clusters_combined, optimal_num_clusters_combined);
- p_values_trans_fMRI = nan(optimal_num_clusters_fMRI, optimal_num_clusters_fMRI);
- for i = 1:optimal_num_clusters_combined
- for j = 1:optimal_num_clusters_combined
- p_values_trans_10Hz(i, j) = safe_paired_ttest(squeeze(trans_prob_10Hz_on(i, j, :)), squeeze(trans_prob_10Hz_off(i, j, :)));
- p_values_trans_1Hz(i, j) = safe_paired_ttest(squeeze(trans_prob_1Hz_on(i, j, :)), squeeze(trans_prob_1Hz_off(i, j, :)));
- end
- end
- for i = 1:optimal_num_clusters_fMRI
- for j = 1:optimal_num_clusters_fMRI
- p_values_trans_fMRI(i, j) = safe_paired_ttest(squeeze(trans_prob_fMRI_on(i, j, :)), squeeze(trans_prob_fMRI_off(i, j, :)));
- end
- end
- fprintf('P-values for transition probabilities - FL 10 Hz:\n'); disp(p_values_trans_10Hz);
- fprintf('P-values for transition probabilities - FL 1 Hz:\n'); disp(p_values_trans_1Hz);
- fprintf('P-values for transition probabilities - fMRI:\n'); disp(p_values_trans_fMRI);
- figure;
- threshold_transition = 0.05;
- plot_transition_matrix_with_sig(3, 2, 1, avg_trans_mat_10Hz_on, p_values_trans_10Hz, threshold_transition, 'Average Transition Matrix - FL 10 Hz (CO2 On)', 'Next State', 'Current State', [-0.01 0.9], cm_custom_blueToRed);
- plot_transition_matrix_with_sig(3, 2, 2, avg_trans_mat_10Hz_off, p_values_trans_10Hz, threshold_transition, 'Average Transition Matrix - FL 10 Hz (CO2 Off)', 'Next State', 'Current State', [-0.01 0.9], cm_custom_blueToRed);
- plot_transition_matrix_with_sig(3, 2, 3, avg_trans_mat_1Hz_on, p_values_trans_1Hz, threshold_transition, 'Average Transition Matrix - FL 1 Hz (CO2 On)', 'Next State', 'Current State', [-0.01 0.9], cm_custom_blueToRed);
- plot_transition_matrix_with_sig(3, 2, 4, avg_trans_mat_1Hz_off, p_values_trans_1Hz, threshold_transition, 'Average Transition Matrix - FL 1 Hz (CO2 Off)', 'Next State', 'Current State', [-0.01 0.9], cm_custom_blueToRed);
- plot_transition_matrix_with_sig(3, 2, 5, avg_trans_mat_fMRI_on, p_values_trans_fMRI, threshold_transition, 'Average Transition Matrix - fMRI (CO2 On)', 'Next State', 'Current State', [-0.02 0.9], cm_custom_blueToRed);
- plot_transition_matrix_with_sig(3, 2, 6, avg_trans_mat_fMRI_off, p_values_trans_fMRI, threshold_transition, 'Average Transition Matrix - fMRI (CO2 Off)', 'Next State', 'Current State', [-0.02 0.9], cm_custom_blueToRed);
- sgtitle('Average transition matrices for FL 10 Hz, FL 1 Hz, and fMRI (CO2 on/off)');
- %% Joint FL-fMRI state distributions (overall)
- count_10Hz_fMRI = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- count_1Hz_fMRI = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- count_fMRI_10Hz = zeros(optimal_num_clusters_fMRI, optimal_num_clusters_combined);
- count_fMRI_1Hz = zeros(optimal_num_clusters_fMRI, optimal_num_clusters_combined);
- for animal = 1:num_animals
- for t = 1:num_windows_fMRI
- f_state = idx_fMRI(t, animal);
- if t <= num_windows_10Hz
- fl10_state = idx_10Hz(t, animal);
- count_10Hz_fMRI(fl10_state, f_state) = count_10Hz_fMRI(fl10_state, f_state) + 1;
- end
- if t <= num_windows_1Hz
- fl1_state = idx_1Hz(t, animal);
- count_1Hz_fMRI(fl1_state, f_state) = count_1Hz_fMRI(fl1_state, f_state) + 1;
- end
- end
- for t = 1:num_windows_10Hz
- fl10_state = idx_10Hz(t, animal);
- if t <= num_windows_fMRI
- f_state = idx_fMRI(t, animal);
- count_fMRI_10Hz(f_state, fl10_state) = count_fMRI_10Hz(f_state, fl10_state) + 1;
- end
- end
- for t = 1:num_windows_1Hz
- fl1_state = idx_1Hz(t, animal);
- if t <= num_windows_fMRI
- f_state = idx_fMRI(t, animal);
- count_fMRI_1Hz(f_state, fl1_state) = count_fMRI_1Hz(f_state, fl1_state) + 1;
- end
- end
- end
- percent_10Hz_fMRI = safe_percent_by_column(count_10Hz_fMRI);
- percent_1Hz_fMRI = safe_percent_by_column(count_1Hz_fMRI);
- percent_fMRI_10Hz = safe_percent_by_column(count_fMRI_10Hz);
- percent_fMRI_1Hz = safe_percent_by_column(count_fMRI_1Hz);
- ulim = 40;
- figure;
- subplot(1, 2, 1); imagesc(percent_10Hz_fMRI); colorbar; axis square; colormap(cm_turbo_custom); caxis([0 ulim]); title('Percentage distribution of 10 Hz FL states by fMRI state'); xlabel('fMRI State'); ylabel('10 Hz FL State');
- subplot(1, 2, 2); imagesc(percent_1Hz_fMRI); colorbar; axis square; colormap(cm_turbo_custom); caxis([0 ulim]); title('Percentage distribution of 1 Hz FL states by fMRI state'); xlabel('fMRI State'); ylabel('1 Hz FL State');
- figure;
- subplot(1, 2, 1); imagesc(percent_fMRI_10Hz); colorbar; axis square; colormap(cm_turbo_custom); caxis([0 ulim]); title('Percentage distribution of fMRI states by 10 Hz FL state'); xlabel('10 Hz FL State'); ylabel('fMRI State');
- subplot(1, 2, 2); imagesc(percent_fMRI_1Hz); colorbar; axis square; colormap(cm_turbo_custom); caxis([0 ulim]); title('Percentage distribution of fMRI states by 1 Hz FL state'); xlabel('1 Hz FL State'); ylabel('fMRI State');
- %% Joint FL-fMRI state distributions by CO2 condition (10 Hz FL, fMRI)
- count_10Hz_fMRI_on = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI, num_animals);
- count_10Hz_fMRI_off = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI, num_animals);
- count_fMRI_10Hz_on = zeros(optimal_num_clusters_fMRI, optimal_num_clusters_combined, num_animals);
- count_fMRI_10Hz_off = zeros(optimal_num_clusters_fMRI, optimal_num_clusters_combined, num_animals);
- for animal = 1:num_animals
- [starts_10Hz, ~, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- timing_info_fMRI = build_timing_mask(num_windows_fMRI, starts_fMRI, starts_fMRI + co2_duration);
- timing_info_10Hz = build_timing_mask(num_windows_10Hz, starts_10Hz, starts_10Hz + co2_duration);
- for t = 1:num_windows_fMRI
- f_state = idx_fMRI(t, animal);
- if t <= num_windows_10Hz
- fl_state = idx_10Hz(t, animal);
- if timing_info_10Hz(t)
- count_10Hz_fMRI_on(fl_state, f_state, animal) = count_10Hz_fMRI_on(fl_state, f_state, animal) + 1;
- else
- count_10Hz_fMRI_off(fl_state, f_state, animal) = count_10Hz_fMRI_off(fl_state, f_state, animal) + 1;
- end
- end
- end
- for t = 1:num_windows_10Hz
- fl_state = idx_10Hz(t, animal);
- if t <= num_windows_fMRI
- f_state = idx_fMRI(t, animal);
- if timing_info_fMRI(t)
- count_fMRI_10Hz_on(f_state, fl_state, animal) = count_fMRI_10Hz_on(f_state, fl_state, animal) + 1;
- else
- count_fMRI_10Hz_off(f_state, fl_state, animal) = count_fMRI_10Hz_off(f_state, fl_state, animal) + 1;
- end
- end
- end
- end
- total_count_10Hz_fMRI_on = sum(count_10Hz_fMRI_on, 3);
- total_count_10Hz_fMRI_off = sum(count_10Hz_fMRI_off, 3);
- total_count_fMRI_10Hz_on = sum(count_fMRI_10Hz_on, 3);
- total_count_fMRI_10Hz_off = sum(count_fMRI_10Hz_off, 3);
- percent_10Hz_fMRI_on = safe_percent_by_column(total_count_10Hz_fMRI_on);
- percent_10Hz_fMRI_off = safe_percent_by_column(total_count_10Hz_fMRI_off);
- percent_fMRI_10Hz_on = safe_percent_by_column(total_count_fMRI_10Hz_on);
- percent_fMRI_10Hz_off = safe_percent_by_column(total_count_fMRI_10Hz_off);
- p_values_10Hz_fMRI = nan(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- p_values_fMRI_10Hz = nan(optimal_num_clusters_fMRI, optimal_num_clusters_combined);
- for i = 1:optimal_num_clusters_combined
- for j = 1:optimal_num_clusters_fMRI
- p_values_10Hz_fMRI(i, j) = safe_paired_ttest(squeeze(count_10Hz_fMRI_on(i, j, :)), squeeze(count_10Hz_fMRI_off(i, j, :)));
- end
- end
- for i = 1:optimal_num_clusters_fMRI
- for j = 1:optimal_num_clusters_combined
- p_values_fMRI_10Hz(i, j) = safe_paired_ttest(squeeze(count_fMRI_10Hz_on(i, j, :)), squeeze(count_fMRI_10Hz_off(i, j, :)));
- end
- end
- fprintf('P-values for joint state distributions - 10 Hz FL to fMRI:\n'); disp(p_values_10Hz_fMRI);
- fprintf('P-values for joint state distributions - fMRI to 10 Hz FL:\n'); disp(p_values_fMRI_10Hz);
- figure;
- threshold_joint = 0.05;
- ulim = 50;
- plot_matrix_with_sig(2, 2, 1, percent_10Hz_fMRI_on, p_values_10Hz_fMRI, threshold_joint, 'Percentage Distribution - 10 Hz FL to fMRI (CO2 On)', 'fMRI State', '10 Hz FL State', [0 ulim], cm_custom_blue2red_2);
- plot_matrix_with_sig(2, 2, 2, percent_10Hz_fMRI_off, p_values_10Hz_fMRI, threshold_joint, 'Percentage Distribution - 10 Hz FL to fMRI (CO2 Off)', 'fMRI State', '10 Hz FL State', [0 ulim], cm_custom_blue2red_2);
- plot_matrix_with_sig(2, 2, 3, percent_fMRI_10Hz_on, p_values_fMRI_10Hz, threshold_joint, 'Percentage Distribution - fMRI to 10 Hz FL (CO2 On)', '10 Hz FL State', 'fMRI State', [0 ulim], cm_custom_blue2red_2);
- plot_matrix_with_sig(2, 2, 4, percent_fMRI_10Hz_off, p_values_fMRI_10Hz, threshold_joint, 'Percentage Distribution - fMRI to 10 Hz FL (CO2 Off)', '10 Hz FL State', 'fMRI State', [0 ulim], cm_custom_blue2red_2);
- sgtitle('Percentage distributions for FL and fMRI states during CO2 on/off');
- %% Joint transition probabilities: FL to fMRI (1 Hz and 10 Hz), overall and by CO2
- joint_transitions_10Hz_fMRI = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- joint_transitions_1Hz_fMRI = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- for animal = 1:num_animals
- for t = 1:(min(num_windows_10Hz, num_windows_fMRI) - 1)
- joint_transitions_10Hz_fMRI(idx_10Hz(t, animal), idx_fMRI(t, animal)) = joint_transitions_10Hz_fMRI(idx_10Hz(t, animal), idx_fMRI(t, animal)) + 1;
- end
- for t = 1:(min(num_windows_1Hz, num_windows_fMRI) - 1)
- joint_transitions_1Hz_fMRI(idx_1Hz(t, animal), idx_fMRI(t, animal)) = joint_transitions_1Hz_fMRI(idx_1Hz(t, animal), idx_fMRI(t, animal)) + 1;
- end
- end
- joint_trans_prob_10Hz_fMRI = normalize_rows_2d(joint_transitions_10Hz_fMRI);
- joint_trans_prob_1Hz_fMRI = normalize_rows_2d(joint_transitions_1Hz_fMRI);
- figure;
- subplot(1, 2, 1); imagesc(joint_trans_prob_10Hz_fMRI); colorbar; colormap(cm_turbo_custom); caxis([0 0.5]); title('Joint transition probabilities - 10 Hz FL to fMRI'); xlabel('fMRI State'); ylabel('10 Hz FL State');
- subplot(1, 2, 2); imagesc(joint_trans_prob_1Hz_fMRI); colorbar; colormap(cm_turbo_custom); caxis([0 0.5]); title('Joint transition probabilities - 1 Hz FL to fMRI'); xlabel('fMRI State'); ylabel('1 Hz FL State');
- joint_trans_prob_10Hz_fMRI_on = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI, num_animals);
- joint_trans_prob_10Hz_fMRI_off = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI, num_animals);
- joint_trans_prob_1Hz_fMRI_on = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI, num_animals);
- joint_trans_prob_1Hz_fMRI_off = zeros(optimal_num_clusters_combined, optimal_num_clusters_fMRI, num_animals);
- for animal = 1:num_animals
- [~, ~, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- ends_fMRI = starts_fMRI + co2_on_duration_fMRI;
- for t = 1:(min(num_windows_10Hz, num_windows_fMRI) - 1)
- current_state_10Hz = idx_10Hz(t, animal);
- next_state_fMRI = idx_fMRI(t + 1, animal);
- if current_state_10Hz > 0 && next_state_fMRI > 0
- if any(t >= starts_fMRI & t <= ends_fMRI)
- joint_trans_prob_10Hz_fMRI_on(current_state_10Hz, next_state_fMRI, animal) = joint_trans_prob_10Hz_fMRI_on(current_state_10Hz, next_state_fMRI, animal) + 1;
- else
- joint_trans_prob_10Hz_fMRI_off(current_state_10Hz, next_state_fMRI, animal) = joint_trans_prob_10Hz_fMRI_off(current_state_10Hz, next_state_fMRI, animal) + 1;
- end
- end
- end
- for t = 1:(min(num_windows_1Hz, num_windows_fMRI) - 1)
- current_state_1Hz = idx_1Hz(t, animal);
- next_state_fMRI = idx_fMRI(t + 1, animal);
- if current_state_1Hz > 0 && next_state_fMRI > 0
- if any(t >= starts_fMRI & t <= ends_fMRI)
- joint_trans_prob_1Hz_fMRI_on(current_state_1Hz, next_state_fMRI, animal) = joint_trans_prob_1Hz_fMRI_on(current_state_1Hz, next_state_fMRI, animal) + 1;
- else
- joint_trans_prob_1Hz_fMRI_off(current_state_1Hz, next_state_fMRI, animal) = joint_trans_prob_1Hz_fMRI_off(current_state_1Hz, next_state_fMRI, animal) + 1;
- end
- end
- end
- end
- joint_trans_prob_10Hz_fMRI_on = normalize_transition_tensor(joint_trans_prob_10Hz_fMRI_on);
- joint_trans_prob_10Hz_fMRI_off = normalize_transition_tensor(joint_trans_prob_10Hz_fMRI_off);
- joint_trans_prob_1Hz_fMRI_on = normalize_transition_tensor(joint_trans_prob_1Hz_fMRI_on);
- joint_trans_prob_1Hz_fMRI_off = normalize_transition_tensor(joint_trans_prob_1Hz_fMRI_off);
- p_values_joint_10Hz_fMRI = nan(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- p_values_joint_1Hz_fMRI = nan(optimal_num_clusters_combined, optimal_num_clusters_fMRI);
- for i = 1:optimal_num_clusters_combined
- for j = 1:optimal_num_clusters_fMRI
- p_values_joint_10Hz_fMRI(i, j) = safe_paired_ttest(squeeze(joint_trans_prob_10Hz_fMRI_on(i, j, :)), squeeze(joint_trans_prob_10Hz_fMRI_off(i, j, :)));
- p_values_joint_1Hz_fMRI(i, j) = safe_paired_ttest(squeeze(joint_trans_prob_1Hz_fMRI_on(i, j, :)), squeeze(joint_trans_prob_1Hz_fMRI_off(i, j, :)));
- end
- end
- fprintf('P-values for joint transition probabilities - 10 Hz FL to fMRI:\n'); disp(p_values_joint_10Hz_fMRI);
- fprintf('P-values for joint transition probabilities - 1 Hz FL to fMRI:\n'); disp(p_values_joint_1Hz_fMRI);
- figure;
- threshold_joint_trans = 0.1;
- plot_matrix_with_sig(2, 2, 1, mean(joint_trans_prob_10Hz_fMRI_on, 3, 'omitnan'), p_values_joint_10Hz_fMRI, threshold_joint_trans, 'Joint Transition Probabilities - 10 Hz FL to fMRI (CO2 On)', 'fMRI State', '10 Hz FL State', [0 0.5], cm_turbo_custom);
- plot_matrix_with_sig(2, 2, 2, mean(joint_trans_prob_10Hz_fMRI_off, 3, 'omitnan'), p_values_joint_10Hz_fMRI, threshold_joint_trans, 'Joint Transition Probabilities - 10 Hz FL to fMRI (CO2 Off)', 'fMRI State', '10 Hz FL State', [0 0.5], cm_turbo_custom);
- plot_matrix_with_sig(2, 2, 3, mean(joint_trans_prob_1Hz_fMRI_on, 3, 'omitnan'), p_values_joint_1Hz_fMRI, threshold_joint_trans, 'Joint Transition Probabilities - 1 Hz FL to fMRI (CO2 On)', 'fMRI State', '1 Hz FL State', [0 0.5], cm_turbo_custom);
- plot_matrix_with_sig(2, 2, 4, mean(joint_trans_prob_1Hz_fMRI_off, 3, 'omitnan'), p_values_joint_1Hz_fMRI, threshold_joint_trans, 'Joint Transition Probabilities - 1 Hz FL to fMRI (CO2 Off)', 'fMRI State', '1 Hz FL State', [0 0.5], cm_turbo_custom);
- sgtitle('Joint transition probabilities for FL to fMRI (CO2 on/off)');
- %% Similarity between FL and fMRI dFC matrices over time
- similarity_10Hz_fMRI = nan(num_windows_fMRI, num_animals);
- similarity_1Hz_fMRI = nan(num_windows_fMRI, num_animals);
- dFC_10Hz_reshaped = reshape(dFC_10Hz, num_regions * num_regions, num_windows_10Hz, num_animals);
- dFC_1Hz_reshaped = reshape(dFC_1Hz, num_regions * num_regions, num_windows_1Hz, num_animals);
- dFC_fMRI_reshaped = reshape(dFC_fMRI, num_regions * num_regions, num_windows_fMRI, num_animals);
- for animal = 1:num_animals
- for t = 1:num_windows_fMRI
- start_time_fMRI = (t - 1) * step_size_fMRI + 1;
- start_time_10Hz = round(start_time_fMRI / (step_size_10Hz / 10)) - 4;
- end_time_10Hz = start_time_10Hz + 5;
- if start_time_10Hz > 0 && end_time_10Hz <= num_windows_10Hz
- avg_dFC_10Hz = mean(dFC_10Hz_reshaped(:, start_time_10Hz:end_time_10Hz, animal), 2);
- similarity_10Hz_fMRI(t, animal) = corr(avg_dFC_10Hz, dFC_fMRI_reshaped(:, t, animal), 'Rows', 'pairwise');
- end
- t_1Hz = round(((t - 1) * step_size_fMRI) / step_size_1Hz) + 1;
- if t_1Hz > 0 && t_1Hz <= num_windows_1Hz
- similarity_1Hz_fMRI(t, animal) = corr(dFC_1Hz_reshaped(:, t_1Hz, animal), dFC_fMRI_reshaped(:, t, animal), 'Rows', 'pairwise');
- end
- end
- end
- similarity_10Hz_fMRI_on = [];
- similarity_10Hz_fMRI_off = [];
- similarity_1Hz_fMRI_on = [];
- similarity_1Hz_fMRI_off = [];
- cc = 30;
- for animal = 1:num_animals
- [starts_10Hz, starts_1Hz, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- ends_10Hz = starts_10Hz + co2_duration;
- ends_1Hz = starts_1Hz + co2_duration;
- ends_fMRI = starts_fMRI + co2_duration;
- off_starts_fMRI = [1, ends_fMRI + window_size_fMRI / 2];
- off_ends_fMRI = [starts_fMRI - window_size_fMRI / 2, num_windows_fMRI];
- off_starts_10Hz = [1, ends_10Hz + window_size_10Hz / sampling_rate_10Hz / 2];
- off_ends_10Hz = [starts_10Hz - window_size_10Hz / sampling_rate_10Hz / 2, num_windows_10Hz];
- for cycle = 1:length(starts_10Hz)
- for t = (starts_10Hz(cycle) + cc):min(ends_10Hz(cycle), num_windows_fMRI) - cc
- if t > 0 && t <= num_windows_10Hz
- similarity_10Hz_fMRI_on = [similarity_10Hz_fMRI_on; similarity_10Hz_fMRI(t, animal)]; %#ok<AGROW>
- end
- if t > 0 && t <= num_windows_1Hz
- similarity_1Hz_fMRI_on = [similarity_1Hz_fMRI_on; similarity_1Hz_fMRI(t, animal)]; %#ok<AGROW>
- end
- end
- end
- for cycle = 1:length(off_starts_10Hz)
- for t = max(1, round(off_starts_10Hz(cycle))) + cc : round(off_ends_10Hz(cycle)) - cc
- if t > 0 && t <= num_windows_10Hz
- similarity_10Hz_fMRI_off = [similarity_10Hz_fMRI_off; similarity_10Hz_fMRI(t, animal)]; %#ok<AGROW>
- end
- if t > 0 && t <= num_windows_1Hz
- similarity_1Hz_fMRI_off = [similarity_1Hz_fMRI_off; similarity_1Hz_fMRI(t, animal)]; %#ok<AGROW>
- end
- end
- end
- end
- llim = 10;
- ulim = 90;
- similarity_1Hz_fMRI_on_filtered = percentile_filter(similarity_1Hz_fMRI_on, llim, ulim);
- similarity_1Hz_fMRI_off_filtered = percentile_filter(similarity_1Hz_fMRI_off, llim, ulim);
- similarity_10Hz_fMRI_on_filtered = percentile_filter(similarity_10Hz_fMRI_on, llim, ulim);
- similarity_10Hz_fMRI_off_filtered = percentile_filter(similarity_10Hz_fMRI_off, llim, ulim);
- figure;
- subplot(1, 2, 1);
- plot_distribution_comparison(similarity_1Hz_fMRI_on_filtered, similarity_1Hz_fMRI_off_filtered, '1 Hz similarity');
- subplot(1, 2, 2);
- plot_distribution_comparison(similarity_10Hz_fMRI_on_filtered, similarity_10Hz_fMRI_off_filtered, '10 Hz similarity');
- [~, p_10Hz] = ttest2(similarity_10Hz_fMRI_on_filtered, similarity_10Hz_fMRI_off_filtered);
- [~, p_1Hz] = ttest2(similarity_1Hz_fMRI_on_filtered, similarity_1Hz_fMRI_off_filtered);
- effect_1Hz = cohens_d_two_sample(similarity_1Hz_fMRI_on_filtered, similarity_1Hz_fMRI_off_filtered);
- effect_10Hz = cohens_d_two_sample(similarity_10Hz_fMRI_on_filtered, similarity_10Hz_fMRI_off_filtered);
- fprintf('P-value for similarity comparison (10 Hz FL): %.6f\n', p_10Hz);
- fprintf('P-value for similarity comparison (1 Hz FL): %.6f\n', p_1Hz);
- fprintf('Cohen''s d for similarity comparison (10 Hz FL): %.6f\n', effect_10Hz);
- fprintf('Cohen''s d for similarity comparison (1 Hz FL): %.6f\n', effect_1Hz);
- %% Dwell times during CO2 on/off
- [dwell_times_10Hz_on, dwell_times_10Hz_off] = deal(nan(optimal_num_clusters_combined, num_animals));
- [dwell_times_1Hz_on, dwell_times_1Hz_off] = deal(nan(optimal_num_clusters_combined, num_animals));
- [dwell_times_fMRI_on, dwell_times_fMRI_off] = deal(nan(optimal_num_clusters_fMRI, num_animals));
- for animal = 1:num_animals
- [starts_10Hz, starts_1Hz, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- timing_info_10Hz = build_timing_mask(num_windows_10Hz, starts_10Hz, starts_10Hz + co2_duration);
- timing_info_1Hz = build_timing_mask(num_windows_1Hz, starts_1Hz, starts_1Hz + co2_duration);
- timing_info_fMRI = build_timing_mask(num_windows_fMRI, starts_fMRI, starts_fMRI + co2_duration);
- dwell_times_10Hz_on(:, animal) = calculate_dwell_times(idx_10Hz(:, animal), timing_info_10Hz, optimal_num_clusters_combined);
- dwell_times_10Hz_off(:, animal) = calculate_dwell_times(idx_10Hz(:, animal), ~timing_info_10Hz, optimal_num_clusters_combined);
- dwell_times_1Hz_on(:, animal) = calculate_dwell_times(idx_1Hz(:, animal), timing_info_1Hz, optimal_num_clusters_combined);
- dwell_times_1Hz_off(:, animal) = calculate_dwell_times(idx_1Hz(:, animal), ~timing_info_1Hz, optimal_num_clusters_combined);
- dwell_times_fMRI_on(:, animal) = calculate_dwell_times(idx_fMRI(:, animal), timing_info_fMRI, optimal_num_clusters_fMRI);
- dwell_times_fMRI_off(:, animal) = calculate_dwell_times(idx_fMRI(:, animal), ~timing_info_fMRI, optimal_num_clusters_fMRI);
- end
- p_values_dwell_10Hz = nan(optimal_num_clusters_combined, 1);
- p_values_dwell_1Hz = nan(optimal_num_clusters_combined, 1);
- p_values_dwell_fMRI = nan(optimal_num_clusters_fMRI, 1);
- for i = 1:optimal_num_clusters_combined
- p_values_dwell_10Hz(i) = safe_paired_ttest(dwell_times_10Hz_on(i, :), dwell_times_10Hz_off(i, :));
- p_values_dwell_1Hz(i) = safe_paired_ttest(dwell_times_1Hz_on(i, :), dwell_times_1Hz_off(i, :));
- end
- for i = 1:optimal_num_clusters_fMRI
- p_values_dwell_fMRI(i) = safe_paired_ttest(dwell_times_fMRI_on(i, :), dwell_times_fMRI_off(i, :));
- end
- fprintf('P-values for dwell times - FL 10 Hz:\n'); disp(p_values_dwell_10Hz);
- fprintf('P-values for dwell times - FL 1 Hz:\n'); disp(p_values_dwell_1Hz);
- fprintf('P-values for dwell times - fMRI:\n'); disp(p_values_dwell_fMRI);
- mean_dwell_times_10Hz_on = mean(dwell_times_10Hz_on, 2, 'omitnan');
- mean_dwell_times_10Hz_off = mean(dwell_times_10Hz_off, 2, 'omitnan');
- mean_dwell_times_1Hz_on = mean(dwell_times_1Hz_on, 2, 'omitnan');
- mean_dwell_times_1Hz_off = mean(dwell_times_1Hz_off, 2, 'omitnan');
- mean_dwell_times_fMRI_on = mean(dwell_times_fMRI_on, 2, 'omitnan');
- mean_dwell_times_fMRI_off = mean(dwell_times_fMRI_off, 2, 'omitnan');
- sem_dwell_times_10Hz_on = std(dwell_times_10Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_dwell_times_10Hz_off = std(dwell_times_10Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_dwell_times_1Hz_on = std(dwell_times_1Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_dwell_times_1Hz_off = std(dwell_times_1Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_dwell_times_fMRI_on = std(dwell_times_fMRI_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_dwell_times_fMRI_off = std(dwell_times_fMRI_off, 0, 2, 'omitnan') / sqrt(num_animals);
- figure('Position', [0 0 400 900]);
- plot_grouped_bars_with_paired_points(3, 1, 1, mean_dwell_times_10Hz_on, mean_dwell_times_10Hz_off, sem_dwell_times_10Hz_on, sem_dwell_times_10Hz_off, dwell_times_10Hz_on, dwell_times_10Hz_off, 'Dwell Times - FL 10 Hz', 'Time (windows)', 1:optimal_num_clusters_combined, []);
- plot_grouped_bars_with_paired_points(3, 1, 2, mean_dwell_times_1Hz_on, mean_dwell_times_1Hz_off, sem_dwell_times_1Hz_on, sem_dwell_times_1Hz_off, dwell_times_1Hz_on, dwell_times_1Hz_off, 'Dwell Times - FL 1 Hz', 'Time (windows)', 1:optimal_num_clusters_combined, []);
- plot_grouped_bars_with_paired_points(3, 1, 3, mean_dwell_times_fMRI_on, mean_dwell_times_fMRI_off, sem_dwell_times_fMRI_on, sem_dwell_times_fMRI_off, dwell_times_fMRI_on, dwell_times_fMRI_off, 'Dwell Times - fMRI', 'Time (windows)', 1:optimal_num_clusters_fMRI, []);
- sgtitle('Dwell times for FL 10 Hz, FL 1 Hz, and fMRI (CO2 on/off)');
- %% Entry and exit rates during CO2 on/off
- [entry_rate_10Hz_on, entry_rate_10Hz_off] = deal(nan(optimal_num_clusters_combined, num_animals));
- [entry_rate_1Hz_on, entry_rate_1Hz_off] = deal(nan(optimal_num_clusters_combined, num_animals));
- [entry_rate_fMRI_on, entry_rate_fMRI_off] = deal(nan(optimal_num_clusters_fMRI, num_animals));
- [exit_rate_10Hz_on, exit_rate_10Hz_off] = deal(nan(optimal_num_clusters_combined, num_animals));
- [exit_rate_1Hz_on, exit_rate_1Hz_off] = deal(nan(optimal_num_clusters_combined, num_animals));
- [exit_rate_fMRI_on, exit_rate_fMRI_off] = deal(nan(optimal_num_clusters_fMRI, num_animals));
- for animal = 1:num_animals
- [starts_10Hz, starts_1Hz, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- timing_info_10Hz = build_timing_mask(num_windows_10Hz, starts_10Hz, starts_10Hz + co2_duration);
- timing_info_1Hz = build_timing_mask(num_windows_1Hz, starts_1Hz, starts_1Hz + co2_duration);
- timing_info_fMRI = build_timing_mask(num_windows_fMRI, starts_fMRI, starts_fMRI + co2_duration);
- entry_rate_10Hz_on(:, animal) = calculate_entry_rates(idx_10Hz(:, animal), timing_info_10Hz, optimal_num_clusters_combined);
- entry_rate_10Hz_off(:, animal) = calculate_entry_rates(idx_10Hz(:, animal), ~timing_info_10Hz, optimal_num_clusters_combined);
- exit_rate_10Hz_on(:, animal) = calculate_exit_rates(idx_10Hz(:, animal), timing_info_10Hz, optimal_num_clusters_combined);
- exit_rate_10Hz_off(:, animal) = calculate_exit_rates(idx_10Hz(:, animal), ~timing_info_10Hz, optimal_num_clusters_combined);
- entry_rate_1Hz_on(:, animal) = calculate_entry_rates(idx_1Hz(:, animal), timing_info_1Hz, optimal_num_clusters_combined);
- entry_rate_1Hz_off(:, animal) = calculate_entry_rates(idx_1Hz(:, animal), ~timing_info_1Hz, optimal_num_clusters_combined);
- exit_rate_1Hz_on(:, animal) = calculate_exit_rates(idx_1Hz(:, animal), timing_info_1Hz, optimal_num_clusters_combined);
- exit_rate_1Hz_off(:, animal) = calculate_exit_rates(idx_1Hz(:, animal), ~timing_info_1Hz, optimal_num_clusters_combined);
- entry_rate_fMRI_on(:, animal) = calculate_entry_rates(idx_fMRI(:, animal), timing_info_fMRI, optimal_num_clusters_fMRI);
- entry_rate_fMRI_off(:, animal) = calculate_entry_rates(idx_fMRI(:, animal), ~timing_info_fMRI, optimal_num_clusters_fMRI);
- exit_rate_fMRI_on(:, animal) = calculate_exit_rates(idx_fMRI(:, animal), timing_info_fMRI, optimal_num_clusters_fMRI);
- exit_rate_fMRI_off(:, animal) = calculate_exit_rates(idx_fMRI(:, animal), ~timing_info_fMRI, optimal_num_clusters_fMRI);
- end
- p_values_entry_10Hz = nan(optimal_num_clusters_combined, 1);
- p_values_entry_1Hz = nan(optimal_num_clusters_combined, 1);
- p_values_entry_fMRI = nan(optimal_num_clusters_fMRI, 1);
- p_values_exit_10Hz = nan(optimal_num_clusters_combined, 1);
- p_values_exit_1Hz = nan(optimal_num_clusters_combined, 1);
- p_values_exit_fMRI = nan(optimal_num_clusters_fMRI, 1);
- for i = 1:optimal_num_clusters_combined
- p_values_entry_10Hz(i) = safe_paired_ttest(entry_rate_10Hz_on(i, :), entry_rate_10Hz_off(i, :));
- p_values_entry_1Hz(i) = safe_paired_ttest(entry_rate_1Hz_on(i, :), entry_rate_1Hz_off(i, :));
- p_values_exit_10Hz(i) = safe_paired_ttest(exit_rate_10Hz_on(i, :), exit_rate_10Hz_off(i, :));
- p_values_exit_1Hz(i) = safe_paired_ttest(exit_rate_1Hz_on(i, :), exit_rate_1Hz_off(i, :));
- end
- for i = 1:optimal_num_clusters_fMRI
- p_values_entry_fMRI(i) = safe_paired_ttest(entry_rate_fMRI_on(i, :), entry_rate_fMRI_off(i, :));
- p_values_exit_fMRI(i) = safe_paired_ttest(exit_rate_fMRI_on(i, :), exit_rate_fMRI_off(i, :));
- end
- fprintf('P-values for entry rates - FL 10 Hz:\n'); disp(p_values_entry_10Hz);
- fprintf('P-values for entry rates - FL 1 Hz:\n'); disp(p_values_entry_1Hz);
- fprintf('P-values for entry rates - fMRI:\n'); disp(p_values_entry_fMRI);
- fprintf('P-values for exit rates - FL 10 Hz:\n'); disp(p_values_exit_10Hz);
- fprintf('P-values for exit rates - FL 1 Hz:\n'); disp(p_values_exit_1Hz);
- fprintf('P-values for exit rates - fMRI:\n'); disp(p_values_exit_fMRI);
- mean_entry_rates_10Hz_on = mean(entry_rate_10Hz_on, 2, 'omitnan');
- mean_entry_rates_10Hz_off = mean(entry_rate_10Hz_off, 2, 'omitnan');
- mean_entry_rates_1Hz_on = mean(entry_rate_1Hz_on, 2, 'omitnan');
- mean_entry_rates_1Hz_off = mean(entry_rate_1Hz_off, 2, 'omitnan');
- mean_entry_rates_fMRI_on = mean(entry_rate_fMRI_on, 2, 'omitnan');
- mean_entry_rates_fMRI_off = mean(entry_rate_fMRI_off, 2, 'omitnan');
- sem_entry_rates_10Hz_on = std(entry_rate_10Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_entry_rates_10Hz_off = std(entry_rate_10Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_entry_rates_1Hz_on = std(entry_rate_1Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_entry_rates_1Hz_off = std(entry_rate_1Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_entry_rates_fMRI_on = std(entry_rate_fMRI_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_entry_rates_fMRI_off = std(entry_rate_fMRI_off, 0, 2, 'omitnan') / sqrt(num_animals);
- mean_exit_rates_10Hz_on = mean(exit_rate_10Hz_on, 2, 'omitnan');
- mean_exit_rates_10Hz_off = mean(exit_rate_10Hz_off, 2, 'omitnan');
- mean_exit_rates_1Hz_on = mean(exit_rate_1Hz_on, 2, 'omitnan');
- mean_exit_rates_1Hz_off = mean(exit_rate_1Hz_off, 2, 'omitnan');
- mean_exit_rates_fMRI_on = mean(exit_rate_fMRI_on, 2, 'omitnan');
- mean_exit_rates_fMRI_off = mean(exit_rate_fMRI_off, 2, 'omitnan');
- sem_exit_rates_10Hz_on = std(exit_rate_10Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_exit_rates_10Hz_off = std(exit_rate_10Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_exit_rates_1Hz_on = std(exit_rate_1Hz_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_exit_rates_1Hz_off = std(exit_rate_1Hz_off, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_exit_rates_fMRI_on = std(exit_rate_fMRI_on, 0, 2, 'omitnan') / sqrt(num_animals);
- sem_exit_rates_fMRI_off = std(exit_rate_fMRI_off, 0, 2, 'omitnan') / sqrt(num_animals);
- figure('Position', [0 0 400 900]);
- plot_grouped_bars_with_paired_points(3, 1, 1, mean_entry_rates_10Hz_on, mean_entry_rates_10Hz_off, sem_entry_rates_10Hz_on, sem_entry_rates_10Hz_off, entry_rate_10Hz_on, entry_rate_10Hz_off, 'Entry Rates - FL 10 Hz', 'Entry Rate (entries/window)', 1:optimal_num_clusters_combined, []);
- plot_grouped_bars_with_paired_points(3, 1, 2, mean_entry_rates_1Hz_on, mean_entry_rates_1Hz_off, sem_entry_rates_1Hz_on, sem_entry_rates_1Hz_off, entry_rate_1Hz_on, entry_rate_1Hz_off, 'Entry Rates - FL 1 Hz', 'Entry Rate (entries/window)', 1:optimal_num_clusters_combined, []);
- plot_grouped_bars_with_paired_points(3, 1, 3, mean_entry_rates_fMRI_on, mean_entry_rates_fMRI_off, sem_entry_rates_fMRI_on, sem_entry_rates_fMRI_off, entry_rate_fMRI_on, entry_rate_fMRI_off, 'Entry Rates - fMRI', 'Entry Rate (entries/window)', 1:optimal_num_clusters_fMRI, []);
- sgtitle('Entry rates for FL 10 Hz, FL 1 Hz, and fMRI (CO2 on/off)');
- figure('Position', [0 0 400 900]);
- plot_grouped_bars_with_paired_points(3, 1, 1, mean_exit_rates_10Hz_on, mean_exit_rates_10Hz_off, sem_exit_rates_10Hz_on, sem_exit_rates_10Hz_off, exit_rate_10Hz_on, exit_rate_10Hz_off, 'Exit Rates - FL 10 Hz', 'Exit Rate (exits/window)', 1:optimal_num_clusters_combined, []);
- plot_grouped_bars_with_paired_points(3, 1, 2, mean_exit_rates_1Hz_on, mean_exit_rates_1Hz_off, sem_exit_rates_1Hz_on, sem_exit_rates_1Hz_off, exit_rate_1Hz_on, exit_rate_1Hz_off, 'Exit Rates - FL 1 Hz', 'Exit Rate (exits/window)', 1:optimal_num_clusters_combined, []);
- plot_grouped_bars_with_paired_points(3, 1, 3, mean_exit_rates_fMRI_on, mean_exit_rates_fMRI_off, sem_exit_rates_fMRI_on, sem_exit_rates_fMRI_off, exit_rate_fMRI_on, exit_rate_fMRI_off, 'Exit Rates - fMRI', 'Exit Rate (exits/window)', 1:optimal_num_clusters_fMRI, []);
- sgtitle('Exit rates for FL 10 Hz, FL 1 Hz, and fMRI (CO2 on/off)');
- %% Cross-correlation between FL and fMRI state transitions
- thres = 0.01;
- state_transitions_FL = zeros(num_windows_10Hz - 1, num_animals);
- state_transitions_fMRI = zeros(num_windows_fMRI - 1, num_animals);
- for animal = 1:num_animals
- state_transitions_FL(:, animal) = diff(idx_10Hz(:, animal)) ~= 0;
- state_transitions_fMRI(:, animal) = diff(idx_fMRI(:, animal)) ~= 0;
- end
- max_lag = 6;
- cross_corr_FL_to_fMRI = zeros(2 * max_lag + 1, num_animals);
- for animal = 1:num_animals
- [cross_corr, lags_xcorr] = xcorr(state_transitions_FL(:, animal), state_transitions_fMRI(:, animal), max_lag, 'coeff');
- cross_corr_FL_to_fMRI(:, animal) = cross_corr;
- end
- avg_cross_corr_FL_to_fMRI = mean(cross_corr_FL_to_fMRI, 2, 'omitnan');
- p_values_FL_to_fMRI = nan(2 * max_lag + 1, 1);
- for lag_idx = 1:(2 * max_lag + 1)
- p_values_FL_to_fMRI(lag_idx) = safe_one_sample_ttest(cross_corr_FL_to_fMRI(lag_idx, :));
- end
- figure;
- subplot(2, 1, 1); hold on;
- plot(lags_xcorr, avg_cross_corr_FL_to_fMRI, '-b', 'LineWidth', 1.5);
- sig_lags = find(p_values_FL_to_fMRI < thres);
- plot(lags_xcorr(sig_lags), avg_cross_corr_FL_to_fMRI(sig_lags), 'r*', 'MarkerSize', 10);
- xlabel('Lag (frames)'); ylabel('Cross-Correlation'); title('Cross-correlation between FL and fMRI state transitions'); grid on; hold off;
- cross_corr_FL_to_fMRI_on = zeros(2 * max_lag + 1, num_animals);
- cross_corr_FL_to_fMRI_off = zeros(2 * max_lag + 1, num_animals);
- for animal = 1:num_animals
- [starts_10Hz, ~, starts_fMRI] = get_co2_start_indices_for_animal(animal, ...
- co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, ...
- co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, ...
- co2_on_indices_fMRI, co2_on_indices_fMRI_sub3);
- timing_info_10Hz = build_timing_mask(num_windows_10Hz, starts_10Hz, starts_10Hz + co2_duration);
- timing_info_fMRI = build_timing_mask(num_windows_fMRI, starts_fMRI, starts_fMRI + co2_duration);
- cross_corr_FL_to_fMRI_on(:, animal) = xcorr(state_transitions_FL(timing_info_10Hz(1:end-1), animal), state_transitions_fMRI(timing_info_fMRI(1:end-1), animal), max_lag, 'coeff');
- cross_corr_FL_to_fMRI_off(:, animal) = xcorr(state_transitions_FL(~timing_info_10Hz(1:end-1), animal), state_transitions_fMRI(~timing_info_fMRI(1:end-1), animal), max_lag, 'coeff');
- end
- avg_cross_corr_FL_to_fMRI_on = mean(cross_corr_FL_to_fMRI_on, 2, 'omitnan');
- avg_cross_corr_FL_to_fMRI_off = mean(cross_corr_FL_to_fMRI_off, 2, 'omitnan');
- p_values_FL_to_fMRI_on = nan(2 * max_lag + 1, 1);
- p_values_FL_to_fMRI_off = nan(2 * max_lag + 1, 1);
- for lag_idx = 1:(2 * max_lag + 1)
- p_values_FL_to_fMRI_on(lag_idx) = safe_one_sample_ttest(cross_corr_FL_to_fMRI_on(lag_idx, :));
- p_values_FL_to_fMRI_off(lag_idx) = safe_one_sample_ttest(cross_corr_FL_to_fMRI_off(lag_idx, :));
- end
- subplot(2, 1, 2); hold on;
- plot(lags_xcorr, avg_cross_corr_FL_to_fMRI_on, '-g', 'LineWidth', 1.5);
- plot(lags_xcorr, avg_cross_corr_FL_to_fMRI_off, '-r', 'LineWidth', 1.5);
- plot(lags_xcorr(p_values_FL_to_fMRI_on < thres), avg_cross_corr_FL_to_fMRI_on(p_values_FL_to_fMRI_on < thres), 'g*', 'MarkerSize', 8);
- plot(lags_xcorr(p_values_FL_to_fMRI_off < thres), avg_cross_corr_FL_to_fMRI_off(p_values_FL_to_fMRI_off < thres), 'r*', 'MarkerSize', 8);
- xlabel('Lag (frames)'); ylabel('Cross-Correlation'); title('Cross-correlation between FL and fMRI state transitions (CO2 on/off)'); grid on; hold off; ylim([0 0.1]);
- sgtitle('Cross-correlation between FL and fMRI state transitions');
- %% Conditional co-occurrence matrices across temporal lags
- lags = 0;
- [T, N] = size(idx_10Hz);
- K_FL = max(idx_10Hz(:));
- K_fMRI = max(idx_fMRI(:));
- L = numel(lags);
- CoocOn = zeros(K_fMRI, K_FL, L);
- CoocOff = zeros(K_fMRI, K_FL, L);
- P_on_fMRIgivenFL = nan(K_fMRI, K_FL, L);
- P_off_fMRIgivenFL = nan(K_fMRI, K_FL, L);
- P_on_FLgivenfMRI = nan(K_fMRI, K_FL, L);
- P_off_FLgivenfMRI = nan(K_fMRI, K_FL, L);
- for animal = 1:N
- if animal == 3
- on_idx = co2_on_indices_10Hz_sub3;
- else
- on_idx = co2_on_indices_10Hz;
- end
- on_mask = false(T, 1);
- on_mask(on_idx(on_idx <= T)) = true;
- off_mask = ~on_mask;
- for li = 1:L
- lag = lags(li);
- for t = 1:T
- tFL = t - lag;
- if tFL < 1 || tFL > T || t > size(idx_fMRI, 1)
- continue;
- end
- fL = idx_10Hz(tFL, animal);
- fR = idx_fMRI(t, animal);
- if fL > 0 && fR > 0
- if on_mask(t)
- CoocOn(fR, fL, li) = CoocOn(fR, fL, li) + 1;
- elseif off_mask(t)
- CoocOff(fR, fL, li) = CoocOff(fR, fL, li) + 1;
- end
- end
- end
- end
- end
- for li = 1:L
- C_on = CoocOn(:, :, li);
- C_off = CoocOff(:, :, li);
- P_on_fMRIgivenFL(:, :, li) = normalize_columns(C_on);
- P_off_fMRIgivenFL(:, :, li) = normalize_columns(C_off);
- P_on_FLgivenfMRI(:, :, li) = normalize_rows_2d(C_on);
- P_off_FLgivenfMRI(:, :, li) = normalize_rows_2d(C_off);
- end
- figure('Position', [100 100 1200 600]);
- for li = 1:L
- lag = lags(li);
- subplot(4, L, li);
- imagesc(P_on_fMRIgivenFL(:, :, li)); axis square; colorbar;
- title(sprintf('P(fMRI|FL) On, lag=%ds', lag));
- if li == 1, ylabel('fMRI state'); end
- xlabel('FL state');
- subplot(4, L, li + L);
- imagesc(P_off_fMRIgivenFL(:, :, li)); axis square; colorbar;
- title(sprintf('P(fMRI|FL) Off, lag=%ds', lag));
- xlabel('FL state');
- subplot(4, L, li + 2 * L);
- imagesc(P_on_FLgivenfMRI(:, :, li)); axis square; colorbar;
- title(sprintf('P(FL|fMRI) On, lag=%ds', lag));
- if li == 1, ylabel('fMRI state'); end
- xlabel('FL state');
- subplot(4, L, li + 3 * L);
- imagesc(P_off_FLgivenfMRI(:, :, li)); axis square; colorbar;
- title(sprintf('P(FL|fMRI) Off, lag=%ds', lag));
- xlabel('FL state');
- end
- sgtitle('Conditional co-occurrence matrices across lags and CO2 conditions');
- example_FL = 5;
- example_fMRI = 1;
- figure('Position', [200 200 800 300]);
- for li = 1:L
- subplot(2, L, li);
- bar(P_on_fMRIgivenFL(:, example_FL, li), 'b'); hold on;
- bar(P_off_fMRIgivenFL(:, example_FL, li), 'r'); hold off;
- ylim([0 1]);
- title(sprintf('P(fMRI|FL=%d), lag=%ds', example_FL, lags(li)));
- if li == 1, ylabel('Probability'); end
- xlabel('fMRI state'); legend('On', 'Off');
- subplot(2, L, li + L);
- bar(P_on_FLgivenfMRI(example_fMRI, :, li), 'b'); hold on;
- bar(P_off_FLgivenfMRI(example_fMRI, :, li), 'r'); hold off;
- ylim([0 1]);
- title(sprintf('P(FL|fMRI=%d), lag=%ds', example_fMRI, lags(li)));
- xlabel('FL state');
- end
- sgtitle(sprintf('Example conditional distributions for FL=%d and fMRI=%d', example_FL, example_fMRI));
- %% Local functions
- function cmap = load_colormap_safe(filename, varname, fallback)
- if exist(filename, 'file')
- S = load(filename);
- if isfield(S, varname)
- cmap = S.(varname);
- return;
- end
- end
- cmap = fallback;
- end
- function [starts_10Hz, starts_1Hz, starts_fMRI] = get_co2_start_indices_for_animal(animal, co2_on_indices_10Hz, co2_on_indices_10Hz_sub3, co2_on_indices_1Hz, co2_on_indices_1Hz_sub3, co2_on_indices_fMRI, co2_on_indices_fMRI_sub3)
- if animal == 3
- starts_10Hz = co2_on_indices_10Hz_sub3;
- starts_1Hz = co2_on_indices_1Hz_sub3;
- starts_fMRI = co2_on_indices_fMRI_sub3;
- else
- starts_10Hz = co2_on_indices_10Hz;
- starts_1Hz = co2_on_indices_1Hz;
- starts_fMRI = co2_on_indices_fMRI;
- end
- end
- function mask = build_timing_mask(num_windows, starts, ends_)
- mask = false(num_windows, 1);
- for i = 1:length(starts)
- s = max(1, round(starts(i)));
- e = min(num_windows, round(ends_(i)));
- if s <= e
- mask(s:e) = true;
- end
- end
- end
- function [idx_out, removed_states] = remove_single_subject_states(idx_in)
- idx_out = idx_in;
- removed_states = [];
- states = unique(idx_in(:));
- states = states(~isnan(states));
- for state = states'
- subject_count = sum(any(idx_in == state, 1));
- if subject_count == 1
- idx_out(idx_out == state) = NaN;
- removed_states(end + 1) = state; %#ok<AGROW>
- end
- end
- end
- function idx_out = replace_nan_states_with_closest(idx_in, distance_matrix)
- idx_out = idx_in;
- for animal = 1:size(idx_out, 2)
- for t = 1:size(idx_out, 1)
- if isnan(idx_out(t, animal))
- non_nan_states = idx_out(~isnan(idx_out(:, animal)), animal);
- if isempty(non_nan_states)
- continue;
- end
- min_distance = inf;
- similar_state = NaN;
- for s = non_nan_states'
- distances = distance_matrix(s, :);
- [min_dist, state] = min(distances);
- if min_dist < min_distance
- min_distance = min_dist;
- similar_state = state;
- end
- end
- idx_out(t, animal) = similar_state;
- end
- end
- end
- end
- function counts = count_states_in_range(state_vector, start_idx, end_idx, num_states)
- counts = zeros(num_states, 1);
- start_idx = max(1, round(start_idx));
- end_idx = min(length(state_vector), round(end_idx));
- if start_idx > end_idx
- return;
- end
- for s = 1:num_states
- counts(s) = sum(state_vector(start_idx:end_idx) == s);
- end
- end
- function trans_counts = count_transitions_in_range(state_vector, start_idx, end_idx, num_states)
- trans_counts = zeros(num_states, num_states);
- start_idx = max(1, round(start_idx));
- end_idx = min(length(state_vector), round(end_idx));
- if start_idx >= end_idx
- return;
- end
- for t = start_idx:(end_idx - 1)
- current_state = state_vector(t);
- next_state = state_vector(t + 1);
- if ~isnan(current_state) && ~isnan(next_state)
- trans_counts(current_state, next_state) = trans_counts(current_state, next_state) + 1;
- end
- end
- end
- function M = normalize_columns(M)
- denom = sum(M, 1, 'omitnan');
- denom(denom == 0) = NaN;
- M = M ./ denom;
- end
- function P = normalize_rows_2d(M)
- denom = sum(M, 2, 'omitnan');
- denom(denom == 0) = NaN;
- P = M ./ denom;
- P(isnan(P)) = 0;
- end
- function pct = safe_percent_by_column(counts)
- denom = sum(counts, 1);
- denom(denom == 0) = NaN;
- pct = counts ./ denom * 100;
- pct(isnan(pct)) = 0;
- end
- function T = normalize_transition_tensor(count_tensor)
- T = zeros(size(count_tensor));
- for animal = 1:size(count_tensor, 3)
- for i = 1:size(count_tensor, 1)
- row_sum = sum(count_tensor(i, :, animal));
- if row_sum > 0
- T(i, :, animal) = count_tensor(i, :, animal) / row_sum;
- end
- end
- end
- end
- function p = safe_paired_ttest(x, y)
- x = x(:);
- y = y(:);
- valid = ~isnan(x) & ~isnan(y);
- if nnz(valid) < 2 || numel(unique(x(valid) - y(valid))) < 1
- p = NaN;
- return;
- end
- [~, p] = ttest(x(valid), y(valid));
- end
- function p = safe_one_sample_ttest(x)
- x = x(:);
- x = x(~isnan(x));
- if numel(x) < 2 || numel(unique(x)) < 2
- p = NaN;
- return;
- end
- [~, p] = ttest(x);
- end
- function plot_grouped_bars_with_paired_points(nr, nc, idx_subplot, mean_on, mean_off, sem_on, sem_off, data_on, data_off, plot_title, ylab, xtick_vals, y_limits)
- subplot(nr, nc, idx_subplot);
- bar_data = [mean_on, mean_off];
- bar_handle = bar(bar_data, 'grouped');
- hold on;
- bar_handle(1).FaceColor = [0.2 0.6 0.8];
- bar_handle(2).FaceColor = [0.8 0.4 0.4];
- x_on = bar_handle(1).XEndPoints;
- x_off = bar_handle(2).XEndPoints;
- errorbar(x_on, mean_on, sem_on, 'k', 'linestyle', 'none', 'LineWidth', 1);
- errorbar(x_off, mean_off, sem_off, 'k', 'linestyle', 'none', 'LineWidth', 1);
- jitter_amount = 0.05;
- marker_size = 22;
- line_color = [0.7 0.7 0.7];
- for s = 1:numel(mean_on)
- jitter_vec = (rand(size(data_on, 2), 1) - 0.5) * 2 * jitter_amount;
- x_on_jit = x_on(s) + jitter_vec;
- x_off_jit = x_off(s) + jitter_vec;
- y_on = data_on(s, :)';
- y_off = data_off(s, :)';
- valid_pairs = ~isnan(y_on) & ~isnan(y_off);
- for a = find(valid_pairs)'
- plot([x_on_jit(a), x_off_jit(a)], [y_on(a), y_off(a)], '-', 'Color', line_color, 'LineWidth', 0.8);
- end
- scatter(x_on_jit(~isnan(y_on)), y_on(~isnan(y_on)), marker_size, 'filled', 'MarkerFaceColor', [0 0.25 0.55], 'MarkerFaceAlpha', 0.7);
- scatter(x_off_jit(~isnan(y_off)), y_off(~isnan(y_off)), marker_size, 'filled', 'MarkerFaceColor', [0.55 0 0], 'MarkerFaceAlpha', 0.7);
- end
- title(plot_title);
- xlabel('State');
- ylabel(ylab);
- xticks(xtick_vals);
- legend({'CO2 On', 'CO2 Off'});
- if ~isempty(y_limits)
- ylim(y_limits);
- end
- hold off;
- end
- function plot_transition_matrix_with_sig(nr, nc, idx_subplot, M, p_values, threshold, ttl, xl, yl, climits, cmap)
- subplot(nr, nc, idx_subplot);
- imagesc(M);
- colorbar;
- axis square;
- colormap(cmap);
- caxis(climits);
- title(ttl);
- xlabel(xl);
- ylabel(yl);
- hold on;
- for i = 1:size(M, 1)
- for j = 1:size(M, 2)
- if ~isnan(p_values(i, j)) && p_values(i, j) < threshold
- text(j, i, '*', 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Middle', 'Color', 'k', 'FontSize', 14);
- end
- end
- end
- hold off;
- end
- function plot_matrix_with_sig(nr, nc, idx_subplot, M, p_values, threshold, ttl, xl, yl, climits, cmap)
- subplot(nr, nc, idx_subplot);
- imagesc(M);
- colorbar;
- axis square;
- colormap(cmap);
- caxis(climits);
- title(ttl);
- xlabel(xl);
- ylabel(yl);
- hold on;
- for i = 1:size(M, 1)
- for j = 1:size(M, 2)
- if ~isnan(p_values(i, j)) && p_values(i, j) < threshold
- text(j, i, '*', 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Middle', 'Color', 'k', 'FontSize', 14);
- end
- end
- end
- hold off;
- end
- function y = percentile_filter(x, lower_pct, upper_pct)
- x = x(~isnan(x));
- if isempty(x)
- y = x;
- return;
- end
- lo = prctile(x, lower_pct);
- hi = prctile(x, upper_pct);
- y = x(x >= lo & x <= hi);
- end
- function plot_distribution_comparison(x_on, x_off, ttl)
- if exist('daviolinplot', 'file') == 2
- daviolinplot([x_on; x_off], 'groups', [ones(size(x_on)); 2 * ones(size(x_off))]);
- title(ttl);
- return;
- end
- boxplot([x_on; x_off], [ones(size(x_on)); 2 * ones(size(x_off))]);
- set(gca, 'XTickLabel', {'CO2 On', 'CO2 Off'});
- ylabel('Similarity');
- title(ttl);
- end
- function d = cohens_d_two_sample(x, y)
- x = x(~isnan(x));
- y = y(~isnan(y));
- if numel(x) < 2 || numel(y) < 2
- d = NaN;
- return;
- end
- nx = numel(x);
- ny = numel(y);
- sx = std(x, 0);
- sy = std(y, 0);
- s_pooled = sqrt(((nx - 1) * sx^2 + (ny - 1) * sy^2) / (nx + ny - 2));
- if s_pooled == 0
- d = NaN;
- else
- d = (mean(x) - mean(y)) / s_pooled;
- end
- end
- function dwell_times = calculate_dwell_times(state_sequence, timing_mask, num_states)
- dwell_times = nan(num_states, 1);
- state_sequence = state_sequence(:);
- timing_mask = timing_mask(:);
- for state = 1:num_states
- run_lengths = [];
- in_run = false;
- current_len = 0;
- for t = 1:length(state_sequence)
- is_selected_state = timing_mask(t) && state_sequence(t) == state;
- if is_selected_state
- current_len = current_len + 1;
- in_run = true;
- elseif in_run
- run_lengths(end + 1) = current_len; %#ok<AGROW>
- current_len = 0;
- in_run = false;
- end
- end
- if in_run
- run_lengths(end + 1) = current_len; %#ok<AGROW>
- end
- if ~isempty(run_lengths)
- dwell_times(state) = mean(run_lengths);
- end
- end
- end
- function entry_rates = calculate_entry_rates(state_sequence, timing_mask, num_states)
- entry_rates = nan(num_states, 1);
- state_sequence = state_sequence(:);
- timing_mask = timing_mask(:);
- total_selected = sum(timing_mask);
- if total_selected == 0
- return;
- end
- for state = 1:num_states
- entries = 0;
- for t = 1:length(state_sequence)
- if timing_mask(t) && state_sequence(t) == state
- if t == 1 || ~timing_mask(t - 1) || state_sequence(t - 1) ~= state
- entries = entries + 1;
- end
- end
- end
- entry_rates(state) = entries / total_selected;
- end
- end
- function exit_rates = calculate_exit_rates(state_sequence, timing_mask, num_states)
- exit_rates = nan(num_states, 1);
- state_sequence = state_sequence(:);
- timing_mask = timing_mask(:);
- total_selected = sum(timing_mask);
- if total_selected == 0
- return;
- end
- for state = 1:num_states
- exits = 0;
- for t = 1:length(state_sequence)
- if timing_mask(t) && state_sequence(t) == state
- is_exit = (t == length(state_sequence)) || ~timing_mask(min(t + 1, length(timing_mask))) || state_sequence(min(t + 1, length(state_sequence))) ~= state;
- if is_exit
- exits = exits + 1;
- end
- end
- end
- exit_rates(state) = exits / total_selected;
- end
- end
dfc_state_analysis.m, under CC-BY-4.0 · at the source
Overview
- Institute for Biomedical Engineering and Institute of Pharmacology and Toxicology, Faculty of Medicine, University of Zurich,Zurich, Switzerland
- Department of Information Technology and Electrical Engineering, Institute for Biomedical Engineering, ETH Zurich,Zurich, Switzerland
- Department of Psychiatry, Faculty of Medicine, University of Geneva,Geneva, Switzerland
- Department of Basic Neurosciences, Faculty of Medicine, University of Geneva,Geneva, Switzerland
- Institute of Precision Optical Engineering, School of Physics Science and Engineering, Tongji University,Shanghai, China
Abstract
Neurovascular coupling (NVC) underpins the interpretation of hemodynamic signals as proxies for neural activity, yet its response to metabolic perturbations remains poorly understood. Here, we leverage concurrent fluorescence calcium imaging and functional magnetic resonance imaging in mice expressing genetically encoded calcium indicators to dissect how elevated CO₂ levels reshape the interplay between neural and vascular responses. Our findings indicate that hypercapnia induces opposing trends in calcium and blood-oxygen-level-depen
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.
Zenodo 19099592
Availability: 1 check, the latest on 29 September 2026: the link answers (HTTP 200)
- 29 September 2026: the link answers (HTTP 200)
2 files
- cap_analysis.m, MATLAB, 596 lines
- dfc_state_analysis.m, MATLAB, 1,383 lines, 1 match
Code availability
Examples of custom codes used in this manuscript are deposited and publicly available on Zenodo at 10.5281/
Reproduced under the paper's license (CC BY), from the paper cited above.
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;
- 2 scripts, each with its path and the digest of its content;
- 1 match 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
No dataset and no data link were found in the paper.
Data availability
The data that support the findings of this study are available from the corresponding author. All data supporting the findings of this study are found within the paper and its Supplementary Information. Source data are provided with this paper.
Reproduced under the paper's license (CC BY), from the paper cited above.
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, 29 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 5 authors, 3 keywords, 13 MeSH terms, 1 funder, 49 references.
Cite
This paper
Gezginer, I., Chen, Y., Zerbi, V., Chen, Z., & Razansky, D. (2026). Hypercapnia dissociates neuronal and hemodynamic responses impairing neurovascular coupling and functional brain connectivity. Nature communications, 17(1), 5158. https://
BibTeX
@article{gezginer2026hyp
author = {Gezginer, Irmak and Chen, Yi and Zerbi, Valerio and Chen, Zhenyue and Razansky, Daniel},
title = {{Hypercapnia dissociates neuronal and hemodynamic responses impairing neurovascular coupling and functional brain connectivity}},
journal = {Nature communications},
year = {2026},
month = apr,
volume = {17},
number = {1},
pages = {5158},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/
url = {https://
pmid = {41974737},
pmcid = {PMC13249851}
}
RIS
TY - JOUR
AU - Gezginer, Irmak
AU - Chen, Yi
AU - Zerbi, Valerio
AU - Chen, Zhenyue
AU - Razansky, Daniel
TI - Hypercapnia dissociates neuronal and hemodynamic responses impairing neurovascular coupling and functional brain connectivity
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/
VL - 17
IS - 1
SP - 5158
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Hypercapnia dissociates neuronal and hemodynamic responses impairing neurovascular coupling and functional brain connectivity",
"container-title": "Nature communications",
"author": [
{
"family": "Gezginer",
"given": "Irmak"
},
{
"family": "Chen",
"given": "Yi"
},
{
"family": "Zerbi",
"given": "Valerio"
},
{
"family": "Chen",
"given": "Zhenyue"
},
{
"family": "Razansky",
"given": "Daniel"
}
],
"container-title-short":
"volume": "17",
"issue": "1",
"page": "5158",
"DOI": "10.1038/
"PMID": "41974737",
"PMCID": "PMC13249851",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
13
]
]
}
}
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.1038/s41467-024-54947-y
- Concurrent optoacoustic tomography and magnetic resonance imaging of resting-state functional connectivity in the mouse brain.Journal: Nature communicationsIn common: fMRI, mouse, 4 references, 3 authors
- [2] doi:10.1002/advs.202205191
- Simultaneous Functional Magnetic Resonance and Optoacoustic Imaging of Brain-Wide Sensory Responses in Mice.Journal: Advanced science (Weinheim, Baden-Wurttemberg, Germany)In common: fMRI, mouse, 2 references, 3 authors
- [3] doi:10.1038/s41467-026-71746-9
- Double-helix optical point spread function enables real-time mesoscopic 3D functional microangiography in the living mouse brain and skull.Journal: Nature communicationsIn common: mouse, 3 authors
- [4] doi:10.1016/j.pacs.2023.100522
- Volumetric registration framework for multimodal functional magnetic resonance and optoacoustic tomography of the rodent brain.Journal: PhotoacousticsIn common: fMRI, mouse, 2 references, 2 authors
- [5] doi:10.1038/s41467-024-47892-3 [code]
- Cortex-wide transcranial localization microscopy with fluorescently labeled red blood cells.Journal: Nature communicationsIn common: mouse, 2 authors
- [6] doi:10.1038/s41467-023-39069-1
- Deep optoacoustic localization microangiography of ischemic stroke in mice.Journal: Nature communicationsIn common: mouse, 2 authors
- [7] doi:10.1038/s41467-022-35733-0
- Three-dimensional wide-field fluorescence microscopy for transcranial mapping of cortical microcirculation.Journal: Nature communicationsIn common: mouse, 2 authors
- [8] doi:10.1007/s00259-022-05708-w
- Non-invasive imaging of tau-targeted probe uptake by whole brain multi-spectral optoacoustic tomography.Journal: European journal of nuclear medicine and molecular imagingIn common: mouse, 2 authors
- [9] doi:10.1038/s42003-024-05766-w [code]
- Modular subgraphs in large-scale connectomes underpin spontaneous co-fluctuation events in mouse and human brains.Journal: Communications biologyIn common: Statistics and Machine Learning Toolbox, mouse, 7 references
- [10] doi:10.1016/j.molmet.2025.102313
- Pancreatic amylin dynamically reconfigures distributed brain networks governing appetite regulation in mice.Journal: Molecular metabolismIn common: fMRI, mouse, 3 references, author Irmak Gezginer
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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 2 scripts, and 1 match between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:092802e004d271b6…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1038/s41467-026-71742-z)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1038/s41467-026-71742-z.svg
:target: https://openscicode.org/badge/doi/10.1038/s41467-026-71742-z
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s41467-026-71742-z"><img src="https://openscicode.org/badge/doi/10.1038/s41467-026-71742-z.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge 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: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
