load cell_times.txt; load LP_wav.txt; load MVN_wav.txt; load PD_wav.txt; load PY_wav.txt; frame_rate = 30; window = 5; max_time = max(max(cell_times)) + 1; num_frames = max_time * frame_rate; displacement = 0.1; M = moviein(num_frames); [cell_X, cell_Y, cell_Z] = sphere(40); warning off MATLAB:divideByZero Cells = {'IC' 'AB/PD' 'LP' 'VD' 'PY'}; pos_x = [ 5 1.5 -1.5 0 -5]; pos_y = [ 0 2.5 2.5 7 0]; % Cells IC AB/PD LP VD PY connect = [ 0 1 0 1 1; ...% IC 0 0 1 2 0; ...% AB/PD 0 1 0 1 1; ...% LP 1 1 1 0 0; ...% VD 0 1 2 1 0]; % PY current_time = ones(size(pos_x)); H = gcf; set(H, 'Position', [50 100 800 600]); for j = 1 : num_frames, clf; AH1 = subplot('position', [(1/20) (1/4) (9/20) (1/2)]); hold on; for i = 1 : length(pos_x) if (cell_times(current_time(i), i) < ((j + 1) / frame_rate)), color = [1.0 0.0 0.0]; current_time(i) = current_time(i) + 1; else color = [0.8 0.8 0.8]; end; surf(cell_X + pos_x(i), cell_Y + pos_y(i), cell_Z, ... 'EdgeColor', 'none', 'FaceColor', color, 'FaceLighting', 'Phong'); text(pos_x(i), pos_y(i), 2,Cells(i), 'Color', [1 1 1], ... 'HorizontalAlignment', 'center', 'FontSize', 12, 'FontWeight', 'bold'); % lines for k = 1 : length(pos_x), if connect(k, i) > 0, angle = atan((pos_y(k) - pos_y(i)) / (pos_x(k) - pos_x(i))); if (pos_x(k) - pos_x(i)) < 0, angle = angle + pi; end; if connect(i, k) > 0, displacement_x = displacement * cos(pi / 2 + angle); displacement_y = displacement * sin(pi / 2 + angle); else displacement_x = 0; displacement_y = 0; end; if connect(k, i) == 1, line([pos_x(i); pos_x(k) - 1.2 * cos(angle)] + displacement_x, ... [pos_y(i); pos_y(k) - 1.2 * sin(angle)] + displacement_y, ... 'Color', color, 'LineWidth', 2, 'Marker', 'o', 'MarkerSize', 6, 'MarkerFaceColor', color); end; if connect(k, i) == 2, line([pos_x(i); pos_x(k)] + displacement_x, ... [pos_y(i); pos_y(k)] + displacement_y, ... 'Color', color, 'LineWidth', 2); line([pos_x(k) - 1.5 * cos(angle) + 0.1 * cos(angle + pi / 2); ... pos_x(k) - 1.5 * cos(angle) + 0.1 * cos(angle - pi / 2)] + displacement_x, ... [pos_y(k) - 1.5 * sin(angle) + 0.1 * sin(angle + pi / 2); ... pos_y(k) - 1.5 * sin(angle) + 0.1 * sin(angle - pi / 2)] + displacement_y, ... 'Color', color, 'LineWidth', 2); patch([pos_x(k) - 1.5 * cos(angle); ... pos_x(k) - 1.7 * cos(angle) + 0.1 * cos(angle + pi / 2); ... pos_x(k) - 1.7 * cos(angle) + 0.1 * cos(angle - pi / 2)] + displacement_x, ... [pos_y(k) - 1.5 * sin(angle); ... pos_y(k) - 1.7 * sin(angle) + 0.1 * sin(angle + pi / 2); ... pos_y(k) - 1.7 * sin(angle) + 0.1 * sin(angle - pi / 2)] + displacement_y, ... color, 'EdgeColor', 'none', 'FaceLighting', 'none'); end; end; end; end; light('Position', [15 5 2], 'Color', [1 0 0]); light('Position', [10 10 2], 'Color', [0 1 0]); light('Position', [ 5 15 2], 'Color', [0 0 1]); axis equal; subplot('position', [(12/20) (16/21) (7/20) (4/21)]); plot(LP_wav(:, 1), LP_wav(:, 2)); ylabel('LP'); axis([(j / frame_rate - window) (j / frame_rate) (-80) (-20)]); subplot('position', [(12/20) (11/21) (7/20) (4/21)]); plot(PD_wav(:, 1), PD_wav(:, 2)); ylabel('PD'); axis([(j / frame_rate - window) (j / frame_rate) (-80) (-20)]); subplot('position', [(12/20) (6/21) (7/20) (4/21)]); plot(PY_wav(:, 1), PY_wav(:, 2)); ylabel('PY'); axis([(j / frame_rate - window) (j / frame_rate) (-80) (-20)]); subplot('position', [(12/20) (1/21) (7/20) (4/21)]); plot(MVN_wav(:, 1),MVN_wav(:, 2)); ylabel('MVN'); axis([(j / frame_rate - window) (j / frame_rate) (-1.5) (1.5)]); set(AH1, 'Box', 'on', 'XTick', [], 'YTick', [], 'ZTick', [], 'XColor', [0 0 0], 'YColor', [0 0 0]) M(j) = getframe(H); disp(j/num_frames) end; %movie2avi(M, 'net.avi', 'compression','none'); mpgwrite(M, jet, 'net.mpeg'); exit