-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeasureZ.bsh
83 lines (70 loc) · 1.97 KB
/
measureZ.bsh
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
/**
* Micro-Manager script that measures the z position at all positions in the position list
*/
outputFile = "D:\\Users\\Susana\\20150512\\posWholePlate3.txt";
nrColumns = 12;
nrRows = 8;
zDrive = "TIZDrive";
////////// Do NOT edit below this line
import org.micromanager.api.MultiStagePosition;
resultsFile = new File(outputFile);
resultsFile.createNewFile();
resultsWriter = new BufferedWriter(new FileWriter(resultsFile));
posList = gui.getPositionList();
positions = posList.getPositions();
currentWell = "";
count = 0;
sitesPerWell = 0;
wellCount = 0;
// first get out how many positions per well we have
for (int p = 0; p < positions.length; p++) {
msp = positions[p];
label = msp.getLabel();
well = label.split("-")[0];
if (!currentWell.equals(well)) {
currentWell = well;
wellCount++;
sitesPerWell = 1;
} else
sitesPerWell++;
}
nPerRow = Math.sqrt(sitesPerWell);
nPerRow = (int) nPerRow;
gui.message("" + sitesPerWell + " sites per well, " + wellCount + " wells, " + nPerRow + "rows/columns");
// this will only work with square sites per well
double[][][] zValues = new double[wellCount][nPerRow][nPerRow];
// now visit them all and record z positions after locking the PFS
wi = 0;
ri = 0;
ci = 0;
for (int p = 0; p < positions.length; p++) {
msp = positions[p];
label = msp.getLabel();
well = label.split("-")[0];
MultiStagePosition.goToPosition(msp, mmc);
//gui.sleep(200);
mmc.fullFocus();
gui.message("well " + wi + ", " + ri + ", " + ci);
zValues[wi][ri][ci] = mmc.getPosition(zDrive);
ci++;
if (ci == nPerRow) {
ci = 0;
ri++;
}
if (ri == nPerRow) {
ri = 0;
wi++;
}
}
for (int r = 0; r < nrRows; r++) {
for (int rr = 0; rr < nPerRow; rr++) {
for (int sr = 0; sr < nPerRow * nrColumns; sr++) {
wellIndex = r * nrColumns + sr / nPerRow;
cci = sr % nPerRow;
gui.message("" + wellIndex + ", " + rr + ", " + cci);
resultsWriter.write("" + zValues[wellIndex][rr][cci] + "\t" );
}
resultsWriter.newLine();
}
}
resultsWriter.close();