API details.

Hello wht

create_img_dict_from_folder[source]

create_img_dict_from_folder(load_pattern:str, img_regex:str='\\w\\dg\\d\\d?', label:bool=False, **kwargs)

C0_imgs = create_img_dict_from_folder(load_pattern="data/PercevalHR_data/imgs/*C0.tiff")

C1_imgs = create_img_dict_from_folder(load_pattern="data/PercevalHR_data/imgs/*C1.tiff")

lab_imgs = create_img_dict_from_folder(
    load_pattern="data/PercevalHR_data/segs/*.tif", label=True
)
from clonedetective.utils import plot_new_images

img_name = "a1g01"

plot_new_images(
    [C0_imgs[img_name], C1_imgs[img_name], lab_imgs[img_name]],
    ["C0 channel", "C1 channel", "label image (segmentation)"],
    interpolation="none",
)

create_ratio_image[source]

create_ratio_image(num_img, denom_img, mask_img)

a1g01_img = create_ratio_image(C1_imgs["a1g01"], C0_imgs["a1g01"], lab_imgs["a1g01"])
a2g01_img = create_ratio_image(C1_imgs["a2g01"], C0_imgs["a2g01"], lab_imgs["a2g01"])

plot_new_images(
    [a1g01_img, a2g01_img],
    ["a1g01 ratio image", "a2g01 ratio image"],
    img_cmap="magma",
    vmax=2.5,
    figure_shape=(1, 2),
    figure_size=(10, 5),
    colorbar=True,
    colorbar_title="PercevalHR 488/405"
)

create_dict_of_ratio_images[source]

create_dict_of_ratio_images(num_imgs:dict, denom_imgs:dict, lab_imgs:dict)

ratio_imgs = create_dict_of_ratio_images(C1_imgs, C0_imgs, lab_imgs)
ratio_imgs.keys()
dict_keys(['a1g01', 'a1g02', 'a1g03', 'a1g04', 'a2g01', 'a2g02', 'a2g03', 'a2g04'])

measure_region_props_to_tidy_df[source]

measure_region_props_to_tidy_df(int_imgs:dict, lab_imgs:dict, **reg_prop_kwargs)

df = measure_region_props_to_tidy_df(
    C1_imgs, lab_imgs, properties=["label", "mean_intensity"]
)
df.head()
label mean_intensity img_key
0 1 0.017960 a1g01
1 2 0.012017 a1g01
2 3 0.013259 a1g01
3 4 0.013988 a1g01
4 5 0.025333 a1g01

only_intensity_region_properties[source]

only_intensity_region_properties(properties)

only_intensity_region_properties(["label", "area", "mean_intensity", "centroid"])
['label', 'mean_intensity']

ratiometric_measure_region_props_to_tidy_df[source]

ratiometric_measure_region_props_to_tidy_df(num_imgs:dict, denom_imgs:dict, lab_imgs:dict, region_properties:list=None, **reg_prop_kwargs)

df = ratiometric_measure_region_props_to_tidy_df(C1_imgs, C0_imgs, lab_imgs)
df.head()
label area mean_intensity_num centroid-0 centroid-1 img_key mean_intensity_denom ratio_mean_int
0 1 342 0.017960 7.400585 295.084795 a1g01 0.010094 1.779309
1 2 200 0.012017 35.585000 80.495000 a1g01 0.006473 1.856478
2 3 269 0.013259 79.152416 174.858736 a1g01 0.027961 0.474173
3 4 213 0.013988 76.201878 282.995305 a1g01 0.019588 0.714101
4 5 546 0.025333 86.560440 322.816850 a1g01 0.013664 1.854012

split_img_key_col_to_sample_id_and_replicates[source]

split_img_key_col_to_sample_id_and_replicates(df, split_regex:str, img_key_colname:str='img_key', sample_id_colname:str='sample_id', replicate_id_colname:str='rep_id')

df = split_img_key_col_to_sample_id_and_replicates(
    df, sample_id_colname="genotype", split_regex=r"g"
)
df.head()
label area mean_intensity_num centroid-0 centroid-1 img_key mean_intensity_denom ratio_mean_int genotype rep_id
0 1 342 0.017960 7.400585 295.084795 a1g01 0.010094 1.779309 a1 01
1 2 200 0.012017 35.585000 80.495000 a1g01 0.006473 1.856478 a1 01
2 3 269 0.013259 79.152416 174.858736 a1g01 0.027961 0.474173 a1 01
3 4 213 0.013988 76.201878 282.995305 a1g01 0.019588 0.714101 a1 01
4 5 546 0.025333 86.560440 322.816850 a1g01 0.013664 1.854012 a1 01

sample_id_to_categories[source]

sample_id_to_categories(df, sample_id_colname:str='sample_id', old_to_new_sample_ids:dict=None, categories:list=None)

df = sample_id_to_categories(
    df, sample_id_colname="genotype", old_to_new_sample_ids={"a1": "ctrl", "a2": "mut"}
)
df.head()
label area mean_intensity_num centroid-0 centroid-1 img_key mean_intensity_denom ratio_mean_int genotype rep_id
0 1 342 0.017960 7.400585 295.084795 a1g01 0.010094 1.779309 ctrl 01
1 2 200 0.012017 35.585000 80.495000 a1g01 0.006473 1.856478 ctrl 01
2 3 269 0.013259 79.152416 174.858736 a1g01 0.027961 0.474173 ctrl 01
3 4 213 0.013988 76.201878 282.995305 a1g01 0.019588 0.714101 ctrl 01
4 5 546 0.025333 86.560440 322.816850 a1g01 0.013664 1.854012 ctrl 01
df["genotype"].head()
0    ctrl
1    ctrl
2    ctrl
3    ctrl
4    ctrl
Name: genotype, dtype: category
Categories (2, object): ['ctrl', 'mut']