|
18 | 18 | "metadata": {}, |
19 | 19 | "outputs": [], |
20 | 20 | "source": [ |
21 | | - "ATP_IMAGE_DF = df[df[\"Staining method\"] == \"ATP 9.4\"]\n", |
22 | | - "ATP_IMAGE_NAME = ATP_IMAGE_DF[\"Number\"].tolist()\n", |
23 | 21 | "IMAGE_INDEX = 189\n", |
24 | 22 | "# show the first image in the list using the image name\n", |
25 | 23 | "from IPython.display import Image\n", |
26 | | - "Image(filename='../data/muscle_atlas/images/' + ATP_IMAGE_NAME[IMAGE_INDEX])" |
| 24 | + "Image(filename='../sample_img/sample_atp.jpg')" |
27 | 25 | ] |
28 | 26 | }, |
29 | 27 | { |
|
39 | 37 | "except ImportError:\n", |
40 | 38 | " from imageio import imread\n", |
41 | 39 | "\n", |
42 | | - "image_array = imread('../data/muscle_atlas/images/' + ATP_IMAGE_NAME[IMAGE_INDEX])\n", |
| 40 | + "image_array = imread('../sample_img/sample_atp.jpg')\n", |
43 | 41 | "model_cellpose = load_cellpose()\n", |
44 | 42 | "mask_cellpose = run_cellpose(image_array, model_cellpose)\n", |
45 | 43 | "plt.imshow(mask_cellpose)" |
|
92 | 90 | " all_cell_median_intensity.append(single_cell_median_intensity)\n" |
93 | 91 | ] |
94 | 92 | }, |
| 93 | + { |
| 94 | + "cell_type": "code", |
| 95 | + "execution_count": null, |
| 96 | + "metadata": {}, |
| 97 | + "outputs": [], |
| 98 | + "source": [ |
| 99 | + "# Histogram plot of the median pixel intensity of all cells\n", |
| 100 | + "plt.hist(all_cell_median_intensity, bins=255, density=True, alpha=0.5)\n", |
| 101 | + "plt.plot(xs,density(xs))\n", |
| 102 | + "plt.xlim(50,220)\n", |
| 103 | + "plt.show()" |
| 104 | + ] |
| 105 | + }, |
95 | 106 | { |
96 | 107 | "cell_type": "code", |
97 | 108 | "execution_count": null, |
|
103 | 114 | "# Build a \"density\" function based on the dataset\n", |
104 | 115 | "# When you give a value from the X axis to this function, it returns the according value on the Y axis\n", |
105 | 116 | "density = gaussian_kde(all_cell_median_intensity)\n", |
106 | | - "density.covariance_factor = lambda : .25\n", |
| 117 | + "density.covariance_factor = lambda : .05\n", |
107 | 118 | "density._compute_covariance()\n", |
108 | 119 | "\n", |
109 | 120 | "# Create a vector of 256 values going from 0 to 256:\n", |
|
115 | 126 | "# Make the chart\n", |
116 | 127 | "# We're actually building a line chart where x values are set all along the axis and y value are\n", |
117 | 128 | "# the corresponding values from the density function\n", |
| 129 | + "\n", |
118 | 130 | "plt.plot(xs,density(xs))\n", |
| 131 | + "plt.xlim(50,220)\n", |
119 | 132 | "plt.show()" |
120 | 133 | ] |
121 | 134 | }, |
| 135 | + { |
| 136 | + "cell_type": "code", |
| 137 | + "execution_count": null, |
| 138 | + "metadata": {}, |
| 139 | + "outputs": [], |
| 140 | + "source": [] |
| 141 | + }, |
122 | 142 | { |
123 | 143 | "cell_type": "code", |
124 | 144 | "execution_count": null, |
|
179 | 199 | "threshold = sorted_peaks[0]+xs[min_index]\n", |
180 | 200 | "print(threshold)\n", |
181 | 201 | "# Plot the data\n", |
182 | | - "plt.plot(xs, density(xs), label='Density')\n", |
| 202 | + "plt.hist(all_cell_median_intensity, bins=255, density=True, alpha=0.5, label='Histogram')\n", |
| 203 | + "plt.plot(xs,density(xs), label='Density', linewidth=3)\n", |
| 204 | + "plt.xlim(50,220)\n", |
183 | 205 | "plt.axvline(threshold, color='r', label='Threshold')\n", |
184 | 206 | "plt.legend()\n", |
185 | 207 | "plt.show()" |
|
0 commit comments