mydefaultfonts; close all; clear all; %name_dataset = 'MAX_Maph-1_lifeact_w2_crop-2_t=01'; name_dataset = 'MAX_Maph-1_lifeact_w2_crop-2_t=36'; %name_dataset = 'MAX_Maph-1_lifeact_w3_crop-2_t=01'; %name_dataset = 'MAX_Maph-1_lifeact_w3_crop-2_t=29'; %name_dataset = 'MAX_Maph-1_lifeact_w6_crop-2_t=18'; %name_dataset = 'MAX_Maph-1_lifeact_w6_crop-2_t=01'; Dat = xlsread(['Data/Table_' name_dataset '.xlsx']); if(strcmp(name_dataset,'MAX_Maph-1_lifeact_w3_crop-2_t=29')==1) xhole = 89; yhole = 126; radius_internal = 15; radius_external = 28; radius_external_2 = 25; radius_external_3 = 40; filter_on = 3; coherence_threshold = 0.10; elseif(strcmp(name_dataset,'MAX_Maph-1_lifeact_w3_crop-2_t=01')==1) xhole = 89; yhole = 126; radius_internal = 10; radius_external = 18; radius_external_2 = 25; radius_external_3 = 50; filter_on = 0; coherence_threshold = 0.10; elseif(strcmp(name_dataset,'MAX_Maph-1_lifeact_w6_crop-2_t=18')==1) xhole = 110; yhole = 122; radius_internal = 8; radius_external = 20; radius_external_2 = 25; radius_external_3 = 50; filter_on = 0; coherence_threshold = 0.30; elseif(strcmp(name_dataset,'MAX_Maph-1_lifeact_w6_crop-2_t=01')==1) xhole = 110; yhole = 122; radius_internal = 8; radius_external = 20; radius_external_2 = 25; radius_external_3 = 50; filter_on = 0; coherence_threshold = 0.30; elseif(strcmp(name_dataset,'MAX_Maph-1_lifeact_w2_crop-2_t=36')==1) xhole = 112; yhole = 93; radius_internal = 15; radius_external = 30; radius_external_2 = 40; radius_external_3 = 50; filter_on = 3; coherence_threshold = 0.1; elseif(strcmp(name_dataset,'MAX_Maph-1_lifeact_w2_crop-2_t=01')==1) xhole = 112; yhole = 93; radius_internal = 15; radius_external = 30; radius_external_2 = 40; radius_external_3 = 50; filter_on = 0; coherence_threshold = 0; end fiber_orientation = atan2(Dat(:,5),Dat(:,4)); theta_orientation = atan2(Dat(:,2) - yhole,Dat(:,1) - xhole); %diff_theta = fiber_orientation-theta_orientation; dot_product = abs(Dat(:,4).*(Dat(:,1) - xhole)+Dat(:,5).*(Dat(:,2) - yhole)); nor_product = sqrt(power(Dat(:,5),2)+power(Dat(:,4),2)).*sqrt(power(Dat(:,1) - xhole,2)+power(Dat(:,2) - yhole,2)); diff_theta = acos(dot_product./nor_product); proj = @(x) x; %proj = @(x) mod(x,pi./2); index_other = find(Dat(:,7)- coherence_threshold > 0); if(filter_on==1) index_other = intersect(index_other,find(Dat(:,1)-xhole > 0)); elseif(filter_on==2) index_other = intersect(index_other,find(Dat(:,1)-xhole < 0)); elseif(filter_on==3) index_other = intersect(index_other,find(Dat(:,2)-yhole > 0)); end % Filters all points which are closer to center of whole than threshold distance_to_ablation_site = sqrt(power(Dat(:,1)-xhole,2)+power(Dat(:,2)-yhole,2)); index_nottoofar = find(distance_to_ablation_site < radius_external); index_nottooclose = find(distance_to_ablation_site > radius_internal); good_indices_1 = intersect(index_nottoofar,index_nottooclose); good_indices_1 = intersect(index_other,good_indices_1); index_nottoofar = find(distance_to_ablation_site < radius_external_3); index_nottooclose = find(distance_to_ablation_site > radius_external_2); good_indices_2 = intersect(index_nottoofar,index_nottooclose); good_indices_2 = intersect(index_other,good_indices_2); good_indices_3 = find(distance_to_ablation_site > 1*radius_external_3); good_indices_3 = intersect(index_other,good_indices_3); %%%%%%%%%%%%%%%% I = imread(['Data/' name_dataset '.tif']); h12 = figure('PaperPositionMode','auto'); set(h12, 'Visible', 'on'); hold on; hold all; screen_dpi = get(0, 'ScreenPixelsPerInch'); screen_display_factor = 500; h1 = imshow(I,[],'InitialMagnification',screen_display_factor,'Border','tight'); h1.AlphaData = 0.6; colormap('gray'); theta = linspace(0,2*pi,50); line(xhole + 1.*cos(theta),yhole + 1.*sin(theta),'color',[1 1 1],'LineWidth', 5); line(xhole + radius_internal.*cos(theta),yhole + radius_internal.*sin(theta),'color',[0 0 1],'LineWidth', 1); line(xhole + radius_external.*cos(theta),yhole + radius_external.*sin(theta),'color',[0 0 1],'LineWidth', 1); line(xhole + radius_external_2.*cos(theta),yhole + radius_external_2.*sin(theta),'color',[1 0 0],'LineWidth', 1); line(xhole + radius_external_3.*cos(theta),yhole + radius_external_3.*sin(theta),'color',[1 0 0],'LineWidth', 1); for iv=1:length(good_indices_1) ix = good_indices_1(iv); line([Dat(ix,1)-5.*Dat(ix,4) Dat(ix,1)+5.*Dat(ix,4)],[Dat(ix,2)-5.*Dat(ix,5) Dat(ix,2)+5.*Dat(ix,5)],'color',[0 0 1],'LineWidth',2,'MarkerFaceColor',[0 0 1]); end %remove_assholes = find(diff_theta > pi./4); %good_indices_2 = intersect(good_indices_2,remove_assholes); for iv=1:length(good_indices_2) ix = good_indices_2(iv); line([Dat(ix,1)-5.*Dat(ix,4) Dat(ix,1)+5.*Dat(ix,4)],[Dat(ix,2)-5.*Dat(ix,5) Dat(ix,2)+5.*Dat(ix,5)],'color',[1 0 0],'LineWidth',2,'MarkerFaceColor',[1 0 0]); end for iv=1:length(good_indices_3) ix = good_indices_3(iv); line([Dat(ix,1)-5.*Dat(ix,4) Dat(ix,1)+5.*Dat(ix,4)],[Dat(ix,2)-5.*Dat(ix,5) Dat(ix,2)+5.*Dat(ix,5)],'color',[0 1 0],'LineWidth',2,'MarkerFaceColor',[0 1 0]); end %for ix=1:length(Dat(:,1)) % line([Dat(ix,1)-5.*Dat(ix,4) Dat(ix,1)+5.*Dat(ix,4)],[Dat(ix,2)-5.*Dat(ix,5) Dat(ix,2)+5.*Dat(ix,5)],'color',[0.5 0 0],'LineWidth',0.5,'MarkerFaceColor',[0.5 0 0]); %end axis equal; axis tight; saveas(h12,['Results/' name_dataset 'rawimage.tiff']) Fig1 = figure(6); set(Fig1, 'Name', 'Histogram of Angle', 'Position', [100 500 600 400]); %polarhistogram(pi.*vec./180,2,'FaceColor','red','FaceAlpha',.3); polarhistogram(proj(diff_theta(good_indices_1)),5); %rose(pi.*vec2./180,30); set(gca, 'FontSize', 30); ax = gca; ax.ThetaLim = [0 90]; saveas(Fig1, ['Results/' name_dataset 'angle.svg']); saveas(Fig1, ['Results/' name_dataset 'angle.fig']); saveas(Fig1, ['Results/' name_dataset 'angle.png']); Fig1 = figure(8); set(Fig1, 'Name', 'Histogram of Angle', 'Position', [100 500 600 400]); %polarhistogram(pi.*vec./180,2,'FaceColor','red','FaceAlpha',.3); polarhistogram(proj(diff_theta(good_indices_2)),10,'FaceColor','red','FaceAlpha',.3); %rose(pi.*vec2./180,30); set(gca, 'FontSize', 30); ax = gca; ax.ThetaLim = [0 90]; saveas(Fig1, ['Results/' name_dataset 'angle_externallayer.svg']); saveas(Fig1, ['Results/' name_dataset 'angle_externallayer.fig']); saveas(Fig1, ['Results/' name_dataset 'angle_externallayer.png']); Fig1 = figure(9); set(Fig1, 'Name', 'Histogram of Angle', 'Position', [100 500 600 400]); %polarhistogram(pi.*vec./180,2,'FaceColor','red','FaceAlpha',.3); polarhistogram(proj(diff_theta(good_indices_3)),10,'FaceColor','green','FaceAlpha',.3); %rose(pi.*vec2./180,30); set(gca, 'FontSize', 30); ax = gca; ax.ThetaLim = [0 90]; saveas(Fig1, ['Results/' name_dataset 'angle_control.svg']); saveas(Fig1, ['Results/' name_dataset 'angle_control.fig']); saveas(Fig1, ['Results/' name_dataset 'angle_control.png']); data_1 = 90.*proj(diff_theta(good_indices_1))./(pi./2); data_2 = 90.*proj(diff_theta(good_indices_2))./(pi./2); data_3 = 90.*proj(diff_theta(good_indices_3))./(pi./2); g1 = repmat({'Region 1'},length(data_1),1); g2 = repmat({'Region 2'},length(data_2),1); g3 = repmat({'Region 3'},length(data_3),1); g = [g1; g2; g3]; total = [data_1',data_2' data_3']; fig1 = figure(100); h = boxplot(total,g,'PlotStyle','traditional','Whisker', 0); ylabel('Angle'); ylim([0 90]); saveas(fig1, ['Results/' name_dataset 'angle_histo.svg']); saveas(fig1, ['Results/' name_dataset 'angle_histo.fig']); saveas(fig1, ['Results/' name_dataset 'angle_histo.png']); save(['Data/workspace/' name_dataset]);