-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProfile_intensity_time_course.ijm
135 lines (95 loc) · 2.67 KB
/
Profile_intensity_time_course.ijm
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
//Set output directory
#@ File (label = "Output directory", style = "directory") outDir
//Get the name of the image
name=getTitle;
nameNoExt = split(name, ".");
nameNoExt = nameNoExt[0];
//Get rid of any existing results or ROIs
run("Clear Results");
if (roiManager("Count") > 0)
{
roiManager("Deselect");
roiManager("delete");
}
//Save the line as a ROI (user should have set the correct line thickness)
run("ROI Manager...");
roiManager("Add");
//Get current channel, slice and frame
Stack.getPosition(channel, slice, frame);
thisChannel = channel;
thisSlice = slice;
//Get number of frames
getDimensions(width, height, channels, slices, frames);
numFrames = frames;
//Set initial values for normalisation
maximumIntensity = 0;
minimumIntensity = 1000000;
//Create results directory
lineNumber = 1;
resultsDir = outDir + "/" + name + "_line_" + lineNumber + "_results";
while(File.exists(resultsDir))
{
lineNumber ++;
resultsDir = outDir + "/" + name + "_line_" + lineNumber + "_results";
}
File.makeDirectory(resultsDir);
//Set CSV name for raw results
outCSVRawName = resultsDir + "/Raw_results.csv";
//Set CSV name for normalised results
outCSVNormName = resultsDir + "/Normalised_results.csv";
//Set ROI name
outROIName = resultsDir + "/ROIs.roi";
//Set CSV name for normalised length
outCSVNormLengthsName = resultsDir + "/Normalised_length.csv";
//Save ROI
roiManager("Save", outROIName);
//Calculate normed lengths
profile = getProfile();
for (i=0; i<profile.length; i++)
{
setResult("NormalisedLength", i, i/(profile.length-1));
}
updateResults();
//Save normed length results
saveAs("Measurements", outCSVNormLengthsName);
//Clear results table in preparation for writing raw results
run("Clear Results");
for (i = 1; i <= numFrames; i ++)
{
Stack.setPosition(thisChannel, thisSlice, i);
columnName = "Frame_" + i;
profile = getProfile();
for (j=0; j<profile.length; j++)
{
setResult(columnName, j, profile[j]);
if (profile[j] > maximumIntensity)
{
maximumIntensity = profile[j];
}
if (profile[j] < minimumIntensity)
{
minimumIntensity= profile[j];
}
}
}
updateResults();
//Save raw results
saveAs("Measurements", outCSVRawName);
//Clear results table in preparation for writing normalised results
run("Clear Results");
//Normalise results
for (i = 1; i <= numFrames; i ++)
{
Stack.setPosition(thisChannel, thisSlice, i);
columnName = "Frame_" + i;
profile = getProfile();
for (j=0; j<profile.length; j++)
{
normalisedResult = (profile[j] - minimumIntensity) /
(maximumIntensity - minimumIntensity);
setResult(columnName, j, normalisedResult);
}
}
updateResults();
//Save normalised results
saveAs("Measurements", outCSVNormName);