This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36ef7ea
commit 11018e0
Showing
2 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
function cell_sig_merged = alternativePlot(ica_segments, cluster, cell_sig, subPlotCols, sortedIdx, data_r) | ||
cm = colormap(hsv); | ||
tempImage = zeros(size(ica_segments, 2), size(ica_segments, 3), 3); | ||
|
||
for i = 1:subPlotCols | ||
rgb = cm(round(64/subPlotCols * (i-1)+1),:); | ||
for k = cluster{i} | ||
for rgbIdx = 1:3 | ||
mask = squeeze(ica_segments(sortedIdx(k),:,:)); | ||
%transform mask to only outlines | ||
mask = imfill(mask, 'holes'); | ||
mask = bwboundaries(mask); | ||
mask = mask{:}; | ||
%create image with drawn lines between points | ||
linemask = zeros(size(ica_segments, 2), size(ica_segments, 3)); | ||
for l = 1:size(mask,1) | ||
linemask(mask(l,1),mask(l,2)) = 1; | ||
end | ||
|
||
tempImage(:,:,rgbIdx) = tempImage(:,:,rgbIdx) + rgb(rgbIdx)*linemask; | ||
end | ||
end | ||
end | ||
%set pixels 0 which are smaller than 0, seems to happen in rare cases.. | ||
for i = 1:3 | ||
tempImage(:,:,i) = (tempImage(:,:,i) > 0).*tempImage(:,:,i); | ||
end | ||
%scale tempImage | ||
% maximum = max(tempImage(:)); | ||
% minimum = min(tempImage(:)); | ||
% tempImage = uint16(65535*(tempImage - minimum)/(maximum-minimum)); | ||
tempImage = uint16(tempImage*65535); | ||
|
||
%make background white | ||
% blackMask = uint16(all((tempImage < 1),3)); | ||
% for i = 1:3 | ||
% tempImage(:,:,i) = blackMask * 65535 + tempImage(:,:,i); | ||
% end | ||
meanImage = mean(data_r,3); | ||
maximum = max(meanImage(:)); | ||
minimum = min(meanImage(:)); | ||
meanImage = (meanImage - minimum)/(maximum-minimum); | ||
meanImage = uint16(imadjust(meanImage, [0, 1], [0, 1], 0.4)*65535); | ||
%copy meanImage in every colorchannel | ||
for i = 1:3 | ||
tempImage(:,:,i) = tempImage(:,:,i) + meanImage; | ||
end | ||
|
||
subplot(1,2,1); | ||
imshow(tempImage); | ||
%draw number in each roi | ||
for drawNumberCt = 1:size(cluster{i}) | ||
number = cluster{i}(drawNumberCt); | ||
end | ||
subplot(1,2,2); | ||
hold on | ||
cell_sigPlot = cell_sig(sortedIdx,:); | ||
|
||
|
||
|
||
signal = zeros(size(cluster,2),size(cell_sig,2)); | ||
for i = 1:size(cluster, 2) | ||
cell_sig_merged{i} = mean(cell_sig_merged{i}(cluster{i},:), 1); | ||
for clusterIdx = cluster{i} | ||
%subtract minimum value | ||
minimum = min(cell_sigPlot(clusterIdx,:)); | ||
cell_sigPlot(clusterIdx,:) = cell_sigPlot(clusterIdx,:) - minimum; | ||
%norm cell signals | ||
integral = median(cell_sigPlot(clusterIdx,:)); | ||
cell_sigPlot(clusterIdx,:)=cell_sigPlot(clusterIdx,:)/abs(integral); | ||
end | ||
%mean value of all cluster signals | ||
signal(i,:) = mean(cell_sigPlot(cluster{i},:), 1); | ||
%add maximum position from signal from before | ||
if i ~= 1 | ||
%maximum = max(signal(i-1,:)); | ||
maximum = max(max(cell_sigPlot(cluster{i-1},:))); | ||
else | ||
maximum = 0; | ||
end | ||
signal(i,:) = signal(i,:) + maximum; | ||
rgb = cm(round(64/subPlotCols * (i-1)+1),:); | ||
plot(signal(i,:), 'Color', rgb); | ||
text(size(signal,2), maximum, num2str(i)) | ||
%plot single components dotted | ||
for clusterIdx = cluster{i} | ||
cell_sigPlot(clusterIdx,:) = cell_sigPlot(clusterIdx,:) + maximum; | ||
plot(cell_sigPlot(clusterIdx, :),':', 'Color', rgb); | ||
end | ||
end | ||
xlim([0,size(signal,2)]); | ||
%maximum = max(cell_sigPlot(:)); | ||
ylim auto;%([0, maximum]); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters