-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRasterPlot.m
More file actions
74 lines (61 loc) · 2.12 KB
/
RasterPlot.m
File metadata and controls
74 lines (61 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function [raster, raster_fig] = RasterPlot(smooth_signal, calcium_transients, signal_info, timePointName)
%% Function that creates a raster for the dataset
%
% Need to run ProcessNeuroCa.m and then smoothCalciumSignals.m prior to this function
%
% INPUTS:
% smooth_signal = smoothed dF/F of every cell (generated by "smoothCalciumSignals.m")
%
% pc_locs = frame # of each calcium transient peak in each cell
%
% time_axis = % time_axis = time (seconds)
%
% f_end = variable calculated in f_end to ensure a standard signal window of 120 seconds
% (created using "ProcessNeuroCa.m")
%
% OUTPUTS
% raster = matrix of 0's and 1's to represent where calcium transient peaks
% are located in the entire network (matrix includes both active and
% inactive cells)
%
% raster_fig = standard raster figure to view entire network activity
%% EXTRACT RELEVANT VARIABLES FROM STRUCT
active_cells = calcium_transients.active_cells;
pk_locs = calcium_transients.peak_locs;
time_axis = signal_info.time;
f_end = signal_info.analysis_window_frames;
%% CALCULATE RASTER MATRIX FOR ONE DATASET
if active_cells == 0
warning(['No active cells in timepoint ',timePointName,'. Raster no generated.'])
raster = [];
raster_fig = figure;
return;
end
total_cells = size(smooth_signal,1); % total number of cells detected by NeuroCa
% create raster matrix
raster = zeros(total_cells, f_end);
% change a value in the raster matrix to 1 where there is a calcium spike peak
% run through peaks from every active cell
for i = 1 : size(pk_locs,1)
cell_num = active_cells(i,1); % cell number
for j = 1 : size(pk_locs(i,:),2)%sum(~isnan(pk_locs(i,:)))
if isnan(pk_locs(i,j))
continue
end
frame = pk_locs(i,j); % frame # of calcium peak
raster(cell_num,frame) = 1;
end
end
%% PLOT RASTER
raster_fig = figure;
for i = 1:total_cells
plot(time_axis(1,1:f_end), i*raster(i,1:f_end),'k.','MarkerSize',4)
hold on
end
xlabel('Time (s)')
ylabel('Cell #')
xlim([0 120])
ylim([0.5 size(raster,1)])
title(['Raster - ',timePointName])
hold off
end