bm_dataset.rescale_tissue_landmarks module

According given annotations select a subset and add synthetic points and scale it into particular scales used in dataset

The expected structure of annotations is as follows ANNOTATIONS/<tissue>/<user>_scale-<number>pc/<csv-file> The expected structure of dataset is DATASET/<tissue>/scale-<number>pc/<image-file>

Sample usage:

python rescale_tissue_landmarks.py -a data_images -d results

python bm_dataset/rescale_tissue_landmarks.py         -a /datagrid/Medical/dataset_ANHIR/landmarks_all         -d /datagrid/Medical/dataset_ANHIR/landmarks_user         --scales 2 5 10 15 20 25 50 100 --nb_selected 0.2

In case, you are working with the user annotation you need to generate consensus landmark annotation first, using https://borda.github.io/dataset-histology-landmarks/ Sample usage:

python handlers/run_generate_landmarks.py         -a /datagrid/Medical/dataset_ANHIR/landmarks_annot         -d /datagrid/Medical/dataset_ANHIR/landmarks_all         --scales 2 5 10 15 20 25 50 100

Copyright (C) 2014-2019 Jiri Borovec <jiri.borovec@fel.cvut.cz>

bm_dataset.rescale_tissue_landmarks.arg_parse_params()[source]

argument parser from cmd

Return dict:
bm_dataset.rescale_tissue_landmarks.dataset_expand_landmarks(path_annots, path_dataset, nb_selected=None, nb_total=None, nb_workers=1)[source]

select and expand over whole dataset

Parameters:
  • path_annots (str) – root path to original dataset
  • path_dataset (str) – root path to generated dataset
  • nb_selected (float|int|None) – portion of selected points
  • nb_total (int|None) – add extra points up to total number
  • nb_workers (int) – number of jobs running in parallel
Return list(int):
 
bm_dataset.rescale_tissue_landmarks.dataset_scale_landmarks(path_dataset, scales=(5, 10, 15, 20, 25, 50), nb_workers=1)[source]

generate several scales within the same dataset

Parameters:
  • path_dataset (str) – path to the source/generated dataset
  • scales ([inr]) – created scales
  • nb_workers (int) – number of jobs running in parallel
Returns:

bm_dataset.rescale_tissue_landmarks.expand_random_warped_landmarks(names_lnds, names_lnds_new, nb_total)[source]

add some extra point which are randomly sampled in the first sample and warped to the other images using estimated affine transform

Parameters:
  • names_lnds (dict) – mapping to ndarray of the original landmarks
  • names_lnds_new (dict) – mapping to ndarray of the generated landmarks
  • nb_total (int) – total number of point - landmarks
Return dict:

mapping to ndarray

bm_dataset.rescale_tissue_landmarks.extend_landmarks(path_set, path_dataset, nb_selected=None, nb_total=None)[source]

select and extend the original set of landmarks

Parameters:
  • path_set (str) – path to the particular set if images/landmarks
  • path_dataset (str) – root path to generated dataset
  • nb_selected (float|int|None) – portion of selected points, if None use all original landmarks
  • nb_total (int|None) – add extra points up to total number, if None, no adding extra points
Returns:

bm_dataset.rescale_tissue_landmarks.generate_random_points_inside(ref_points, nb_extras)[source]

generate some extra points inside the tissue boundary polygon

Parameters:
  • ref_points – point of the tissue
  • nb_extras (int) – number of point to be added
Return [(int, int)]:
 

extra points

bm_dataset.rescale_tissue_landmarks.load_largest_scale(path_set)[source]

in given set find the largest scale and load all landmarks in full size

Parameters:path_set (str) – path to image/landmark set
Return dict:dictionary of ndarray with loaded landmarks in full scale
bm_dataset.rescale_tissue_landmarks.main(path_annots, path_dataset, scales, nb_selected=None, nb_total=None, nb_workers=1)[source]

main entry point

Parameters:
  • path_annots (str) – root path to original dataset
  • path_dataset (str) – root path to generated dataset
  • scales (list(int)) – generated scales
  • nb_selected (float|int|None) – portion of selected points
  • nb_total (int|None) – add extra points up to total number
  • nb_workers (int) – number of jobs running in parallel
Return tuple(int,int):
 
bm_dataset.rescale_tissue_landmarks.scale_set_landmarks(path_set, scales=(5, 10, 15, 20, 25, 50))[source]

scale the updated (generated) landmarks

the scales are created within the same path set

Parameters:
  • path_set (str) – path to the image/landmark set
  • scales (list(int)) – created scales
Return dict: