Skip to content

Commit eec8f51

Browse files
Add short doc-strings for python files
1 parent ecbf543 commit eec8f51

File tree

7 files changed

+65
-7
lines changed

7 files changed

+65
-7
lines changed

micro_sam/instance_segmentation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
Automated instance segmentation functionality.
3+
The classes implemented here extend the automatic instance segmentation from Segment Anything:
4+
https://computational-cell-analytics.github.io/micro-sam/micro_sam.html
5+
"""
6+
17
import multiprocessing as mp
28
import warnings
39
from abc import ABC

micro_sam/prompt_based_segmentation.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Functions for prompt-based segmentation with Segment Anything.
3+
"""
4+
15
import warnings
26
from typing import Optional
37

micro_sam/prompt_generators.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Classes for generating prompts from ground-truth segmentation masks.
3+
For training or evaluation of prompt-based segmentation.
4+
"""
5+
16
from collections.abc import Mapping
27
from typing import Optional
38

micro_sam/sample_data.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
"""
2+
Sample microscopy data.
3+
"""
4+
15
import os
26
from pathlib import Path
7+
from typing import Union
38

49
import pooch
510

611

7-
def fetch_image_series_example_data(save_directory):
12+
def fetch_image_series_example_data(save_directory: Union[str, os.PathLike]) -> Union[str, os.PathLike]:
813
"""Download the sample images for the image series annotator.
14+
15+
Args:
16+
save_directory: Root folder to save the downloaded data.
17+
Returns:
18+
The folder that contains the downloaded data.
919
"""
1020
save_directory = Path(save_directory)
1121
os.makedirs(save_directory, exist_ok=True)
@@ -26,11 +36,16 @@ def fetch_image_series_example_data(save_directory):
2636
return data_folder
2737

2838

29-
def fetch_wholeslide_example_data(save_directory):
39+
def fetch_wholeslide_example_data(save_directory: Union[str, os.PathLike]) -> Union[str, os.PathLike]:
3040
"""Download the sample data for the 2d annotator.
3141
3242
This downloads part of a whole-slide image from the NeurIPS Cell Segmentation Challenge.
3343
See https://neurips22-cellseg.grand-challenge.org/ for details on the data.
44+
45+
Args:
46+
save_directory: Root folder to save the downloaded data.
47+
Returns:
48+
The path of the downloaded image.
3449
"""
3550
save_directory = Path(save_directory)
3651
os.makedirs(save_directory, exist_ok=True)
@@ -46,11 +61,16 @@ def fetch_wholeslide_example_data(save_directory):
4661
return os.path.join(save_directory, fname)
4762

4863

49-
def fetch_livecell_example_data(save_directory):
64+
def fetch_livecell_example_data(save_directory: Union[str, os.PathLike]) -> Union[str, os.PathLike]:
5065
"""Download the sample data for the 2d annotator.
5166
5267
This downloads a single image from the LiveCELL dataset.
5368
See https://doi.org/10.1038/s41592-021-01249-6 for details on the data.
69+
70+
Args:
71+
save_directory: Root folder to save the downloaded data.
72+
Returns:
73+
The path of the downloaded image.
5474
"""
5575
save_directory = Path(save_directory)
5676
os.makedirs(save_directory, exist_ok=True)
@@ -66,10 +86,15 @@ def fetch_livecell_example_data(save_directory):
6686
return os.path.join(save_directory, fname)
6787

6888

69-
def fetch_hela_2d_example_data(save_directory):
89+
def fetch_hela_2d_example_data(save_directory: Union[str, os.PathLike]) -> Union[str, os.PathLike]:
7090
"""Download the sample data for the 2d annotator.
7191
7292
This downloads a single image from the HeLa CTC dataset.
93+
94+
Args:
95+
save_directory: Root folder to save the downloaded data.
96+
Returns:
97+
The path of the downloaded image.
7398
"""
7499
save_directory = Path(save_directory)
75100
os.makedirs(save_directory, exist_ok=True)
@@ -85,11 +110,16 @@ def fetch_hela_2d_example_data(save_directory):
85110
return os.path.join(save_directory, fname)
86111

87112

88-
def fetch_3d_example_data(save_directory):
113+
def fetch_3d_example_data(save_directory: Union[str, os.PathLike]) -> Union[str, os.PathLike]:
89114
"""Download the sample data for the 3d annotator.
90115
91116
This downloads the Lucchi++ datasets from https://casser.io/connectomics/.
92117
It is a dataset for mitochondria segmentation in EM.
118+
119+
Args:
120+
save_directory: Root folder to save the downloaded data.
121+
Returns:
122+
The folder that contains the downloaded data.
93123
"""
94124
save_directory = Path(save_directory)
95125
os.makedirs(save_directory, exist_ok=True)
@@ -109,7 +139,7 @@ def fetch_3d_example_data(save_directory):
109139
return str(lucchi_dir)
110140

111141

112-
def fetch_tracking_example_data(save_directory):
142+
def fetch_tracking_example_data(save_directory: Union[str, os.PathLike]) -> Union[str, os.PathLike]:
113143
"""Download the sample data for the tracking annotator.
114144
115145
This data is the cell tracking challenge dataset DIC-C2DH-HeLa.
@@ -118,6 +148,11 @@ def fetch_tracking_example_data(save_directory):
118148
Dr. G. van Cappellen. Erasmus Medical Center, Rotterdam, The Netherlands
119149
Training dataset: http://data.celltrackingchallenge.net/training-datasets/DIC-C2DH-HeLa.zip (37 MB)
120150
Challenge dataset: http://data.celltrackingchallenge.net/challenge-datasets/DIC-C2DH-HeLa.zip (41 MB)
151+
152+
Args:
153+
save_directory: Root folder to save the downloaded data.
154+
Returns:
155+
The folder that contains the downloaded data.
121156
"""
122157
save_directory = Path(save_directory)
123158
os.makedirs(save_directory, exist_ok=True)

micro_sam/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Helper functions for downloading Segment Anything models and predicting image embeddings.
3+
"""
4+
15
import hashlib
26
import os
37
import warnings

micro_sam/visualization.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
Functionality for visualizing image embeddings.
3+
"""
4+
15
import numpy as np
26

37
from elf.segmentation.embeddings import embedding_pca

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
version=__version__,
99
description="SegmentAnything For Microscopy",
1010
author="Anwai Archit, Constantin Pape",
11-
url="https://user.informatik.uni-goettingen.de/~pape41/",
11+
url="https://computational-cell-analytics.github.io/micro-sam/micro_sam.html",
1212
packages=["micro_sam", "micro_sam.sam_annotator"],
1313
license="MIT",
1414
entry_points={

0 commit comments

Comments
 (0)