function joint_matrix = showJointgram(averaged_jointgram,opt)
% Get minimal and maximal indexes of j2 and fr_j
j2_array = averaged_jointgram.meta.j(2,:);
fr_j_array = averaged_jointgram.meta.fr_j;
min_j2 = min(j2_array);
max_j2 = max(j2_array);
min_fr_j = min(fr_j_array);
max_fr_j = max(fr_j_array);

% Initialize raster matrix
joint_matrix = zeros(max_fr_j-min_fr_j+1,max_j2-min_j2+1);
weight_matrix = zeros(max_fr_j-min_fr_j+1,max_j2-min_j2+1);
nCells = numel(averaged_jointgram.signal);

% Fill in raster matrix
for cell_index = 1:nCells
	j2_index = j2_array(cell_index)-min_j2+1;
	fr_j_index = fr_j_array(cell_index)-min_fr_j+1;
	% Take expected scattering, i.e. sum over time
	joint_matrix(fr_j_index,j2_index) = ...
		joint_matrix(fr_j_index,j2_index) + ...
		sum(averaged_jointgram.signal{cell_index});
	weight_matrix(fr_j_index,j2_index)= ...
		weight_matrix(fr_j_index,j2_index) + 1;
end

joint_matrix = joint_matrix ./ weight_matrix;


end
