Skip to content

Todd nb 4#13

Merged
todd-fallesen merged 2 commits into
mainfrom
Todd_NB_4
Jun 22, 2026
Merged

Todd nb 4#13
todd-fallesen merged 2 commits into
mainfrom
Todd_NB_4

Conversation

@todd-fallesen

Copy link
Copy Markdown
Collaborator

No description provided.

@todd-fallesen todd-fallesen requested a review from Copilot June 22, 2026 22:11
@todd-fallesen todd-fallesen merged commit 3c24ecc into main Jun 22, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ipynb with 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants