czbiohub-sf / shrimPy

shrimPy: Smart High-throughput Robust Imaging & Measurement in Python
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Refactor and unify reconstruction calls #123

Open ieivanov opened 6 months ago

ieivanov commented 6 months ago

Unify reconstruction functions (e.g. process_single_position and apply_transform_to_zyx_and_save) to work on CZYX datasets, rather than ZYX datasets - I think this is preferred since, for example, birefringence reconstruction requires 4-5 input channels. Similar logic can maybe be extended to registration, which requires fixed and moving volumes, or training for virtual staining which requires paired phase and fluorescence images

We can modify the function signature to accept a "processing unit" and then we'll iterate over these processing units:

for processing_unit in processing_units:
    func(data[processing_unit])

The processing units can be as follows:

processing_units = [
    (slice(0, 1), slice(None), slice(None), slice(None)),
    (slice(1, 2), slice(None), slice(None), slice(None)),
    ...
]

for looping over XYZ volumes in different channels

processing_units = [
    (slice(0, 1), slice(0, 1), slice(None), slice(None)),
    (slice(0, 1), slice(1, 2), slice(None), slice(None)),
    ...
]

for looping over individual XY slices

or

processing_units = [
    (slice(0, 5), slice(None), slice(None), slice(None)),
]

for processing a CZYX array with 5 channels.

Currently process_single_position and apply_transform_to_zyx_and_save and duplicated in shrimpy and recorder and can go out of sync. These function are largely utilities to apply a user-specified functions to iohub Positions. We can consider moving these two functions to iohub/utils.

@talonchandler @edyoshikun @ziw-liu let's kick off this discussion with an in-person meeting.