Todd nb 4#13
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Day 2 “Notebook 4” worked-solutions Jupyter notebook covering blob segmentation/shape filtering, distance transforms, and an optional intensity-measurement exercise.
Changes:
- Introduces
Notebook_4_solutions.ipynbwith end-to-end solutions for multiple image-analysis exercises. - Demonstrates region property measurement (aspect ratio/eccentricity), watershed splitting, and distance-map-based distance measurements.
- Includes optional exercise content for multi-channel intensity measurement and visualization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "source": [ | ||
| "results_with_ecc = skimage.measure.regionprops_table(label_blobs, properties=('label', 'axis_major_length', 'axis_minor_length', 'eccentricity'))\n", | ||
| "results_with_ecc_df = pd.DataFrame(results_with_ecc)\n", | ||
| "results_with_ecc_df['aspect_ratio'] = results_df['axis_major_length'] / results_df['axis_minor_length']\n", |
Comment on lines
+498
to
+502
| "for i, lysosome in enumerate(blobs_dog, 1): # Start labeling from 1\n", | ||
| " y, x, r = lysosome\n", | ||
| " rr, cc = skimage.draw.disk((y, x), r)\n", | ||
| " if(((y+r) < chan_1.shape[0]) and ((x+r) < chan_1.shape[1])):\n", | ||
| " label_lysosomes[rr, cc] = i\n", |
Comment on lines
+576
to
+586
| "# compute mean intensity value of distance map image from lysosomes label image\n", | ||
| "results = skimage.measure.regionprops_table(label_lysosomes, inv_distance_map_nuclei, properties=('label','area', 'mean_intensity'))\n", | ||
| "## intensity is measured from the inv_distance _map_nuclei image. So for each label_lysosome, we measure the average intensity of the inverse distance map, under the lysosome label. \n", | ||
| "## The intensity under the label is the distance to the nearest nuclei\n", | ||
| "\n", | ||
| "\n", | ||
| "results_df = pd.DataFrame(results)\n", | ||
| "plt.hist(results_df['mean_intensity'])\n", | ||
| "plt.title(\"Distance to closest nuclei\")\n", | ||
| "plt.xlabel(\"Mean intensity of lysosome label\\n (distance to nearest nuclei)\") \n", | ||
| "plt.ylabel(\"Count of lysosomes\") " |
Comment on lines
+28
to
+29
| "import stackview\n", | ||
| "import ipywidgets as widgets" |
| "id": "20aaf34a-07ca-4960-b770-a64be1c06ab6", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Excercise 1\n", |
| "id": "90dffcbe-ebf3-41a9-8587-0d7f5ebe041d", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "In some projects, you might be interested in computing distances between different objects. For example, to filter out objects that are far away from an other set of objects. An efficient approach is based on distance maps, and we will see an example of usage along with ```skimage.measure.regionprops_table()``` method in the exercise 2 below. We give before a little theory reminder about distance maps." |
| "id": "8daad760-726d-4962-b04d-87ace600578a", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Distance transforms have many applications, we can for example use them to quantify how a structure of interest is away from object boundaries or other structures as just mentionned. They are also used to characterize the morphology of an object in 2D and 3D, find its center, dimensions, etc.. Distance transforms can also be used as a pre-processing step to improve the segmentation results and split touching objects. Distance maps may use different distance metrics, as the Euclidian or the Manhattan one for example." |
| "2. Segment the nuclei on the last channel\n", | ||
| "3. Detect lysosomes on the first channel and convert them to a label map\n", | ||
| "4. Compute a distance map and inverse distance map of nuclei. \n", | ||
| "5. Compte distances from lysosomes to closest nuclei. Hint: you can use regionprops\n" |
| "metadata": {}, | ||
| "source": [ | ||
| "Steps:\n", | ||
| "1. Import the image from images/4color_cells.tif and visualize the 3rd channel\n", |
| "metadata": {}, | ||
| "source": [ | ||
| "#### Step 1.\n", | ||
| "Import the image from images/4color_cells.tif and visualize the 3rd channel" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.