-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreatment_Timeseries_Labeler.ijm
More file actions
58 lines (45 loc) · 1.79 KB
/
Treatment_Timeseries_Labeler.ijm
File metadata and controls
58 lines (45 loc) · 1.79 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
// @Integer(label="Seconds between treatment and experiment start") treatmentExperimentDiff
// @String(label="Time unit for conversion", choices={"s", "min", "h"}) timeUnit
// @Integer(label="Shown decimal points of times") decimalPoints
/*
* This macro reads metainformation about the "deltaT" from the file
* of the currently open image. It uses Bio-Formats to get the
* information about the time between the experiment start and the
* acquisition start.
*
* Stefan Helfrich (University of Konstanz), 07/14/2016
*/
// Enable Bio-Formats macro extensions
run("Bio-Formats Macro Extensions");
// Load file for the currently open image
openImagePath = getInfo("image.directory")+getInfo("image.filename")
Ext.setId(openImagePath);
// Extract position from the title of the open image
positionToLoad = parsePositionFromTitle(getTitle()) - 1; // index shift
Ext.setSeries(positionToLoad);
treatmentExperimentDiff = convertDuration(treatmentExperimentDiff, timeUnit);
// Obtain deltaT from the metadata
deltaT = 0;
Ext.getPlaneTimingDeltaT(deltaT, 0);
deltaT = convertDuration(deltaT, timeUnit);
// Obtain frame interval
frameInterval = Stack.getFrameInterval();
frameInterval = convertDuration(frameInterval, timeUnit);
// Make the timestamp
makeTimestamp(treatmentExperimentDiff+deltaT, frameInterval, timeUnit);
function convertDuration(duration, timeUnit) {
if (timeUnit == "min") {
return duration / 60;
} else if (timeUnit == "h") {
return duration / 3600;
}
return duration;
}
function makeTimestamp(start, interval, timeUnit) {
run("Time Stamper", "starting=&start interval=&interval decimal=&decimalPoints anti-aliased or=&timeUnit");
}
function parsePositionFromTitle(title) {
idx = lastIndexOf(title, "#");
position = substring(title, idx+1, lengthOf(title));
return parseInt(position);
}