@@ -31,7 +31,7 @@ these IFDs are located in) inside the TIFF image.
31
31
dimensions
32
32
- `ifd_files::OrderedDict{Int, Tuple{String, String}}`: A mapping from IFD
33
33
number to the filepath and UUID of the file it's located in
34
- - `obs_filepaths::Set {String}`: A list of observed filepaths
34
+ - `obs_filepaths::Dict {String, Int }`: A list of observed filepaths mapped to the offset of their IFDs
35
35
- `image::EzXML.Node`: The OMEXML rooted at the current position
36
36
- `dims::NamedTuple`: Sizes of each dimension with the names as keys
37
37
- `tifffile::TiffFile`: A pointer to the root file
@@ -42,7 +42,7 @@ The first two parameters should be then pumped through
42
42
"""
43
43
function ifdindex! (ifd_index:: OrderedDict{Int, NTuple{4, Int}} ,
44
44
ifd_files:: OrderedDict{Int, Tuple{String, String}} ,
45
- obs_filepaths:: Set {String} ,
45
+ obs_filepaths:: Dict {String, Int } ,
46
46
image:: EzXML.Node ,
47
47
dims:: NamedTuple ,
48
48
tifffile:: TiffFile ,
@@ -53,7 +53,7 @@ function ifdindex!(ifd_index::OrderedDict{Int, NTuple{4, Int}},
53
53
ifd = 1
54
54
# this is an offset value since multiple ifds can share the same index if
55
55
# they are split across files, IFD1 (File1), IFD1 (File2), etc
56
- file_ifd_offset = 1
56
+ prev_ifd = 0
57
57
for tiffdata in tiffdatas
58
58
try # if this tiffdata specifies the corresponding IFD
59
59
ifd = parse (Int, tiffdata[" IFD" ]) + 1
@@ -79,11 +79,12 @@ function ifdindex!(ifd_index::OrderedDict{Int, NTuple{4, Int}},
79
79
filepath = joinpath (dirname (tifffile. filepath), internal_filename)
80
80
81
81
# if this file isn't one we've observed before, increment the offset
82
- if ! in (filepath, obs_filepaths)
83
- ifd = file_ifd_offset
84
- file_ifd_offset += 1
85
- push! (obs_filepaths, filepath)
82
+ if ! in (filepath, keys (obs_filepaths))
83
+ obs_filepaths[filepath] = prev_ifd
86
84
end
85
+
86
+ ifd += obs_filepaths[filepath]
87
+
87
88
ifd_files[ifd] = (uuid, filepath)
88
89
end
89
90
@@ -112,6 +113,7 @@ function ifdindex!(ifd_index::OrderedDict{Int, NTuple{4, Int}},
112
113
# all the indices that are not specified, we assume the first index
113
114
ifd_index[ifd] = Tuple (pos > 0 ? pos : 1 for pos in indices)
114
115
end
116
+ prev_ifd = ifd
115
117
end
116
118
end
117
119
0 commit comments