Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# User data
.DS_Store
temp*
user_data/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
57 changes: 39 additions & 18 deletions element_interface/prairieviewreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -115,31 +115,52 @@ 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 = [
int(plane.attrib.get("index"))
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,
Expand Down
2 changes: 1 addition & 1 deletion element_interface/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Package metadata"""

__version__ = "0.5.0"
__version__ = "0.5.1"