line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
2
|
|
|
|
|
|
|
# File: ZISRAW.pm |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Description: Read ZISRAW (CZI) meta information |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Revisions: 2020-08-07 - P. Harvey Created |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# References: 1) https://www.zeiss.com/microscopy/us/products/microscope-software/zen/czi.html |
9
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Image::ExifTool::ZISRAW; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
3367
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
14
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
15
|
1
|
|
|
1
|
|
5
|
use Image::ExifTool qw(:DataAccess :Utils); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1651
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = '1.01'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
%Image::ExifTool::ZISRAW::Main = ( |
20
|
|
|
|
|
|
|
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData, |
21
|
|
|
|
|
|
|
GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' }, |
22
|
|
|
|
|
|
|
NOTES => q{ |
23
|
|
|
|
|
|
|
As well as the header information listed below, ExifTool also extracts the |
24
|
|
|
|
|
|
|
top-level XML-based metadata from Zeiss Integrated Software RAW (ZISRAW) CZI |
25
|
|
|
|
|
|
|
files. |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
0x20 => { |
28
|
|
|
|
|
|
|
Name => 'ZISRAWVersion', |
29
|
|
|
|
|
|
|
Format => 'int32u[2]', |
30
|
|
|
|
|
|
|
PrintConv => '$val =~ tr/ /./; $val', |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
0x30 => { |
33
|
|
|
|
|
|
|
Name => 'PrimaryFileGUID', |
34
|
|
|
|
|
|
|
Format => 'undef[16]', |
35
|
|
|
|
|
|
|
ValueConv => 'unpack("H*",$val)', |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
0x40 => { |
38
|
|
|
|
|
|
|
Name => 'FileGUID', |
39
|
|
|
|
|
|
|
Format => 'undef[16]', |
40
|
|
|
|
|
|
|
ValueConv => 'unpack("H*",$val)', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
45
|
|
|
|
|
|
|
# Shorten obscenely long CZI tag names |
46
|
|
|
|
|
|
|
# Inputs: Tag name |
47
|
|
|
|
|
|
|
# Returns: Shortened tag name |
48
|
|
|
|
|
|
|
sub ShortenTagNames($) |
49
|
|
|
|
|
|
|
{ |
50
|
27
|
|
|
27
|
0
|
33
|
local $_; |
51
|
27
|
|
|
|
|
37
|
$_ = shift; |
52
|
27
|
|
|
|
|
90
|
s/^HardwareSetting//; |
53
|
27
|
|
|
|
|
41
|
s/^DevicesDevice/Device/; |
54
|
27
|
|
|
|
|
34
|
s/LightPathNode//g; |
55
|
27
|
|
|
|
|
47
|
s/Successors//g; |
56
|
27
|
|
|
|
|
33
|
s/ExperimentExperiment/Experiment/g; |
57
|
27
|
|
|
|
|
32
|
s/ObjectivesObjective/Objective/; |
58
|
27
|
|
|
|
|
33
|
s/ChannelsChannel/Channel/; |
59
|
27
|
|
|
|
|
32
|
s/TubeLensesTubeLens/TubeLens/; |
60
|
27
|
|
|
|
|
32
|
s/^ExperimentHardwareSettingsPoolHardwareSetting/HardwareSetting/; |
61
|
27
|
|
|
|
|
29
|
s/SharpnessMeasureSetSharpnessMeasure/Sharpness/; |
62
|
27
|
|
|
|
|
31
|
s/FocusSetupAutofocusSetup/Autofocus/; |
63
|
27
|
|
|
|
|
30
|
s/TracksTrack/Track/; |
64
|
27
|
|
|
|
|
33
|
s/ChannelRefsChannelRef/ChannelRef/; |
65
|
27
|
|
|
|
|
33
|
s/ChangerChanger/Changer/; |
66
|
27
|
|
|
|
|
28
|
s/ElementsChangerElement/Changer/; |
67
|
27
|
|
|
|
|
31
|
s/ChangerElements/Changer/; |
68
|
27
|
|
|
|
|
30
|
s/ContrastChangerContrast/Contrast/; |
69
|
27
|
|
|
|
|
28
|
s/KeyFunctionsKeyFunction/KeyFunction/; |
70
|
27
|
|
|
|
|
35
|
s/ManagerContrastManager(Contrast)?/ManagerContrast/; |
71
|
27
|
|
|
|
|
29
|
s/ObjectiveChangerObjective/ObjectiveChanger/; |
72
|
27
|
|
|
|
|
30
|
s/ManagerLightManager/ManagerLight/; |
73
|
27
|
|
|
|
|
29
|
s/WavelengthAreasWavelengthArea/WavelengthArea/; |
74
|
27
|
|
|
|
|
31
|
s/ReflectorChangerReflector/ReflectorChanger/; |
75
|
27
|
|
|
|
|
32
|
s/^StageStageAxesStageAxis/StageAxis/; |
76
|
27
|
|
|
|
|
30
|
s/ShutterChangerShutter/ShutterChanger/; |
77
|
27
|
|
|
|
|
28
|
s/OnOffChangerOnOff/OnOffChanger/; |
78
|
27
|
|
|
|
|
30
|
s/UnsharpMaskStateUnsharpMask/UnsharpMask/; |
79
|
27
|
|
|
|
|
39
|
s/Acquisition/Acq/; |
80
|
27
|
|
|
|
|
35
|
s/Continuous/Cont/; |
81
|
27
|
|
|
|
|
32
|
s/Resolution/Res/; |
82
|
27
|
|
|
|
|
30
|
s/Experiment/Expt/g; |
83
|
27
|
|
|
|
|
28
|
s/Threshold/Thresh/; |
84
|
27
|
|
|
|
|
31
|
s/Reference/Ref/; |
85
|
27
|
|
|
|
|
36
|
s/Magnification/Mag/; |
86
|
27
|
|
|
|
|
35
|
s/Original/Orig/; |
87
|
27
|
|
|
|
|
30
|
s/FocusSetupFocusStrategySetup/Focus/; |
88
|
27
|
|
|
|
|
32
|
s/ParametersParameter/Parameter/; |
89
|
27
|
|
|
|
|
28
|
s/IntervalInfo/Interval/; |
90
|
27
|
|
|
|
|
29
|
s/ExptBlocksAcqBlock/AcqBlock/; |
91
|
27
|
|
|
|
|
36
|
s/MicroscopesMicroscope/Microscope/; |
92
|
27
|
|
|
|
|
37
|
s/TimeSeriesInterval/TimeSeries/; |
93
|
27
|
|
|
|
|
33
|
s/Interval(.*Interval)/$1/; |
94
|
27
|
|
|
|
|
30
|
s/SingleTileRegionsSingleTileRegion/SingleTileRegion/; |
95
|
27
|
|
|
|
|
32
|
s/AcquisitionMode//; |
96
|
27
|
|
|
|
|
29
|
s/DetectorsDetector/Detector/; |
97
|
27
|
|
|
|
|
35
|
s/Setup//; |
98
|
27
|
|
|
|
|
32
|
s/Setting//; |
99
|
27
|
|
|
|
|
29
|
s/TrackTrack/Track/; |
100
|
27
|
|
|
|
|
28
|
s/AnalogOutMaximumsAnalogOutMaximum/AnalogOutMaximum/; |
101
|
27
|
|
|
|
|
30
|
s/AnalogOutMinimumsAnalogOutMinimum/AnalogOutMinimum/; |
102
|
27
|
|
|
|
|
28
|
s/DigitalOutLabelsDigitalOutLabelLabel/DigitalOutLabelLabel/; |
103
|
27
|
|
|
|
|
29
|
s/(VivaTomeOpticalSectionInformation)+VivaTomeOpticalSectionInformation/VivaTomeOpticalSectionInformation/; |
104
|
27
|
|
|
|
|
33
|
s/FocusDefiniteFocus/FocusDefinite/; |
105
|
27
|
|
|
|
|
33
|
s/ChangerChanger/Changer/; |
106
|
27
|
|
|
|
|
32
|
s/Calibration/Cal/; |
107
|
27
|
|
|
|
|
31
|
s/LightSwitchChangerRLTLSwitch/LightSwitchChangerRLTL/; |
108
|
27
|
|
|
|
|
32
|
s/Parameters//; |
109
|
27
|
|
|
|
|
31
|
s/Fluorescence/Fluor/; |
110
|
27
|
|
|
|
|
30
|
s/CameraGeometryCameraGeometry/CameraGeometry/; |
111
|
27
|
|
|
|
|
63
|
s/CameraCamera/Camera/; |
112
|
27
|
|
|
|
|
35
|
s/DetectorsCamera/Camera/; |
113
|
27
|
|
|
|
|
28
|
s/FilterChangerLeftChangerEmissionFilter/LeftChangerEmissionFilter/; |
114
|
27
|
|
|
|
|
29
|
s/SwitchingStatesSwitchingState/SwitchingState/; |
115
|
27
|
|
|
|
|
31
|
s/Information/Info/; |
116
|
27
|
|
|
|
|
30
|
s/SubDimensions?//g; |
117
|
27
|
|
|
|
|
31
|
s/Setups?//; |
118
|
27
|
|
|
|
|
36
|
s/Parameters?//; |
119
|
27
|
|
|
|
|
31
|
s/Calculate/Calc/; |
120
|
27
|
|
|
|
|
32
|
s/Visibility/Vis/; |
121
|
27
|
|
|
|
|
34
|
s/Orientation/Orient/; |
122
|
27
|
|
|
|
|
31
|
s/ListItems/Items/; |
123
|
27
|
|
|
|
|
34
|
s/Increment/Incr/; |
124
|
27
|
|
|
|
|
32
|
s/Parameter/Param/; |
125
|
27
|
|
|
|
|
28
|
s/(ParfocalParcentralValues)+ParfocalParcentralValue/Parcentral/; |
126
|
27
|
|
|
|
|
43
|
s/ParcentralParcentral/Parcentral/; |
127
|
27
|
|
|
|
|
33
|
s/CorrFocusCorrection/FocusCorr/; |
128
|
27
|
|
|
|
|
33
|
s/(ApoTomeDepthInfo)+Element/ApoTomeDepth/; |
129
|
27
|
|
|
|
|
53
|
s/(ApoTomeClickStopInfo)+Element/ApoTomeClickStop/; |
130
|
27
|
|
|
|
|
34
|
s/DepthDepth/Depth/; |
131
|
27
|
|
|
|
|
40
|
s/(Devices?)+Device/Device/; |
132
|
27
|
|
|
|
|
31
|
s/(BeamPathNode)+/BeamPathNode/; |
133
|
27
|
|
|
|
|
36
|
s/BeamPathsBeamPath/BeamPath/g; |
134
|
27
|
|
|
|
|
29
|
s/BeamPathBeamPath/BeamPath/g; |
135
|
27
|
|
|
|
|
30
|
s/Configuration/Config/; |
136
|
27
|
|
|
|
|
31
|
s/StageAxesStageAxis/StageAxis/; |
137
|
27
|
|
|
|
|
31
|
s/RangesRange/Range/; |
138
|
27
|
|
|
|
|
29
|
s/DataGridDatasGridData(Grid)?/DataGrid/; |
139
|
27
|
|
|
|
|
27
|
s/DataMicroscopeDatasMicroscopeData(Microscope)?/DataMicroscope/; |
140
|
27
|
|
|
|
|
33
|
s/DataWegaDatasWegaData/DataWega/; |
141
|
27
|
|
|
|
|
28
|
s/ClickStopPositionsClickStopPosition/ClickStopPosition/; |
142
|
27
|
|
|
|
|
31
|
s/LightSourcess?LightSource(Settings)?(LightSource)?/LightSource/; |
143
|
27
|
|
|
|
|
34
|
s/FilterSetsFilterSet/FilterSet/; |
144
|
27
|
|
|
|
|
33
|
s/EmissionFiltersEmissionFilter/EmissionFilter/; |
145
|
27
|
|
|
|
|
28
|
s/ExcitationFiltersExcitationFilter/ExcitationFilter/; |
146
|
27
|
|
|
|
|
36
|
s/FiltersFilter/Filter/; |
147
|
27
|
|
|
|
|
32
|
s/DichroicsDichroic/Dichronic/; |
148
|
27
|
|
|
|
|
28
|
s/WavelengthsWavelength/Wavelength/; |
149
|
27
|
|
|
|
|
34
|
s/MultiTrackSetup/MultiTrack/; |
150
|
27
|
|
|
|
|
45
|
s/TrackTrack/Track/; |
151
|
27
|
|
|
|
|
30
|
s/DataGrabberSetup/DataGrabber/; |
152
|
27
|
|
|
|
|
32
|
s/CameraFrameSetup/CameraFrame/; |
153
|
27
|
|
|
|
|
28
|
s/TimeSeries(TimeSeries|Setups)/TimeSeries/; |
154
|
27
|
|
|
|
|
35
|
s/FocusFocus/Focus/; |
155
|
27
|
|
|
|
|
30
|
s/FocusAutofocus/Autofocus/; |
156
|
27
|
|
|
|
|
37
|
s/Focus(Hardware|Software)(Autofocus)+/Autofocus$1/; |
157
|
27
|
|
|
|
|
29
|
s/AutofocusAutofocus/Autofocus/; |
158
|
27
|
|
|
|
|
70
|
return $_; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
162
|
|
|
|
|
|
|
# Extract metadata from a ZISRAW (CZI) image |
163
|
|
|
|
|
|
|
# Inputs: 0) ExifTool object reference, 1) dirInfo reference |
164
|
|
|
|
|
|
|
# Returns: 1 on success, 0 if this wasn't a valid CZI file |
165
|
|
|
|
|
|
|
sub ProcessCZI($$) |
166
|
|
|
|
|
|
|
{ |
167
|
1
|
|
|
1
|
0
|
2
|
my ($et, $dirInfo) = @_; |
168
|
1
|
|
|
|
|
2
|
my $raf = $$dirInfo{RAF}; |
169
|
1
|
|
|
|
|
7
|
my ($buff, $tagTablePtr); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# verify this is a valid CZI file |
172
|
1
|
50
|
|
|
|
4
|
return 0 unless $raf->Read($buff, 100) == 100; |
173
|
1
|
50
|
|
|
|
6
|
return 0 unless $buff =~ /^ZISRAWFILE\0{6}/; |
174
|
1
|
|
|
|
|
5
|
$et->SetFileType(); |
175
|
1
|
|
|
|
|
10
|
SetByteOrder('II'); |
176
|
1
|
|
|
|
|
4
|
my %dirInfo = ( |
177
|
|
|
|
|
|
|
DataPt => \$buff, |
178
|
|
|
|
|
|
|
DirStart => 0, |
179
|
|
|
|
|
|
|
DirLen => length($buff), |
180
|
|
|
|
|
|
|
); |
181
|
1
|
|
|
|
|
3
|
$tagTablePtr = GetTagTable('Image::ExifTool::ZISRAW::Main'); |
182
|
1
|
|
|
|
|
5
|
$et->ProcessDirectory(\%dirInfo, $tagTablePtr); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# read the metadata section |
185
|
1
|
50
|
|
|
|
8
|
my $pos = Get64u(\$buff, 92) or return 1; |
186
|
1
|
50
|
|
|
|
6
|
$raf->Seek($pos, 0) or $et->Warn('Error seeking to metadata'), return 0; |
187
|
1
|
50
|
|
|
|
5
|
$raf->Read($buff, 288) == 288 or $et->Warn('Error reading metadata header'), return 0; |
188
|
1
|
50
|
|
|
|
8
|
$buff =~ /^ZISRAWMETADATA\0\0/ or $et->Warn('Invalid metadata header'), return 0; |
189
|
1
|
|
|
|
|
4
|
my $len = Get32u(\$buff, 32); |
190
|
1
|
50
|
|
|
|
4
|
$len < 200000000 or $et->Warn('Metadata section too large. Ignoring'), return 0; |
191
|
1
|
50
|
|
|
|
4
|
$raf->Read($buff, $len) or $et->Warn('Error reading XML metadata'), return 0; |
192
|
1
|
|
|
|
|
5
|
$et->FoundTag('XML', $buff); # extract as a block |
193
|
1
|
|
|
|
|
3
|
$tagTablePtr = GetTagTable('Image::ExifTool::XMP::XML'); |
194
|
1
|
|
|
|
|
3
|
$dirInfo{DirLen} = length $buff; |
195
|
|
|
|
|
|
|
# shorten tag names somewhat by removing 'ImageDocumentMetadata' prefix from all |
196
|
1
|
|
|
|
|
3
|
$$et{XmpIgnoreProps} = [ 'ImageDocument', 'Metadata', 'Information' ]; |
197
|
1
|
|
|
|
|
2
|
$$et{ShortenXmpTags} = \&ShortenTagNames; |
198
|
|
|
|
|
|
|
|
199
|
1
|
|
|
|
|
5
|
$et->ProcessDirectory(\%dirInfo, $tagTablePtr); |
200
|
|
|
|
|
|
|
|
201
|
1
|
|
|
|
|
4
|
return 1; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; # end |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__END__ |