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

Chunk transfer functions #463

Merged
merged 3 commits into from
Dec 12, 2023
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
56 changes: 34 additions & 22 deletions recOrder/cli/compute_transfer_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import click
import numpy as np
from iohub import open_ome_zarr
from iohub.ngff import open_ome_zarr, Position
from waveorder.models import (
inplane_oriented_thick_pol3d,
isotropic_fluorescent_thick_3d,
Expand Down Expand Up @@ -45,13 +45,15 @@ def generate_and_save_birefringence_transfer_function(settings, dataset):
] = intensity_to_stokes_matrix.cpu().numpy()[None, None, None, ...]


def generate_and_save_phase_transfer_function(settings, dataset, zyx_shape):
def generate_and_save_phase_transfer_function(
settings: ReconstructionSettings, dataset: Position, zyx_shape: tuple
):
"""Generates and saves the phase transfer function to the dataset, based on the settings.

Parameters
----------
settings: ReconstructionSettings
dataset: NGFF Node
dataset: Position
The dataset that will be updated.
zyx_shape : tuple
A tuple of integers specifying the input data's shape in (Z, Y, X) order
Expand Down Expand Up @@ -81,12 +83,16 @@ def generate_and_save_phase_transfer_function(settings, dataset, zyx_shape):
)

# Save
dataset[
"absorption_transfer_function"
] = absorption_transfer_function.cpu().numpy()[None, None, ...]
dataset[
"phase_transfer_function"
] = phase_transfer_function.cpu().numpy()[None, None, ...]
dataset.create_image(
"absorption_transfer_function",
absorption_transfer_function.cpu().numpy()[None, None, ...],
chunks=(1, 1, 1, zyx_shape[1], zyx_shape[2]),
)
dataset.create_image(
"phase_transfer_function",
phase_transfer_function.cpu().numpy()[None, None, ...],
chunks=(1, 1, 1, zyx_shape[1], zyx_shape[2]),
)

elif settings.reconstruction_dimension == 3:
# Calculate transfer functions
Expand All @@ -98,25 +104,29 @@ def generate_and_save_phase_transfer_function(settings, dataset, zyx_shape):
**settings.phase.transfer_function.dict(),
)
# Save
dataset[
"real_potential_transfer_function"
] = real_potential_transfer_function.cpu().numpy()[None, None, ...]
dataset[
"imaginary_potential_transfer_function"
] = imaginary_potential_transfer_function.cpu().numpy()[
None, None, ...
]
dataset.create_image(
"real_potential_transfer_function",
real_potential_transfer_function.cpu().numpy()[None, None, ...],
chunks=(1, 1, 1, zyx_shape[1], zyx_shape[2]),
)
dataset.create_image(
"imaginary_potential_transfer_function",
imaginary_potential_transfer_function.cpu().numpy()[
None, None, ...
],
chunks=(1, 1, 1, zyx_shape[1], zyx_shape[2]),
)


def generate_and_save_fluorescence_transfer_function(
settings, dataset, zyx_shape
settings: ReconstructionSettings, dataset: Position, zyx_shape: tuple
):
"""Generates and saves the fluorescence transfer function to the dataset, based on the settings.

Parameters
----------
settings: ReconstructionSettings
dataset: NGFF Node
dataset: Position
The dataset that will be updated.
zyx_shape : tuple
A tuple of integers specifying the input data's shape in (Z, Y, X) order
Expand All @@ -135,9 +145,11 @@ def generate_and_save_fluorescence_transfer_function(
)
)
# Save
dataset[
"optical_transfer_function"
] = optical_transfer_function.cpu().numpy()[None, None, ...]
dataset.create_image(
"optical_transfer_function",
optical_transfer_function.cpu().numpy()[None, None, ...],
chunks=(1, 1, 1, zyx_shape[1], zyx_shape[2]),
)


def compute_transfer_function_cli(
Expand Down