Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
label hist. & PEP8 (#16)
Browse files Browse the repository at this point in the history
* fix label histogram
* pep8 @imSegm
* pep8 @Experiments
* remove default dicts
* add doctests
* use flake8 & unset DISPLAY
* refactor CircleCI
* reinstall Morph-snakes
* add CodeFactor
  • Loading branch information
Borda committed Jan 4, 2019
1 parent f3955cf commit bcf3895
Show file tree
Hide file tree
Showing 43 changed files with 534 additions and 461 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ coverage:
# https://github.com/codecov/support/wiki/Patch-Status
patch:
default:
against: parent
against: auto
target: 30% # specify the target "X%" coverage to hit
threshold: 50% # allow this much decrease on patch
changes: false
Expand Down
9 changes: 4 additions & 5 deletions .shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
global:
- CI_REPORTS=shippable/testresults
- COVERAGE_REPORTS=shippable/codecoverage
- DISPLAY=""

language: python

Expand All @@ -39,7 +40,7 @@ install:
- mkdir libs

- pip install -r requirements.txt
- pip install "nose>=1.3.7" coverage codecov "pytest>=3.0.5"
- pip install "nose>=1.3.7" coverage codecov "pytest>=3.0.5" flake8

script:
- mkdir mkdir output && mkdir results
Expand All @@ -49,6 +50,7 @@ script:
# - nosetests -v --with-xunit --xunit-file=$CI_REPORTS/nosetests.xml
- nosetests -v --exe --with-doctest --with-xunit --with-coverage --cover-package=imsegm --xunit-file=$CI_REPORTS/nosetests.xml
- python setup.py check -m -s
- flake8 . --ignore=E402,E731 --max-line-length=100

# ANNOTATION section
- python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png"
Expand All @@ -72,10 +74,7 @@ script:
- python experiments_ovary_centres/run_center_evaluation.py

# download MorphSnake
- cd $root/libs && git clone https://github.com/Borda/morph-snakes.git
- cd $root/libs/morph-snakes && pip install -r requirements.txt
- cd $root/libs/morph-snakes && python setup.py install
- cd $root
- pip install git+https://github.com/Borda/morph-snakes.git
# REGION GROWING section
- rm -r -f results && mkdir results
- python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
env:
global:
- CODACY_PROJECT_TOKEN=ea6533a96dfb4b6a9b6b45fc134fabdf
- DISPLAY=""

language: python

Expand All @@ -30,7 +31,7 @@ install:
- mkdir libs

- pip install -r requirements.txt
- pip install nose coverage codecov pytest codacy-coverage check-manifest
- pip install nose coverage codecov pytest codacy-coverage check-manifest flake8

before_script:
- mkdir output && mkdir results
Expand All @@ -42,6 +43,7 @@ script:
- python setup.py build_ext --inplace
# - pytest imsegm -v --doctest-modules
- nosetests imsegm -v --exe --with-doctest --with-xunit --with-coverage --cover-package=imsegm
- flake8 . --ignore=E402,E731 --max-line-length=100
- python setup.py install

after_success:
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Run Status](https://api.shippable.com/projects/5962ea48a125960700c197f8/badge?branch=master)](https://app.shippable.com/github/Borda/pyImSegm)
[![Coverage Badge](https://api.shippable.com/projects/5962ea48a125960700c197f8/coverageBadge?branch=master)](https://app.shippable.com/github/Borda/pyImSegm)
[![CircleCI](https://circleci.com/gh/Borda/pyImSegm.svg?style=svg&circle-token=a30180a28ae7e490c0c0829d1549fcec9a5c59d0)](https://circleci.com/gh/Borda/pyImSegm)
[![CodeFactor](https://www.codefactor.io/repository/github/borda/pyimsegm/badge)](https://www.codefactor.io/repository/github/borda/pyimsegm)


## Superpixel segmentation with GraphCut regularisation
Expand Down Expand Up @@ -281,11 +282,7 @@ In case you do not have estimated object centers, you can use [plugins](ij_macro

**Note:** install multi-snake package which is used in multi-method segmentation experiment.
```bash
cd libs
git clone https://github.com/Borda/morph-snakes.git
cd morph-snakes
pip install -r requirements.txt
python setup.py install
pip install --user git+https://github.com/Borda/morph-snakes.git
```

**Experiment sequence is following:**
Expand Down
69 changes: 41 additions & 28 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
sudo apt-get update
sudo apt-get install tk-dev pkg-config python-dev python-tk
sudo pip install --upgrade pip setuptools
sudo pip install nose coverage pytest pytest-cov
sudo pip install nose coverage pytest pytest-cov flake8
sudo pip install -U backports.functools_lru_cache # required for matplotlib @py2
pip install -r requirements.txt --user
# BUILDING
Expand All @@ -26,44 +27,56 @@ jobs:
# TESTING
- run:
name: Testing
name: Testing and Formating
command: |
unset DISPLAY
coverage run --source imsegm -m py.test imsegm -v --doctest-modules --junitxml=test-reports/pytest_junit.xml
python setup.py check -m -s
flake8 . --ignore=E402,E731 --max-line-length=100
# ANNOTATION section
- run: python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png"
- run: python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" -m position
- run: python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" -out ./data_images/drosophila_ovary_slice/segm_rgb
- run: python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" -out ./data_images/drosophila_ovary_slice/segm
- run: python handling_annotations/run_overlap_images_segms.py -imgs "./data_images/drosophila_ovary_slice/image/*.jpg" -segs ./data_images/drosophila_ovary_slice/segm -out ./results/overlap_ovary_segment
- run: python handling_annotations/run_segm_annot_inpaint.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" --label 0
- run: python handling_annotations/run_segm_annot_relabel.py -imgs "./data_images/drosophila_ovary_slice/center_levels/*.png" -out ./results/relabel_center_levels
- run:
name: Annotations
command: |
python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png"
python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" -m position
python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" -out ./data_images/drosophila_ovary_slice/segm_rgb
python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" -out ./data_images/drosophila_ovary_slice/segm
python handling_annotations/run_overlap_images_segms.py -imgs "./data_images/drosophila_ovary_slice/image/*.jpg" -segs ./data_images/drosophila_ovary_slice/segm -out ./results/overlap_ovary_segment
python handling_annotations/run_segm_annot_inpaint.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" --label 0
python handling_annotations/run_segm_annot_relabel.py -imgs "./data_images/drosophila_ovary_slice/center_levels/*.png" -out ./results/relabel_center_levels
# SEGMENTATION section
- run: python experiments_segmentation/run_compute_stat_annot_segm.py -a "data_images/drosophila_ovary_slice/annot_struct/*.png" -s "data_images/drosophila_ovary_slice/segm/*.png" --visual
- run: python experiments_segmentation/run_segm_slic_model_graphcut.py -i "data_images/drosophila_disc/image/img_[5,6].jpg" -cfg ./experiments_segmentation/sample_config.json --visual
- run: python experiments_segmentation/run_segm_slic_classif_graphcut.py -l data_images/drosophila_ovary_slice/list_imgs-annot-struct_short.csv -i "data_images/drosophila_ovary_slice/image/insitu41*.jpg" -cfg ./experiments_segmentation/sample_config.json --visual
- run:
name: Segmentation
command: |
python experiments_segmentation/run_compute_stat_annot_segm.py -a "data_images/drosophila_ovary_slice/annot_struct/*.png" -s "data_images/drosophila_ovary_slice/segm/*.png" --visual
python experiments_segmentation/run_segm_slic_model_graphcut.py -i "data_images/drosophila_disc/image/img_[5,6].jpg" -cfg ./experiments_segmentation/sample_config.json --visual
python experiments_segmentation/run_segm_slic_classif_graphcut.py -l data_images/drosophila_ovary_slice/list_imgs-annot-struct_short.csv -i "data_images/drosophila_ovary_slice/image/insitu41*.jpg" -cfg ./experiments_segmentation/sample_config.json --visual
# CENTER DETECT. section
- run: python experiments_ovary_centres/run_create_annotation.py
- run: python experiments_ovary_centres/run_center_candidate_training.py
- run: python experiments_ovary_centres/run_center_prediction.py
- run: python experiments_ovary_centres/run_center_clustering.py
- run: python experiments_ovary_centres/run_center_evaluation.py
- run:
name: Center detection
command: |
python experiments_ovary_centres/run_create_annotation.py
python experiments_ovary_centres/run_center_candidate_training.py
python experiments_ovary_centres/run_center_prediction.py
python experiments_ovary_centres/run_center_clustering.py
python experiments_ovary_centres/run_center_evaluation.py
# download MorphSnake
- run: cd libs && git clone https://github.com/Borda/morph-snakes.git
- run: cd libs/morph-snakes && pip install --user -r requirements.txt && python setup.py install --user
# REGION GROWING section
- run: python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py
- run: python experiments_ovary_detect/run_ovary_egg-segmentation.py -m ellipse_moments ellipse_ransac_mmt ellipse_ransac_crit GC_pixels-large GC_pixels-shape GC_slic-small GC_slic-shape rg2sp_greedy-single rg2sp_GC-mixture watershed_morph
- run: python experiments_ovary_detect/run_ovary_segm_evaluation.py --visual
- run: python experiments_ovary_detect/run_export_user-annot-segm.py
- run: python experiments_ovary_detect/run_cut_segmented_objects.py
- run: python experiments_ovary_detect/run_ellipse_annot_match.py
- run: python experiments_ovary_detect/run_ellipse_cut_scale.py
- run: python experiments_ovary_detect/run_egg_swap_orientation.py
- run:
name: Region Growing
command: |
pip install --user git+https://github.com/Borda/morph-snakes.git
python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py
python experiments_ovary_detect/run_ovary_egg-segmentation.py -m ellipse_moments ellipse_ransac_mmt ellipse_ransac_crit GC_pixels-large GC_pixels-shape GC_slic-small GC_slic-shape rg2sp_greedy-single rg2sp_GC-mixture watershed_morph
python experiments_ovary_detect/run_ovary_segm_evaluation.py --visual
python experiments_ovary_detect/run_export_user-annot-segm.py
python experiments_ovary_detect/run_cut_segmented_objects.py
python experiments_ovary_detect/run_ellipse_annot_match.py
python experiments_ovary_detect/run_ellipse_cut_scale.py
python experiments_ovary_detect/run_egg_swap_orientation.py
# PASSING
- run:
Expand Down
13 changes: 7 additions & 6 deletions experiments_ovary_centres/gui_annot_center_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg

sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
sys.path += [os.path.abspath('.'), os.path.abspath('..')] # Add path to root
import imsegm.utilities.data_io as tl_data
import imsegm.utilities.drawing as tl_visu

Expand Down Expand Up @@ -87,7 +87,8 @@ def arg_parse_params():
help='path to file with complete info', default=None)
params = vars(parser.parse_args())
for k in (k for k in params if 'path' in k):
if params[k] is None: continue
if params[k] is None:
continue
params[k] = os.path.abspath(os.path.expanduser(params[k]))
p = os.path.dirname(params[k]) if '*' in params[k] else params[k]
assert os.path.exists(p), 'missing: %s' % p
Expand Down Expand Up @@ -145,8 +146,8 @@ def set_false_negative(df_points, mask_eggs):
if sum(labels) == 0:
pos = ndimage.measurements.center_of_mass(mask)
df_points = df_points.append(
{'X': pos[1], 'Y': pos[0], 'label': 1, 'change': 1},
ignore_index=True)
{'X': pos[1], 'Y': pos[0], 'label': 1, 'change': 1},
ignore_index=True)
return df_points


Expand Down Expand Up @@ -266,7 +267,7 @@ def add_point_correction(x, y, changing=1, limit_dist=DICT_LIMIT_CORRECT):
else:
# add new point
df_center_labeled = df_center_labeled.append(
{'X': x, 'Y': y, 'label': 1, 'change': 1}, ignore_index=True)
{'X': x, 'Y': y, 'label': 1, 'change': 1}, ignore_index=True)

canvas_update_image_centers()

Expand Down Expand Up @@ -354,7 +355,7 @@ def main(params):
actual_idx = 0
paths_img_csv = load_paths_image_csv(params)
logging.info('loaded %i pairs (image & centers)', len(paths_img_csv))
assert len(paths_img_csv) > 0, 'missing paths image - csv'
assert paths_img_csv, 'missing paths image - csv'

if params['path_info'] is not None and os.path.isfile(params['path_info']):
df_info_all = pd.read_csv(params['path_info'], sep='\t', index_col=0)
Expand Down
Loading

0 comments on commit bcf3895

Please sign in to comment.