diff --git a/.gitignore b/.gitignore index ae6db6f..fb7f874 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # User data .DS_Store temp* +user_data/ # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 867c5f2..fb1fafc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention. +## [0.5.1] - 2023-03-15 + ++ Fix - ingestion routine for multiple Z devices in `prairieviewreader.py`. + ## [0.5.0] - 2023-01-09 + Remove - `recursive_search` function @@ -53,6 +57,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and + Add - Readers for: `ScanImage`, `Suite2p`, `CaImAn`. +[0.5.1]: https://github.com/datajoint/element-interface/releases/tag/0.5.1 [0.5.0]: https://github.com/datajoint/element-interface/releases/tag/0.5.0 [0.4.2]: https://github.com/datajoint/element-interface/releases/tag/0.4.2 [0.4.1]: https://github.com/datajoint/element-interface/releases/tag/0.4.1 diff --git a/element_interface/prairieviewreader.py b/element_interface/prairieviewreader.py index a4c6979..31e0170 100644 --- a/element_interface/prairieviewreader.py +++ b/element_interface/prairieviewreader.py @@ -42,7 +42,7 @@ def get_pv_metadata(pvtiffile: str) -> dict: ) bidirectional_scan = False # Does not support bidirectional - roi = 1 + roi = 0 n_fields = 1 # Always contains 1 field record_start_time = root.find(".//Sequence/[@cycle='1']").attrib.get("time") @@ -115,7 +115,7 @@ def get_pv_metadata(pvtiffile: str) -> dict: else: - bidirection_z = bool(root.find(".//Sequence").attrib.get("bidirectionalZ")) + bidirection_z = root.find(".//Sequence").attrib.get("bidirectionalZ") == "True" # One "Frame" per depth. Gets number of frames in first sequence planes = [ @@ -123,23 +123,44 @@ def get_pv_metadata(pvtiffile: str) -> dict: for plane in root.findall(".//Sequence/[@cycle='1']/Frame") ] n_depths = len(set(planes)) - z_min = float( - root.findall( - ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/SubindexedValue/[@subindex='0']" - )[0].attrib.get("value") - ) - z_max = float( - root.findall( - ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/SubindexedValue/[@subindex='0']" - )[-1].attrib.get("value") - ) - z_step = float( - root.find( - ".//PVStateShard/PVStateValue/[@key='micronsPerPixel']/IndexedValue/[@index='ZAxis']" - ).attrib.get("value") + + z_controllers = root.findall( + ".//Sequence/[@cycle='1']/Frame/[@index='1']/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue" ) - z_fields = np.arange(z_min, z_max + 1, z_step) - assert z_fields.size == n_depths + if len(z_controllers) > 1: + + z_repeats = [] + for controller in root.findall( + ".//Sequence/[@cycle='1']/Frame/[@index='1']/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/"): + z_repeats.append( + [ + float(z.attrib.get("value")) + for z in root.findall( + ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue/[@subindex='{0}']".format( + controller.attrib.get("subindex") + ) + ) + ] + ) + + + controller_assert = [not all(z == z_controller[0] for z in z_controller) for z_controller in z_repeats] + + assert sum(controller_assert)==1, "Multiple controllers changing z depth is not supported" + + z_fields = z_repeats[controller_assert.index(True)] + + else: + z_fields = [ + z.attrib.get("value") + for z in root.findall( + ".//Sequence/[@cycle='1']/Frame/PVStateShard/PVStateValue/[@key='positionCurrent']/SubindexedValues/[@index='ZAxis']/SubindexedValue/[@subindex='0']" + ) + ] + + assert ( + len(z_fields) == n_depths + ), "Number of z fields does not match number of depths." metainfo = dict( num_fields=n_fields, diff --git a/element_interface/version.py b/element_interface/version.py index 20b1b3e..c488607 100644 --- a/element_interface/version.py +++ b/element_interface/version.py @@ -1,3 +1,3 @@ """Package metadata""" -__version__ = "0.5.0" +__version__ = "0.5.1"