@@ -128,34 +128,28 @@ def get_pv_metadata(pvtiffile: str) -> dict:
128128 ".//Sequence/[@cycle='1']/Frame/[@index='1']/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue"
129129 )
130130 if len (z_controllers ) > 1 :
131- subindicies = [
132- subindex .attrib .get ("subindex" )
133- for subindex in root .findall (
134- ".//Sequence/[@cycle='1']/Frame/[@index='1']/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/"
135- )
136- ]
137131
138132 z_repeats = []
139- for subindex in subindicies :
133+ for controller in root .findall (
134+ ".//Sequence/[@cycle='1']/Frame/[@index='1']/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/" ):
140135 z_repeats .append (
141136 [
142137 float (z .attrib .get ("value" ))
143138 for z in root .findall (
144139 ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue/[@subindex='{0}']" .format (
145- subindex
140+ controller . attrib . get ( " subindex" )
146141 )
147142 )
148143 ]
149144 )
145+
150146
151- z_fields = np .delete (
152- z_repeats , np .diff (z_repeats ).mean (axis = 1 ) == 0 , axis = 0
153- ).flatten ()
147+ controller_assert = [not all (z == z_controller [0 ] for z in z_controller ) for z_controller in z_repeats ]
154148
155- assert (
156- z_fields .shape [1 ] == n_depths
157- ), "Number of z fields does not match number of depths."
149+ assert sum (controller_assert )== 1 , "Multiple controllers changing z depth is not supported"
158150
151+ z_fields = z_repeats [controller_assert .index (True )]
152+
159153 else :
160154 z_fields = [
161155 z .attrib .get ("value" )
@@ -164,9 +158,9 @@ def get_pv_metadata(pvtiffile: str) -> dict:
164158 )
165159 ]
166160
167- assert (
168- len (z_fields ) == n_depths
169- ), "Number of z fields does not match number of depths."
161+ assert (
162+ len (z_fields ) == n_depths
163+ ), "Number of z fields does not match number of depths."
170164
171165 metainfo = dict (
172166 num_fields = n_fields ,
0 commit comments