-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAFM_Profile_analysis_flatten.m
More file actions
153 lines (107 loc) · 4.2 KB
/
AFM_Profile_analysis_flatten.m
File metadata and controls
153 lines (107 loc) · 4.2 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
% This script is an adaptation from the script I initially wrote to analyze
% STED images. Pixel sizes (px) and height color scale (zscale) have to be manually
% entered before running the program.
close all
clear all
clc
ScriptFolder = '/Users/christine/Documents/Git/AFM-analysis' ;
%% Get titles and define parameters
cd('/Users/christine/Documents/Data/AFM/Full NPC databank/raw_data')
conditions = {'1um';'1.5um';'2um';'2.5um';'3um';'4um'};
px=7.81; % pixel size in nm
L=251; % size of the ROI in nm
l=round(L/px)/2;
zscale = 150/255; % conversion from grey levels to nm
for k=3:3
folder=conditions{k};
[num,txt,raw]=xlsread('FileProperties.xlsx',folder);
n=length(txt);
NPC_Profile=[];
cd('/Users/christine/Documents/Data/AFM/Full NPC databank/2um/2um_crop2')
mkdir('bin20_Flatten')
for i=1:n
i
cd('/Users/christine/Documents/Data/AFM/Full NPC databank/2um/2um_crop2')
name=txt{i}
I=zscale.*double(imread(strcat(name, '_crop.tif')));
cd(ScriptFolder)
[XYZ_array_1] = ImageFlatteningFuncs.Matrix_to_Nx3array(I);
% for plane fitting, take the top 50% of the data
BinWidth_nm = 0.1; % the smaller the value the more accurate the XYZ indexing. 0.1nm should be fine.
Plane_fit_mask_1 = 0.50;
greater_than_1 = 1;
% create new XYZ array of only bottom 50% of data
[XYZ_array_for_plane_fit_1, ~] = ImageFlatteningFuncs.XYZarray_indexed_by_percentage_height(XYZ_array_1, BinWidth_nm, Plane_fit_mask_1, greater_than_1);
% find the plane of the indexed bottom 50% of height data
[plane_1] = ImageFlatteningFuncs.PlaneFit_XYZarray(I, XYZ_array_for_plane_fit_1);
% subtract plane from data. This operation also brings the rim of the
% pore to height_rim_pore_nm (usually set to 35 nm).
height_rim_pore_nm = 35;
Iflat = (I - plane_1) + height_rim_pore_nm;
cd(ScriptFolder)
% define parameters
w=round(L/2);
bin=25; % binning of the intensity profile
NPC_Prof=[];
xo=l+1; yo=l+1;
figure(i)
subplot(2,2,1)
imshow(I)
hold on
plot(xo,yo,'.r')
hold off
subplot(2,2,3)
imshow(I)
b=0;
for a=0:pi/20:39*pi/20 %
b=b+1;
[xi,yi,x,Profile_a1]=intensityPlot(Iflat,xo,yo,a,w,bin,px);
NPC_Prof=[NPC_Prof; Profile_a1'];
cmap=jet(40);
figure(i)
subplot(2,2,3)
hold on
plot(xi,yi,'Color',cmap(b,:))
hold off
subplot(2,2,[2,4])
hold on
plot(x,Profile_a1','Color',cmap(b,:));
hold off
%}
end
NPC_Profile_j=nanmean(NPC_Prof);
figure(i)
subplot(2,2,[2,4])
hold on
plot(x,NPC_Profile_j,'Color','k','LineWidth',2)
hold off
cd('/Users/christine/Documents/Data/AFM/Full NPC databank/2um/2um_crop2/bin20_Flatten')
saveas(gca,strcat('2um_',num2str(i),'_2pi.fig'),'fig');
saveas(gca,strcat('2um_',num2str(i),'_2pi.tif'),'tiff');
saveas(gca,strcat('2um_',num2str(i),'_2pi.jpg'),'jpeg')
close
%}
figure(n+1)
hold on
plot(x,NPC_Profile_j)
hold off
NPC_Profile=[NPC_Profile; NPC_Profile_j];
end
mean_Profile=nanmean(NPC_Profile);
std_Profile=nanstd(NPC_Profile);
figure(n+1)
hold on
plot(x,mean_Profile,'Color','k','LineWidth',2)
hold off
cd('/Users/christine/Documents/Data/AFM/Full NPC databank/2um/2um_crop2/bin20_Flatten')
saveas(gca,'2um_NPCs_2pi.tif','tiff');
saveas(gca,'2um_NPCs_2pi.jpg','jpeg');
T=table(NPC_Profile);
writetable(T, 'NPC_Profiles_2um_2pi.txt');
MP=table(mean_Profile);
writetable(MP,'Mean_NPC_2um_2pi.txt');
SP=table(std_Profile);
writetable(SP,'Std_NPC_2um_2pi.txt')
X=table(x);
writetable(X,'ProfileCoordinates_2pi.txt')
end