angelolab / Nimbus-Inference

MIT License
4 stars 3 forks source link

Add ome-tiff inference script #7

Closed JLrumberger closed 2 months ago

JLrumberger commented 3 months ago

Description of feature

Add ome-tiff inference features to Nimbus.

We can adjust the Nimbus class by adding functions prepare_normalization_dict_ome and predict_ome_fovs to utils.py. The nimbus class then needs to check if fovs contain ome.tifs and use the according functions from utils.py.

The functions in utils.py should look roughly like this

def calculate_normalization_ome(ome_path, quantile, include_channels):
    # open ome_file
    # check if include_channels are included in ome file
    # iterate through include_channels and calculate quantile of foreground
    return channel: quantile dict

def prepare_normalization_dict_ome( fov_paths, output_dir, quantile,
    include_channels, n_subsets, n_jobs, output_name):
    # parallelize over fov_paths if n_jobs > 1
    # average quantiles of dicts

def predict_ome_fovs(nimbus, fov_paths, normalization_dict,
    segmentation_naming_convention, output_dir, suffix, include_channels=[],
    save_predictions=True, half_resolution=False, batch_size=4,
    test_time_augmentation=True):
# iterate through fovs and make prediction with nimbus object
# save predictions as tiffs or ome.tiffs 

In addition we need to change the ViewerWidget reader to work with ome.tifs