-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from bioshape-analysis/csoub
Csoub
- Loading branch information
Showing
17 changed files
with
144 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"hash": "10d851187eb2e992125f935bc965f1d2", | ||
"hash": "8bc5f558cca4dc007297cd54321dee9b", | ||
"result": { | ||
"engine": "jupyter", | ||
"markdown": "---\ntitle: \"Extracting cell geometry from Atomic Force Microscopy\"\nsubtitle: \"Part 1: Static analysis\"\n\n\nauthor:\n - name: \"Clément Soubrier\" \n email: \"[email protected]\"\n affiliations:\n - name: KDD Group\n url: \"https://rtviii.xyz/\"\n\n - name: \"Khanh Dao Duc\" \n email: \"[email protected]\"\n affiliations:\n - name: Department of Mathematics, UBC\n url: \"https://www.math.ubc.ca/\"\n - name: Department of Computer Science, UBC\n url: \"https://www.cs.ubc.ca/\"\n\ndate: \"July 31 2024\"\ncategories: [biology, bioinformatics] \n\ncallout-icon: false\nformat:\n html:\n code-fold: true\nbibliography: bibliography.bib\n\nexecute:\n echo: false\n freeze: auto\n\n---\n\n::: {#44521d56 .cell execution_count=1}\n\n::: {.cell-output .cell-output-stdout}\n```\n1\n```\n:::\n:::\n\n\nWe present here the protocole to process biological images such as bacteria atomic force miroscopy data. We want to study the bacteria cell shape and extract the main geometrical feature.\n\n## Biological context\n*Mycobacterium smegmatis* is Grahm-positive rod shape bacterium. It is 3 to 5 $\\mu m$ long and around 500 $nm$ wide. This non-pathogenic species is otften used a biological model to study the pathogenic Mycobacteria such as *M.tuberculosis* (responsible for the tubercuosis) or *M.abscessus*, with which it shares the same cell wall structure[@tyagi2002mycobacterium] . In particular *M.smegmatis* has a fast growth (3-4 hours doubling time compared to 24h for *M. tuberculosis*), allowing for faster experimental protocols. \n\n\nHere are some know properties of *M.smegmatis* bacteria :\n\n* They present variation of cell diameter along their longitudinal axis [@eskandarian2017division]. The cell diameter is represented as a height profile along the cell centerline. We respectively name peaks and troughs the local maxima and minima of this proile.\n\n![3D image of *M.smegmatis*. The orange line represents the height profile.](3D_cell.png)\n\n* They grow following a biphasic and asymetrical polar dynamics[@hannebelle2020biphasic]. The cells elongate from the poles, where material is added. After division, the pre-existing pole (OP) elongate at a high rate, whereas the newly created pole (NP) has first a slow growth, and then switches to a fast growth, after the New End Take Off (NETO).\n\n![Growth dynamics.](Neto.svg)\n\n\n\n\n\n\n## Raw image pre-processing\n#### Data\n\nSeveral data acquisitions were conducted with wild types and different mutant strains. The raw data is composed of AFM log files times series for each experiments. Each log file contain several images, each one representing a physical channel such as height, stiffness, adhesion etc.\n\n## Segmentation\n\n\n## Centerline\n\n", | ||
"markdown": "---\ntitle: \"Extracting cell geometry from Atomic Force Microscopy\"\nsubtitle: \"Part 1: Static analysis\"\njupyter: python3\n\nauthor:\n - name: \"Clément Soubrier\" \n email: \"[email protected]\"\n affiliations:\n - name: KDD Group\n url: \"https://rtviii.xyz/\"\n\n - name: \"Khanh Dao Duc\" \n email: \"[email protected]\"\n affiliations:\n - name: Department of Mathematics, UBC\n url: \"https://www.math.ubc.ca/\"\n - name: Department of Computer Science, UBC\n url: \"https://www.cs.ubc.ca/\"\n\ndate: \"July 31 2024\"\ncategories: [biology, bioinformatics] \n\ncallout-icon: false\nformat:\n html:\n code-fold: true\nbibliography: bibliography.bib\n\nexecute:\n echo: true\n freeze: auto\n warning: false\n\n---\n\n\n\n\n\n\n\nWe present here the protocole to process biological images such as bacteria atomic force miroscopy data. We want to study the bacteria cell shape and extract the main geometrical feature.\n\n## Biological context\n*Mycobacterium smegmatis* is Grahm-positive rod shape bacterium. It is 3 to 5 $\\mu m$ long and around 500 $nm$ wide. This non-pathogenic species is otften used a biological model to study the pathogenic Mycobacteria such as *M.tuberculosis* (responsible for the tubercuosis) or *M.abscessus*, with which it shares the same cell wall structure [@tyagi2002mycobacterium]. In particular *M.smegmatis* has a fast growth (3-4 hours doubling time compared to 24h for *M. tuberculosis*), allowing for faster experimental protocols. \n\n\nHere are some know properties of *M.smegmatis* bacteria :\n\n* They present variation of cell diameter along their longitudinal axis [@eskandarian2017division]. The cell diameter is represented as a height profile along the cell centerline. We respectively name peaks and troughs the local maxima and minima of this profile.\n\n![3D image of *M.smegmatis*. The orange line represents the height profile.](3D_cell.png)\n\n* They grow following a biphasic and asymetrical polar dynamics [@hannebelle2020biphasic]. The cells elongate from the poles, where material is added. After division, the pre-existing pole (OP) elongate at a high rate, whereas the newly created pole (NP) has first a slow growth, and then switches to a fast growth, after the New End Take Off (NETO).\n\n![Growth dynamics.](Neto.svg)\n\n\n\n\n\n\n## Raw image pre-processing\n#### Data\n\nSeveral data acquisitions were conducted with wild types and different mutant strains. The raw data is composed of AFM log files times series for each experiments. Each log file contain several images, each one representing a physical channel such as height, stiffness, adhesion etc. After extraction of the data, forward and backward cells are aligned, artefacts such as image scars are detected and corrected.\n\n![At each time step, images representing different physical variables are produced by the AFM](Figure_1_quarto.png)\n\n## Segmentation\nAt each time steps, images are segmented to detect each cells using the cellpose package [@stringer2021cellpose]. If available, different physical channels are combined to improve the segmentation. Forward and backward images are also combined.\n\n![Images are combined to improve the segmentation](Figure_2_quarto.png)\n\nHere is an example on how to use cellpose on an image. Different models are available (with the `seg_mod` variable), depending on the training datasets. With cellpose 3, different denoising models are also available (with the `denoise_mod` variable). \n\n::: {#2ca55a5e .cell execution_count=1}\n``` {.python .cell-code}\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom cellpose import io, denoise, plot\nfrom PIL import Image\n\n\n'''\nParameters\n'''\n\nimage_path = 'raw_img.png'\npath_to_save = 'segmented_img'\n# Segmentation model type\nseg_mod = 'cyto' \n# Denoizing model\ndenoise_mod = \"denoise_cyto3\" \n# Expected cell diameter (pixels)\ndia = 40\n# Type of segmentation (with / without nuclei, different color channels or not)\nchan = [0,0] \n# Segmentation sensibility parameters\nthres = 0.8\ncelp = 0.4\n\n'''\nComputing segmentation\n'''\n\n\n# Opening image to segment\nimg=np.array(Image.open(image_path))[:,:,1]\n\n# Chosing a model type :\nmodel = denoise.CellposeDenoiseModel(gpu=False, model_type=seg_mod, restore_type=denoise_mod)\n\n# Computing segmentaion\nmasks, flows, st, diams = model.eval(img, diameter = dia, channels=chan, flow_threshold = thres, cellprob_threshold=celp)\n\n\n# Saving the results into a numpy file\nio.masks_flows_to_seg(img, masks, flows, path_to_save, channels=chan, diams=diams)\n\n```\n:::\n\n\nWe plot the final results :\n\n::: {#23f7d201 .cell execution_count=2}\n``` {.python .cell-code}\nplt.imshow(img,cmap='gray')\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![Raw image](index_files/figure-html/cell-3-output-1.png){width=575 height=307}\n:::\n:::\n\n\n::: {#b441ded7 .cell execution_count=3}\n``` {.python .cell-code}\nmask_RGB = plot.mask_overlay(img,masks)\nplt.imshow(mask_RGB)\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![Image with segmented masks overlaid](index_files/figure-html/cell-4-output-1.png){width=575 height=307}\n:::\n:::\n\n\n## Centerline\nSince we are interested in studying the variations of the cell diameter, we define height profile as the value of the cell height along the cell centerline. The cell centerline are computed using a skeletonization algorithm [@zhang1984fast,@lee1994building]. Here is an example of skeletonization \n\n::: {#fcc052f8 .cell execution_count=4}\n``` {.python .cell-code}\nfrom skimage.morphology import skeletonize\n\n# Selecting first mask\nfirst_mask = masks == 1\n\nskel_img = skeletonize(first_mask, method='lee') \nskel = np.argwhere(skel_img)\nplt.imshow(first_mask, cmap='gray')\n\nplt.scatter(skel[:,1], skel[:,0], 0.5*np.ones(np.shape(skel[:,0])), color='r', marker='.')\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-5-output-1.png){width=575 height=307}\n:::\n:::\n\n\nDepending on the masks shapes, centerlines may have branches :\n\n::: {#1eb253d9 .cell execution_count=5}\n``` {.python .cell-code}\nfrom skimage.morphology import skeletonize\n\n# Selecting first mask\nfirst_mask = masks == 3\n\nskel_img = skeletonize(first_mask) #, method='lee'\nskel = np.argwhere(skel_img)\nplt.imshow(first_mask, cmap='gray')\n\nplt.scatter(skel[:,1], skel[:,0], 0.5*np.ones(np.shape(skel[:,0])), color='r', marker='.')\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![](index_files/figure-html/cell-6-output-1.png){width=575 height=307}\n:::\n:::\n\n\nIn practice, centerlines are pruned and extended to the cell poles, in order to capture the cell length. Other geometrical properties such as masks centroids or outlines are computed as well.\n\n![Final static processing results in real life data. White masks are excluded from the cell tracking algorithm (see part 2). Black dots are cell centroids. The yellow boxes represent artefacts cleaning.](Figure_3_quarto.png)\n\n# References\n\n", | ||
"supporting": [ | ||
"index_files" | ||
], | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.