Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix handling of num_frames and plane search for single/multi plane dataset #100

Merged
Merged
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
16 changes: 13 additions & 3 deletions element_interface/prairie_view_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def __init__(self, prairieview_dir: str):
def meta(self):
if self._meta is None:
self._meta = _extract_prairieview_metadata(self.xml_file)
# adjust for the different definition of "frames"
# from the ome meta - "frame" refers to an image at a given scanning depth, time step combination
# in the imaging pipeline - "frame" refers to video frames - i.e. time steps
num_frames = self._meta.pop("num_frames") / self._meta["num_planes"]

self._meta["num_frames"] = int(num_frames)

return self._meta

def get_prairieview_filenames(
Expand Down Expand Up @@ -73,11 +80,14 @@ def get_prairieview_filenames(
assert (
channel in self.meta["channels"]
), f"Invalid 'channel' - Channels: {self.meta['channels']}"


plane_search_string = f"[@index='{plane_idx}']/" if self.meta["num_planes"] > 1 else ""
# single-plane ome.tif does not have "@index" under Frame to search for
plane_search = f"/[@index='{plane_idx}']" if self.meta["num_planes"] > 1 else ""
# ome.tif does have "@channel" under File regardless of single or multi channel
channel_search = f"/[@channel='{channel}']"

frames = self._xml_root.findall(
f".//Sequence/Frame/{plane_search_string}File/[@channel='{channel}']"
f".//Sequence/Frame{plane_search}/File{channel_search}"
)

fnames = [f.attrib["filename"] for f in frames]
Expand Down
Loading