bm_experiments.bm_ANTs module

Benchmark for ANTs see: * http://stnava.github.io/ANTs * https://sourceforge.net/projects/advants/ * https://github.com/stnava/ANTsDoc/issues/1

INSTALLATION: See: https://brianavants.wordpress.com/2012/04/13/updated-ants-compile-instructions-april-12-2012/

Discussion

I. believes he found the “problem” and indeed it has to do with the file format we use (JPEG). I. converts the kidney images to 8-bit and then .NII.GZ and the whole pipeline works fine.

Note

For showing parameter/options setting run antsRegistration –help

  1. Convert images to 8-bit using Fiji (this is only because I didn’t see any ITK format to store RGB images).

  2. Convert the 8-bit images to .nii.gz (using ANTs script ConvertImagePixelType):

    ConvertImagePixelType         Rat_Kidney_PanCytokeratin-8bit.png         Rat_Kidney_PanCytokeratin.nii.gz         1
    
  3. Register images using antsRegistrationSyN.sh:

    antsRegistrationSyN.sh         -d 2         -m Rat_Kidney_PanCytokeratin.nii.gz         -f Rat_Kidney_HE.nii.gz         -j 1         -t s         -o output         > stdout-reg.txt 2> stderr-reg.txt
    
  4. Apply transform to points:

    antsApplyTransformsToPoints         -d 2         -i Rat_Kidney_PanCytokeratin.csv         -o testPointsHE.csv         -t [ output0GenericAffine.mat, 1 ]         -t output1InverseWarp.nii.gz
    

Usage

Run the basic ANT registration with original parameters:

python bm_experiments/bm_ANTs.py         -t ./data-images/pairs-imgs-lnds_anhir.csv         -d ./data-images         -o ./results         --path_ANTs $HOME/Applications/antsbin/bin         --path_config ./configs/ANTs_SyN.txt

Note

it was needed to use own compiled version

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

class bm_experiments.bm_ANTs.BmANTs(params)[source]

Bases: birl.benchmark.ImRegBenchmark

Benchmark for ANTs no run test while this method requires manual compilation of ANTs

Example

>>> from birl.utilities.data_io import create_folder, update_path
>>> path_out = create_folder('temp_results')
>>> fn_path_conf = lambda n: os.path.join(update_path('configs'), n)
>>> path_csv = os.path.join(update_path('data-images'), 'pairs-imgs-lnds_mix.csv')
>>> params = {'path_table': path_csv,
...           'path_out': path_out,
...           'nb_workers': 2,
...           'unique': False,
...           'path_ANTs': '.',
...           'path_config': '.'}
>>> benchmark = BmANTs(params)
>>> benchmark.EXECUTE_TIMEOUT
10800
>>> benchmark.run()  
>>> shutil.rmtree(path_out, ignore_errors=True)

initialise benchmark

Parameters

params (dict) – parameters

_clear_after_registration(item)[source]

clean unnecessarily files after the registration

Parameters

item (dict) – dictionary with regist. information

Return dict

the same or updated registration info

_extract_warped_image_landmarks(item)[source]

get registration results - warped registered images and landmarks

Parameters

item (dict) – dictionary {str: value} with registration params

Return dict

paths to results

_generate_regist_command(item)[source]

generate the registration command(s)

Parameters

item (dict) – dictionary {str: str|float} with registration params

Return str|list(str)

the execution commands

_prepare()[source]

prepare BM - copy configurations

_prepare_img_registration(item)[source]

prepare the experiment folder if it is required, eq. copy some extra files

Parameters

item (dict) – dictionary with regist. params

Return dict

the same or updated registration info

static extend_parse(arg_parser)[source]

extent the basic arg parses by some extra required parameters

Return object

COL_IMAGE_MOVE_NII = 'Source image Nifty'[source]

column name of temporary Nifty noving image

COL_IMAGE_REF_NII = 'Target image Nifty'[source]

column name of temporary Nifty reference image

COMMAND_REGISTER = '%(antsRegistration)s         --dimensionality 2         %(config)s         --output [%(output)s/trans]'[source]

command for executing the image registration

COMMAND_WARP_IMAGE = '%(antsApplyTransforms)s         --dimensionality 2         --input %(img_source)s         --output %(output)s/%(img_name)s.nii         --reference-image %(img_target)s         --transform %(transfs)s         --interpolation Linear'[source]

command for executing the warping image

COMMAND_WARP_POINTS = '%(antsApplyTransformsToPoints)s         --dimensionality 2         --input %(path_points)s         --output %(output)s/%(pts_name)s.csv         --transform %(transfs)s'[source]

command for executing the warping landmarks

EXECUTE_TIMEOUT = 10800[source]

timeout for executing single image registration

EXEC_REGISTRATION = 'antsRegistration'[source]

executable for performing image registration

EXEC_TRANSFORM_IMAGE = 'antsApplyTransforms'[source]

executable for performing image transformation

EXEC_TRANSFORM_POINTS = 'antsApplyTransformsToPoints'[source]

executable for performing landmarks transformation

REQUIRED_PARAMS = ['path_out', 'path_table', 'path_config'][source]

required experiment parameters