SPACEc 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ import matplotlib.pyplot as plt
2
+ import tifffile
3
+ from scipy import ndimage as ndi
4
+ from skimage.transform import resize
5
+
6
+
7
+ def downscale_tissue(
8
+ file_path,
9
+ DNAslice=0,
10
+ downscale_factor=64,
11
+ sigma=5.0,
12
+ padding=50,
13
+ savefig=False,
14
+ showfig=True,
15
+ output_dir="./",
16
+ output_fname="",
17
+ figsize=(10, 5), # new parameter for figure size
18
+ ):
19
+ print("Reading in the qptiff file, might take awhile!")
20
+ currim = tifffile.imread(file_path)
21
+ nucim = currim[DNAslice]
22
+ del currim
23
+ print(f"Loaded nuclear image of dimension (Y,X) = {nucim.shape}")
24
+ resized_im = resize(
25
+ nucim,
26
+ (nucim.shape[0] // downscale_factor, nucim.shape[1] // downscale_factor),
27
+ anti_aliasing=True,
28
+ )
29
+ resized_im = ndi.gaussian_filter(resized_im, sigma=sigma)
30
+
31
+ if showfig:
32
+ fig, axs = plt.subplots(1, 2, figsize=figsize) # use figsize parameter here
33
+ axs[0].imshow(nucim)
34
+ axs[0].set_title("Nuclear image")
35
+ axs[1].hist(resized_im)
36
+ axs[1].set_title("Marker expression level histogram")
37
+ if savefig:
38
+ fig.savefig(
39
+ output_dir + output_fname + "_raw_tissue_plot.pdf", bbox_inches="tight"
40
+ )
41
+ else:
42
+ plt.show()
43
+ print("returning scaled down image!")
44
+ return resized_im
@@ -0,0 +1,40 @@
1
+ from ._general import (
2
+ BC_projection,
3
+ catplot,
4
+ cn_exp_heatmap,
5
+ cn_map,
6
+ coordinates_on_image,
7
+ count_patch_proximity_res,
8
+ create_pie_charts,
9
+ distance_graph,
10
+ dumbbell,
11
+ plot_top_n_distances,
12
+ ppa_res_donut,
13
+ stacked_bar_plot,
14
+ zcount_thres,
15
+ )
16
+ from ._qptiff_converter import tissue_lables
17
+ from ._segmentation import segmentation_ch, show_masks
18
+
19
+ __all__ = [
20
+ # segmentation
21
+ "segmentation_ch",
22
+ "show_masks",
23
+ # general
24
+ "coordinates_on_image",
25
+ "catplot",
26
+ "stacked_bar_plot",
27
+ "create_pie_charts",
28
+ "cn_exp_heatmap",
29
+ "catplot",
30
+ "cn_map",
31
+ "dumbbell",
32
+ "count_patch_proximity_res",
33
+ "zcount_thres",
34
+ "BC_projection",
35
+ "plot_top_n_distances",
36
+ "distance_graph",
37
+ # qptiff converter
38
+ "tissue_lables",
39
+ "ppa_res_donut",
40
+ ]