SpaceQuester

Untitled

May 2nd, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.68 KB | None | 0 0
  1. close all;
  2. clc;
  3. clear;
  4.  
  5. filename0 = 'A.txt';
  6. path0 = '/Users/sergeymakovkin/Documents/Kuramoto_network/Solver4_experiment/Solver/Solver';
  7. Data = importdata( [ path0 '/' filename0 ] );
  8.  
  9. %figure;
  10. figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  11. imagesc(Data, [0 1]);
  12. %axis equal;
  13. daspect([1 1 1])
  14. %%axis off;
  15. colormap(gray(2));
  16. caxis([0 1]);
  17. cbh = colorbar('v');
  18. set(cbh, 'YTick', [0:1:1]);
  19. set(gca, 'XTick', [1 size(Data, 1)/2 size(Data, 1)]);
  20. set(gca, 'YTick', [1 size(Data, 2)/2 size(Data, 2)]);
  21. ax = gca;
  22. ax.XAxisLocation = 'top';
  23. title('Adjacency matrix');
  24. set(gca, 'FontSize', 40);
  25. saveas(gcf, 'A', 'epsc');
  26.  
  27. filename3 = 'links.txt';
  28. path3 = '/Users/sergeymakovkin/Documents/Kuramoto_network/Solver4_experiment/Solver/Solver';
  29. Data = importdata( [ path3 '/' filename3 ] );
  30.  
  31. % f_n_omega = figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  32. % subplot(3, 1, 1);
  33. figure;
  34. oscillator_number = linspace(size(Data, 1)+1, 2*size(Data, 1), size(Data, 1));
  35. bar(oscillator_number, Data(:, 1), 'r');
  36. hold on;
  37. plot([size(Data, 1)+0.5 2*size(Data, 1)+0.5], [mean(Data(:, 1)) mean(Data(:, 1))], 'b', 'LineWidth', 3);
  38. hold on;
  39. xlim([size(Data, 1)+0.5, 2*size(Data, 1)+0.5]);
  40. set(gca, 'XTick', [size(Data, 1)+1, 2*size(Data, 1)]);
  41. title('Links counter diagram');
  42. xlabel('Neuron layer oscillator number');
  43. ylabel('Links count');
  44. saveas(gcf, 'Links', 'epsc');
  45.  
  46. filename1 = 'omega_init.txt';
  47. path1 = '/Users/sergeymakovkin/Documents/Kuramoto_network/Solver4_experiment/Solver/Solver';
  48. omega_init = importdata( [ path1 '/' filename1 ] );
  49. oscillator_number = linspace(1, size(omega_init, 1), size(omega_init, 1));
  50.  
  51. f_omega_1 = figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  52. subplot(1, 2, 1);
  53. plot(oscillator_number(1:end/2), omega_init(1:end/2)', 'r.', 'MarkerSize', 21);
  54. hold on;
  55. plot(oscillator_number(end/2+1:end), omega_init(end/2+1:end)', 'b.', 'MarkerSize', 21);
  56. grid on;
  57. xlim([0 size(oscillator_number, 2)]);
  58. ylim([0 4]);
  59. set(gca, 'XTick', 0:size(oscillator_number, 2)/2:size(oscillator_number, 2));
  60. set(gca, 'FontSize', 28);
  61. title('\omega_{init}, natural frequencies of i^{th} oscillator', 'FontSize', 28);
  62. xlabel('Oscillator number', 'FontSize', 50);
  63. ylabel('\omega, Hz', 'FontSize', 50);
  64. legend('\omega_{init wired glial}', '\omega_{init random neuron}', 'Location', 'northwest', 'FontSize', 28);
  65.  
  66. % figure(f_n_omega);
  67. % subplot(3, 1, 2);
  68. % plot(oscillator_number(end/2+1:end)+1, omega_init(end/2+1:end), 'b.', 'MarkerSize', 21);
  69. % grid on;
  70. % grid minor;
  71. % xlim([oscillator_number(end/2+1)+1 oscillator_number(end)+1]);
  72. % ylim([3 4]);
  73. % set(gca, 'XTick', [oscillator_number(end/2+1)+1, oscillator_number(end)+1]);
  74. % xlabel('Neuron layer oscillator number');
  75. % ylabel('\omega_{init random neuron}, Hz');
  76.  
  77. filename2 = 'results.txt';
  78. path2 = '/Users/sergeymakovkin/Documents/Kuramoto_network/Solver4_experiment/Solver/Solver';
  79. Data = importdata( [ path2 '/' filename2 ] );
  80. time = Data(:, 1);
  81. theta = Data(:, 2:end);
  82.  
  83. figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  84. plot(time, theta);
  85. %plot(time, mod(theta, 2*pi));
  86. %grid on;
  87. %title('Kuramoto C results on MacBook Pro');
  88. set(gca, 'FontSize', 24);
  89. xlabel('Time, msec', 'FontSize', 50);
  90. ylabel('\theta, rad', 'FontSize', 50);
  91. %saveas(gcf, 'results.png');
  92. saveas(gcf, 'results', 'epsc');
  93.  
  94. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  95. % omega calculation HARD!!!
  96. % for i = 0.5:0.1:0.6
  97. % omega_end_distribution(i, :) = ( bsxfun(@minus, theta(i, :), theta(size(theta(round(end/2):end, :), 1), :)) ) / ( time(i) - time(size(theta(round(end/2):end, :), 1)) );
  98. % end
  99. %
  100. % figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  101. % plot(time(:, :), omega_end_distribution(:, :));
  102. % grid on;
  103. % hold on;
  104. %%%%%%%%%%%%%%%%%%%%%%%%%%%
  105.  
  106. omega_end(:) = ( bsxfun(@minus, theta(end, :), theta(round(end/2), :)) ) / ( time(end) - time(round(end/2)) );
  107. % plot(time(end), omega_end(:), '.', 'MarkerSize', 20);
  108. % grid on;
  109.  
  110. %%%%%%%%%%%
  111. omega_end_055(:) = ( bsxfun(@minus, theta(round(0.55*end), :), theta(round(end/2), :)) ) / ( time(round(0.55*end)) - time(round(end/2)) );
  112. omega_end_060(:) = ( bsxfun(@minus, theta(round(0.60*end), :), theta(round(end/2), :)) ) / ( time(round(0.60*end)) - time(round(end/2)) );
  113. omega_end_065(:) = ( bsxfun(@minus, theta(round(0.65*end), :), theta(round(end/2), :)) ) / ( time(round(0.65*end)) - time(round(end/2)) );
  114. omega_end_070(:) = ( bsxfun(@minus, theta(round(0.70*end), :), theta(round(end/2), :)) ) / ( time(round(0.70*end)) - time(round(end/2)) );
  115. omega_end_075(:) = ( bsxfun(@minus, theta(round(0.75*end), :), theta(round(end/2), :)) ) / ( time(round(0.75*end)) - time(round(end/2)) );
  116. omega_end_080(:) = ( bsxfun(@minus, theta(round(0.80*end), :), theta(round(end/2), :)) ) / ( time(round(0.80*end)) - time(round(end/2)) );
  117. omega_end_085(:) = ( bsxfun(@minus, theta(round(0.85*end), :), theta(round(end/2), :)) ) / ( time(round(0.85*end)) - time(round(end/2)) );
  118. omega_end_090(:) = ( bsxfun(@minus, theta(round(0.90*end), :), theta(round(end/2), :)) ) / ( time(round(0.90*end)) - time(round(end/2)) );
  119. omega_end_095(:) = ( bsxfun(@minus, theta(round(0.95*end), :), theta(round(end/2), :)) ) / ( time(round(0.95*end)) - time(round(end/2)) );
  120. omega_end_100(:) = ( bsxfun(@minus, theta(round(1.00*end), :), theta(round(end/2), :)) ) / ( time(round(1.00*end)) - time(round(end/2)) );
  121. omega_end_time_distribution = [omega_end_055(:) omega_end_060(:) omega_end_065(:) omega_end_070(:) omega_end_075(:) omega_end_080(:) omega_end_085(:) omega_end_090(:) omega_end_095(:) omega_end_100(:)];
  122. time_omega_end_time_distribution = [time(round(0.55*end)) time(round(0.60*end)) time(round(0.65*end)) time(round(0.70*end)) time(round(0.75*end)) time(round(0.80*end)) time(round(0.85*end)) time(round(0.90*end)) time(round(0.95*end)) time(round(1.00*end))];
  123.  
  124. figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  125. plot(time_omega_end_time_distribution, omega_end_time_distribution, '.-');
  126. grid on;
  127. ylim([0 4]);
  128. xlabel('Time, msec');
  129. ylabel('\omega_{end random neuron}, Hz');
  130. title('\omega by time distribution');
  131. %%%%%%%%%%%
  132.  
  133. % figure(f_n_omega);
  134. % subplot(3, 1, 3);
  135. % plot(oscillator_number(end/2+1:end)+1, omega_end(end/2+1:end), 'b.', 'MarkerSize', 21);
  136. % grid on;
  137. % grid minor;
  138. % xlim([oscillator_number(end/2+1)+1 oscillator_number(end)+1]);
  139. % ylim([3 4]);
  140. % set(gca, 'XTick', [oscillator_number(end/2+1)+1, oscillator_number(end)+1]);
  141. % xlabel('Neuron layer oscillator number');
  142. % ylabel('\omega_{end random neuron}, Hz');
  143.  
  144. figure(f_omega_1);
  145. subplot(1, 2, 2);
  146. plot(oscillator_number(1:end/2), omega_end(1:end/2), 'r.', 'MarkerSize', 21);
  147. hold on;
  148. plot(oscillator_number(end/2+1:end), omega_end(end/2+1:end), 'b.', 'MarkerSize', 21);
  149. grid on;
  150. xlim([0 size(oscillator_number, 2)]);
  151. ylim([0 4]);
  152. set(gca, 'XTick', 0:size(oscillator_number, 2)/2:size(oscillator_number, 2));
  153. set(gca, 'FontSize', 28);
  154. title('\omega_{end average} in the last time point, natural frequencies of i^{th} oscillator', 'FontSize', 28);
  155. xlabel('Oscillator number', 'FontSize', 50);
  156. ylabel('\omega, Hz', 'FontSize', 50);
  157. legend('\omega_{end wired glial}', '\omega_{end random neuron}', 'Location', 'northwest', 'FontSize', 28);
  158. saveas(gcf, 'omega_disrtibution_1', 'epsc');
  159.  
  160. % Dispersion: mean((x - mean(x)).^2) or var(x, 1)
  161. Delta_total = sqrt(var(omega_end(:), 1));
  162. Delta_wired_glial = sqrt(var(omega_end(1:end/2), 1));
  163. Delta_random_neuron = sqrt(var(omega_end(end/2+1:end), 1));
  164.  
  165. % fid = fopen('Delta_N25_s1.000.txt', 'at');
  166. % fprintf(fid, '%f\t %f\t %f \n', [Delta_total Delta_wired_glial Delta_random_neuron]');
  167. % fclose(fid);
  168. %%%%%%%%%
  169.  
  170. % Answer here: http://stackoverflow.com/questions/15754459/how-can-i-make-a-color-map-plot-in-matlab
  171. % surf(i, j, B);
  172. % colorbar;
  173. % view(90, 90);
  174. omega_init_wired_glial = omega_init(1:end/2);
  175. omega_init_random_neuron = omega_init(end/2+1:end);
  176.  
  177. image_init_wired_glial = reshape(omega_init_wired_glial, [sqrt(size(omega_init_wired_glial, 1)), sqrt(size(omega_init_wired_glial, 1))]);
  178. image_init_random_neuron = reshape(omega_init_random_neuron, [sqrt(size(omega_init_random_neuron, 1)), sqrt(size(omega_init_wired_glial, 1))]);
  179.  
  180. f_omega_2 = figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  181. subplot(1, 2, 1);
  182. imagesc(image_init_wired_glial');
  183. axis equal;
  184. axis off;
  185. colormap jet;
  186. caxis([0 4]);
  187. colorbar;
  188. title(['\omega_{init wired glial}. Layer size = ' num2str(sqrt(size(omega_init_wired_glial, 1))) 'x' num2str(sqrt(size(omega_init_wired_glial, 1)))]);
  189. set(gca, 'FontSize', 40);
  190.  
  191. figure(f_omega_2);
  192. subplot(1, 2, 2);
  193. imagesc(image_init_random_neuron');
  194. axis equal;
  195. axis off;
  196. colormap jet;
  197. caxis([0 4]);
  198. colorbar;
  199. title(['\omega_{init random neuron}. Layer size = ' num2str(sqrt(size(omega_init_random_neuron, 1))) 'x' num2str(sqrt(size(omega_init_random_neuron, 1)))]);
  200. set(gca, 'FontSize', 40);
  201. saveas(gcf, 'omega_disrtibution_2', 'epsc');
  202.  
  203. omega_end_wired_glial = omega_end(1:end/2);
  204. omega_end_random_neuron = omega_end(end/2+1:end);
  205.  
  206. image_end_wired_glial = reshape(omega_end_wired_glial, [sqrt(size(omega_end_wired_glial, 2)), sqrt(size(omega_end_wired_glial, 2))]);
  207. image_end_random_neuron = reshape(omega_end_random_neuron, [sqrt(size(omega_end_random_neuron, 2)), sqrt(size(omega_end_wired_glial, 2))]);
  208.  
  209. f_omega_3 = figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  210. subplot(1, 2, 1);
  211. imagesc(image_end_wired_glial');
  212. axis equal;
  213. axis off;
  214. colormap jet;
  215. caxis([0 4]);
  216. colorbar;
  217. title(['\omega_{end wired glial}. Layer size = ' num2str(sqrt(size(omega_end_wired_glial, 2))) 'x' num2str(sqrt(size(omega_end_wired_glial, 2)))]);
  218. set(gca, 'FontSize', 40);
  219.  
  220. figure(f_omega_3);
  221. subplot(1, 2, 2);
  222. imagesc(image_end_random_neuron');
  223. axis equal;
  224. axis off;
  225. colormap jet;
  226. caxis([0 4]);
  227. colorbar;
  228. title(['\omega_{end random neuron}. Layer size = ' num2str(sqrt(size(omega_end_random_neuron, 2))) 'x' num2str(sqrt(size(omega_end_random_neuron, 2)))]);
  229. set(gca, 'FontSize', 40);
  230. %saveas(gcf, 'omega_disrtibution.png');
  231. saveas(gcf, 'omega_disrtibution_3', 'epsc');
  232.  
  233. filename4 = 'results.txt';
  234. path4 = '/Users/sergeymakovkin/Documents/Kuramoto_network/Solver4_experiment/Solver/Solver';
  235. Data = importdata( [ path4 '/' filename4 ] );
  236. time = Data(:, 1);
  237. theta = Data(:, 2:end);
  238.  
  239. rx_total = (1/(size(theta, 2)))*sum(cos(theta(:, :)')); % Sum of mean x-part of theta
  240. ry_total = (1/(size(theta, 2)))*sum(sin(theta(:, :)')); % Sum of mean y-part of theta
  241. r_total = sqrt(rx_total.*rx_total + ry_total.*ry_total);
  242. r_total_mean = mean(r_total(:, round(size(r_total, 2)*0.5):end));
  243.  
  244. rx_wired_glial = (1/(size(theta(:, 1:end/2), 2)))*sum(cos(theta(:, 1:end/2)')); % Sum of mean x-part of theta
  245. ry_wired_glial = (1/(size(theta(:, 1:end/2), 2)))*sum(sin(theta(:, 1:end/2)')); % Sum of mean y-part of theta
  246. r_wired_glial = sqrt(rx_wired_glial.*rx_wired_glial + ry_wired_glial.*ry_wired_glial);
  247. r_wired_glial_mean = mean(r_wired_glial(:, round(size(r_wired_glial, 2)*0.5):end));
  248.  
  249. rx_random_neuron = (1/(size(theta(:, end/2+1:end), 2)))*sum(cos(theta(:, end/2+1:end)')); % Sum of mean x-part of theta
  250. ry_random_neuron = (1/(size(theta(:, end/2+1:end), 2)))*sum(sin(theta(:, end/2+1:end)')); % Sum of mean y-part of theta
  251. r_random_neuron = sqrt(rx_random_neuron.*rx_random_neuron + ry_random_neuron.*ry_random_neuron);
  252. r_random_neuron_mean = mean(r_random_neuron(:, round(size(r_random_neuron, 2)*0.5):end));
  253.  
  254. % fid = fopen('r_sigma_N50_sG0.500_sGN0.370_sN0.500.txt', 'at');
  255. % fprintf(fid, '%f\t %f\t %f \n', [r_total_mean r_wired_glial_mean r_random_neuron_mean]');
  256. % %dlmwrite('r_data.txt', [r_total_mean r_wired_glial_mean r_random_neuron_mean], '-append');
  257. % fclose(fid);
  258.  
  259. figure('units', 'normalized', 'outerposition', [0 0 1 1]);
  260. %plot(time, rx_total, 'g');
  261. %hold on;
  262. %plot(time, ry_total, 'b');
  263. %hold on;
  264. plot(time, r_total, 'k', time, r_wired_glial, 'r', time, r_random_neuron, 'b');
  265. %plot(time, r_wired_glial, 'r', time, r_random_neuron, 'b');
  266. %title('Kuramoto C results on MacBook Pro');
  267. hold on;
  268. line([time(round(size(r_total, 2)*0.5)) time(end)], [r_total_mean r_total_mean], 'Color', 'k', 'LineWidth', 2);
  269. hold on;
  270. line([time(round(size(r_wired_glial, 2)*0.5)) time(size(r_wired_glial, 2))], [r_wired_glial_mean r_wired_glial_mean], 'Color', 'r', 'LineWidth', 2);
  271. hold on;
  272. line([time(round(size(r_random_neuron, 2)*0.5)) time(size(r_random_neuron, 2))], [r_random_neuron_mean r_random_neuron_mean], 'Color', 'b', 'LineWidth', 2);
  273. hold on;
  274. %grid on;
  275. legend('r_{total}', 'r_{wired glial}', 'r_{random neuron}', 'r_{total mean}', 'r_{wired glial mean}', 'r_{random neuron mean}', 'Location', 'east');
  276. %legend('r_{wired glial}', 'r_{random neuron}', 'r_{wired glial mean}', 'r_{random neuron mean}', 'Location', 'east');
  277. set(gca, 'FontSize', 28);
  278. xlabel('Time, msec', 'FontSize', 50);
  279. ylabel('Mean field', 'FontSize', 50);
  280. ylim([0 1]);
  281. %saveas(gcf, 'r_order.png');
  282. saveas(gcf, 'r_order', 'epsc');
Advertisement
Add Comment
Please, Sign In to add comment