@@ -42,7 +42,7 @@ def get_pv_metadata(pvtiffile: str) -> dict:
4242 )
4343
4444 bidirectional_scan = False # Does not support bidirectional
45- roi = 1
45+ roi = 0
4646 n_fields = 1 # Always contains 1 field
4747 record_start_time = root .find (".//Sequence/[@cycle='1']" ).attrib .get ("time" )
4848
@@ -128,14 +128,33 @@ 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- z_repeats = [
132- z .attrib .get ("value " )
133- for z in root .findall (
134- ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue "
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']/"
135135 )
136136 ]
137137
138- z_fields = [float (z ) for z in z_repeats if z_repeats .count (z ) == 1 ]
138+ z_repeats = []
139+ for subindex in subindicies :
140+ z_repeats .append (
141+ [
142+ float (z .attrib .get ("value" ))
143+ for z in root .findall (
144+ ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue/[@subindex='{0}']" .format (
145+ subindex
146+ )
147+ )
148+ ]
149+ )
150+
151+ z_fields = np .delete (
152+ z_repeats , np .diff (z_repeats ).mean (axis = 1 ) == 0 , axis = 0
153+ ).flatten ()
154+
155+ assert (
156+ z_fields .shape [1 ] == n_depths
157+ ), "Number of z fields does not match number of depths."
139158
140159 else :
141160 z_fields = [
@@ -145,9 +164,9 @@ def get_pv_metadata(pvtiffile: str) -> dict:
145164 )
146165 ]
147166
148- assert (
149- len (z_fields ) == n_depths
150- ), "Number of z fields does not match number of depths."
167+ assert (
168+ len (z_fields ) == n_depths
169+ ), "Number of z fields does not match number of depths."
151170
152171 metainfo = dict (
153172 num_fields = n_fields ,
0 commit comments