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

Iterate/concatenate multiple .nd2 files #25

Open
steveb-123 opened this issue Apr 21, 2022 · 0 comments
Open

Iterate/concatenate multiple .nd2 files #25

steveb-123 opened this issue Apr 21, 2022 · 0 comments

Comments

@steveb-123
Copy link

I'd like to iterate over iterated axes of multiple .nd2 files as if they were one continuous flat iterable. I think the outcome would be something similar to ImageSequence from other readers.

Is this missing from this nd2 reader?

The following code illustrates the use-case, where I accumulate a list of ND2_reader objects. I later then iterate with nested for loops, but this feels silly and complicates merging external metadata, for example.

# List of files:
image_file_dir = "/run/media/steve/usb_msata/microscopy_images/"
image_filenames = (
    "WellA1-A3.nd2",
    "WellA4-A7.nd2",
    "WellA8-A12.nd2",
    "WellB1-C12.nd2",
    "WellD1-E12.nd2",
    "WellF1-H12.nd2"
    )

files = []
for i in image_filenames:
    image = ND2Reader_SDK(image_file_dir+i)
    image.bundle_axes = ['x', 'y', 'z', 'c'] 
    image.iter_axes = "m"  # iterate over the scene/field of view axis which is 'm'
    files.append(image)

One of files might look like

<FramesSequenceND>
Axes: 5
Axis 'x' size: 2046
Axis 'y' size: 2048
Axis 'c' size: 3
Axis 'm' size: 12
Axis 'z' size: 13
Pixel Datatype: <class 'numpy.uint16'>

As far as I can tell I'm unable to use any of the usual external array functions (concatenation, chaining, joining) to get to where I want because the objects provided by pims are incompatible (due to the lazy loading, I am guessing).

Disclaimer: I'm extremely new to pims and even python, so I'm likely to just be missing something super obvious. Apologies in advance if so.

@steveb-123 steveb-123 changed the title Iterate/concantenate multiple .nd2 files Iterate/concatenate multiple .nd2 files Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant