-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_as_OMEtiff_Synthetic_Desc.m
85 lines (50 loc) · 1.98 KB
/
save_as_OMEtiff_Synthetic_Desc.m
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
function save_as_OMEtiff_Synthetic_Gated(ometiffname)
% replace paths for your own machine
addpath('/Users/imunro/FLIMfit/FLIMfitFrontEnd/BFMatlab');
nbins = 3; % No of time bins/gates
% synthetic data
% dimensions here are (x, y , Z, C(hannels) nbins )
data = uint16(ones(2, 2, 1, 1, nbins)) .* 200;
if nbins < 12
delays = 0:1000:(nbins-1)* 1000;
else
delays = 0:(nbins -1);
end
data(:,:,1,1,1) = uint16(400);
data(:,:,1,1,2) = uint16(1000);
data(:,:,1,1,3) = uint16(700);
%data(:,:,1,1,6) = uint16(300);
%data(:,:,1,1,7) = uint16(250);
%data(:,:,1,1,8) = uint16(210);
size(data)
tStart = tic;
% verify that enough memory is allocated
bfCheckJavaMemory();
autoloadBioFormats = 1;
% load the Bio-Formats library into the MATLAB environment
status = bfCheckJavaPath(autoloadBioFormats);
assert(status, ['Missing Bio-Formats library. Either add loci_tools.jar '...
'to the static Java path or add it to the Matlab path.']);
% initialize logging
loci.common.DebugTools.enableLogging('ERROR');
outputPath = [pwd filesep ometiffname];
java.lang.System.setProperty('javax.xml.transform.TransformerFactory', 'com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl');
metadata = createMinimalOMEXMLMetadata(data);
modlo = loci.formats.CoreMetadata();
modlo.moduloT.type = loci.formats.FormatTools.LIFETIME;
modlo.moduloT.unit = 'ps';
% replace with 'TCSPC' if appropriate
modlo.moduloT.typeDescription = 'Gated';
modlo.moduloT.labels = javaArray('java.lang.String',length(delays));
for i=1:length(delays)
modlo.moduloT.labels(i)= java.lang.String(num2str(delays(i)));
end
OMEXMLService = loci.formats.services.OMEXMLServiceImpl();
OMEXMLService.addModuloAlong(metadata,modlo,0);
metadata.setXMLAnnotationID('Annotation:0',0); % might be multiple
metadata.setXMLAnnotationValue('<DescriptiveTextGoesHere/>',0);
if exist(outputPath, 'file') == 2
delete(outputPath);
end
bfsave(data, outputPath, 'metadata', metadata);
tElapsed = toc(tStart)