-
Notifications
You must be signed in to change notification settings - Fork 1
/
acqMN.bsh
104 lines (94 loc) · 3.29 KB
/
acqMN.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* Script used to run another script once for every position during
* a Micro-Manager acquisition
*/
import org.micromanager.api.MultiStagePosition;
import org.micromanager.api.MMAcquisition;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.prefs.Preferences;
import java.awt.Color;
script = "D:\\projects\\mnfinder\\mn2.bsh";
channelGroup = "Channels";
imagingChannel = "Epi-Cy5-PhotoTarget";
afterZapChannel = "Epi-Cherry";
nrImagesPerWell = 100;
saveLocation = "D:\\Users\\Susana\\20150427\\screen2";
saveZappedLocation = saveLocation + "\\Zapped";
/*
script = "/Users/nico/git/mnfinder/mn2.bsh";
channelGroup = "Channel";
imagingChannel = "DAPI";
afterZapChannel = "FITC";
nrImagesPerWell = 2;
saveLocation = "/Users/nico/tmp/testSreen";
saveZappedLocation = saveLocation + "/Zapped";
*/
//////////DO NOT EDIT BELOW THIS LINE////////////////
// maintain some form of persistence using prefs
prefs = Preferences.userNodeForPackage(this.getClass());
gui.closeAllAcquisitions();
new File(saveLocation).mkdirs();
//new File(saveZappedLocation).mkdirs();
resultsFile = new File(saveLocation + File.separator + "results.txt");
resultsFile.createNewFile();
resultsWriter = new BufferedWriter(new FileWriter(resultsFile));
posList = gui.getPositionList();
positions = posList.getPositions();
currentWell = "";
count = 0;
for (int p = 0; p < positions.length; p++) {
msp = positions[p];
label = msp.getLabel();
well = label.split("-")[0];
if (!currentWell.equals(well)) {
gui.message ("Starting well: " + well);
if (!currentWell.equals("")) {
nuclei = prefs.getInt("nuclei", 0);
prefs.putInt("nuclei", 0);
zappedNuclei = prefs.getInt("zappedNuclei", 0);
prefs.putInt("zappedNuclei", 0);
resultsWriter.write(currentWell + "\t" + nuclei + "\t" + zappedNuclei);
resultsWriter.newLine();
resultsWriter.flush();
gui.message(currentWell + " " + nuclei + " " + zappedNuclei);
}
currentWell = well;
gui.openAcquisition(well, saveLocation, 1, 2, 1, nrImagesPerWell, true, true);
wellCount = 0;
}
MultiStagePosition.goToPosition(msp, mmc);
gui.message("Site: " + msp.getLabel());
mmc.setConfig(channelGroup, imagingChannel);
mmc.snapImage();
tImg = mmc.getTaggedImage();
gui.addImageToAcquisition(well, 0, 0, 0, wellCount, tImg);
prefs.putInt("zappedNow", 0);
// run the script recognizing the micronuclei and zapping them
source(script);
zappedNow = prefs.getInt("zappedNow", 0);
if (zappedNow > 0) {
acq2 = msp.getLabel();
gui.message("Imaging zapped cells at site: " + acq2);
// take the red image and save it
mmc.setConfig(channelGroup, afterZapChannel);
mmc.snapImage();
tImg2 = mmc.getTaggedImage();
gui.addImageToAcquisition(well, 0, 1, 0, wellCount, tImg2);
acqObject = gui.getAcquisition(well);
acqObject.setChannelColor(1, new Color(255, 0, 0).getRGB());
mmc.setConfig(channelGroup, imagingChannel);
}
wellCount++;
count++;
}
// record the results from the last well:
nuclei = prefs.getInt("nuclei", 0);
prefs.putInt("nuclei", 0);
zappedNuclei = prefs.getInt("zappedNuclei", 0);
prefs.putInt("zappedNuclei", 0);
resultsWriter.write(currentWell + "\t" + nuclei + "\t" + zappedNuclei);
resultsWriter.newLine();
gui.message(currentWell + " " + nuclei + " " + zappedNuclei);
resultsWriter.close();
gui.message("Analyzed " + count + " images");