-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_stackInfo.m
More file actions
47 lines (35 loc) · 1.9 KB
/
get_stackInfo.m
File metadata and controls
47 lines (35 loc) · 1.9 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
function stackInfo = get_stackInfo(raw_path)
disp('Fetching stackInfo: metadata from image files...');
%Header info from scim_openTif()
warning('off','imageio:tiffmexutils:libtiffWarning'); %Issue with scim_openTif(): Warning: TIFF library warning - 'TIFFFetchNormalTag: ASCII value for tag "ImageDescription" does not end in null byte.'
header = scim_openTif(raw_path{1});
stackInfo.imageWidth = header.acq.pixelsPerLine;
stackInfo.imageHeight = header.acq.linesPerFrame;
stackInfo.frameRate = header.acq.frameRate;
stackInfo.zoomFactor = header.acq.zoomFactor;
stackInfo.nChans = header.acq.numberOfChannelsSave;
for i = 1:numel(raw_path)
%Waitbar
f = waitbar(0);
msg = ['Processing stack ' num2str(i) '/' num2str(numel(raw_path)) '...'];
waitbar(i/numel(raw_path),f,msg);
%Filename from raw substacks
[~,fname,ext] = fileparts(raw_path{i});
stackInfo.rawFileName{i} = [fname ext];
%Number of frames per substack
stackInfo.nFrames(i) = length(imfinfo(raw_path{i}))/stackInfo.nChans;
%Get trigger timestamp and delay from scim_openTif()
header = scim_openTif(raw_path{i}); %Get header info
trigTime = datetime(header.internal.triggerTimeString,'InputFormat','M/d/yyyy H:m:s.SSS'); %As datetime for easier calculations
firstTrigTime = datetime(header.internal.triggerTimeFirstString,'InputFormat','M/d/yyyy H:m:s.SSS');
%Store trigger time as difference in seconds between current trigger and first trigger timestamps
stackInfo.trigTime(i) = seconds(trigTime - firstTrigTime); %Time from first trigger in seconds
stackInfo.trigDelay(i) = header.internal.triggerFrameDelayMS/1000; %Delay in seconds between trigger and time of first pixel in frame
end
%All column vectors
fields = fieldnames(stackInfo);
for i = 1:numel(fields)
stackInfo.(fields{i}) = stackInfo.(fields{i})(:);
end
warning('on','all');
close(f);