mouse_to_human_years.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. % Define the data points
  2. mouse_days = [0, 3, 14, 21, 28, 48];
  3. human_days = [0, 1, 7, 90, 180, 360];
  4. phases = {'Hyper-acute', 'Acute', 'Early Subacute', 'Late Subacute', 'Chronic'};
  5. phase_colors = [0.8, 0.2, 0.2; % Hyper-acute
  6. 0.2, 0.8, 0.2; % Acute
  7. 0.2, 0.2, 0.8; % Early Subacute
  8. 0.8, 0.8, 0.2; % Late Subacute
  9. 0.5, 0.2, 0.5]; % Chronic
  10. % Create a spline fit
  11. spline_fit = spline(mouse_days, human_days);
  12. % Generate finer x values for smooth curve plotting
  13. fine_mouse_days = linspace(min(mouse_days), max(mouse_days), 100);
  14. fine_human_days = ppval(spline_fit, fine_mouse_days);
  15. % Plot the data points and the fit
  16. figure;
  17. hold on;
  18. plot(mouse_days, human_days, 'o', 'MarkerFaceColor', 'b', 'DisplayName', 'Data Points');
  19. plot(fine_mouse_days, fine_human_days, '-r', 'DisplayName', 'Spline Fit');
  20. % Fill areas under the curve according to phases
  21. for i = 1:length(mouse_days)-1
  22. fill_x = [mouse_days(i), linspace(mouse_days(i), mouse_days(i+1), 100), mouse_days(i+1)];
  23. fill_y = [0, ppval(spline_fit, linspace(mouse_days(i), mouse_days(i+1), 100)), 0];
  24. fill(fill_x, fill_y, phase_colors(i,:), 'FaceAlpha', 0.5, 'EdgeColor', 'none');
  25. % Write the phases in the areas between time points
  26. mid_x = (mouse_days(i) + mouse_days(i+1)) / 2;
  27. mid_y = ppval(spline_fit, mid_x) / 2;
  28. text(mid_x, mid_y, phases{i}, 'HorizontalAlignment', 'center', 'FontSize', 12, 'Color', 'k');
  29. end
  30. % Add dashed grey lines from data points to x and y ticks
  31. for i = 1:length(mouse_days)
  32. x = mouse_days(i);
  33. y = human_days(i);
  34. plot([x, x], [0, y], '--', 'Color', [0.5, 0.5, 0.5]);
  35. plot([0, x], [y, y], '--', 'Color', [0.5, 0.5, 0.5]);
  36. end
  37. % Set the ticks for the dashed lines
  38. set(gca, 'XTick', mouse_days);
  39. set(gca, 'YTick', human_days);
  40. % Add legend and labels
  41. xlabel('Mouse Days');
  42. ylabel('Human Days');
  43. title('Mouse Days to Human Days Conversion');
  44. % Remove the legend
  45. legend off;
  46. % Show grid for better visualization
  47. grid on;
  48. hold off;