From c8ad840c1fe198be7903fd596c58fefa137eac59 Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Thu, 15 Feb 2024 19:00:29 +0100 Subject: [PATCH 1/4] readme --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a5b330a1..435e52ab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ - - # Advanced Normalization Tools in Python ![img](https://media0.giphy.com/media/OCMGLUo7d5jJ6/200_s.gif) @@ -7,7 +5,7 @@ Coverage Status - Documentation Status +Documentation Status ![Downloads](https://img.shields.io/github/downloads/antsx/antspy/total) ![PyPI - Downloads](https://img.shields.io/pypi/dm/antspyx?label=pypi%20downloads) @@ -18,8 +16,7 @@ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/stnava/ANTsPyDocker/master) [![PubMed](https://img.shields.io/badge/ANTsX_paper-Open_Access-8DABFF?logo=pubmed)](https://pubmed.ncbi.nlm.nih.gov/33907199/) - -## About ANTsPy +## Advanced Normalization Tools in Python (ants-py) Search [ANTsPy documentation at read the docs.](https://antspyx.readthedocs.io/en/latest/?badge=latest) @@ -44,13 +41,14 @@ If you have any questions or feature requests, feel free to open an issue or ema ### NOTE: old pip wheels will be deleted!!! -we dont have the quota on pypi to support more than one or two prior releases. if you care about this: (1) open a pypi issue requesting more quota for this project; (2) propose another alternative. +we dont have the quota on pypi to support more than one or two prior releases. if you care about this: (1) open a pypi issue requesting more quota for this project; (2) propose another alternative. We recommend that users install the latest pre-compiled binaries, which takes ~1 minute. Note that ANTsPy is not currently tested for Python 2.7 support. Copy the following command and paste it into your bash terminal: For MacOS and Linux: + ```bash pip install antspyx ``` @@ -64,34 +62,34 @@ git clone https://github.com/ANTsX/ANTsPy cd ANTsPy python3 setup.py install ``` + or see below for an alternative strategy using `pip`. If you want more detailed instructions on compiling ANTsPy from source, you can read the [installation tutorial](https://github.com/ANTsX/ANTsPy/blob/master/tutorials/InstallingANTsPy.md). - ### Installing older versions We cannot store the entire history of releases because storage space on `pip` is limited. if you need an older release, you can check the [Github Releases page](https://github.com/ANTsX/ANTsPy/releases) or -build from source. +build from source. Try something like: ```bash pip install 'antspyx @ git+https://github.com/ANTsX/ANTsPy@v0.3.2' ``` -which will attempt to build from source (requires a machine with developer tools). - +which will attempt to build from source (requires a machine with developer tools). ### Recent wheels Non-release commits have wheels built automatically, which are available for download for a limited period. -Look under the [Actions tab](https://github.com/ANTsX/ANTsPy/actions). Then click on the commit for the software version you want. +Look under the [Actions tab](https://github.com/ANTsX/ANTsPy/actions). Then click on the commit for the software version you want. Recent commits will have wheels stored as "artifacts". we build wheels locally like this: + ``` rm -r -f build/ antspymm.egg-info/ dist/ python3 setup.py sdist bdist_wheel @@ -103,13 +101,14 @@ pipx run twine upload dist/* Available on [Docker Hub](https://hub.docker.com/repository/docker/antsx/antspy). To build ANTsPy docker images, see the (installation tutorial)(https://github.com/ANTsX/ANTsPy/blob/master/tutorials/InstallingANTsPy.md#docker-installation). ------------------------------------------------------------------------------- +--- ## ANTsR Comparison Here is a quick example to show the similarity with ANTsR: ANTsR code: + ```R library(ANTsR) img <- antsImageRead(getANTsRData("r16")) @@ -119,6 +118,7 @@ segs1 <- atropos(a=img, m='[0.2,1x1]', c='[2,0]', i='kmeans[3]', x=mask ) ``` ANTsPy code: + ```python from ants import atropos, get_ants_data, image_read, resample_image, get_mask img = image_read(get_ants_data("r16")) From 7f8230cf46484ff475929a963f86c60d8b093f43 Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Thu, 15 Feb 2024 19:00:56 +0100 Subject: [PATCH 2/4] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 435e52ab..12873d05 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/stnava/ANTsPyDocker/master) [![PubMed](https://img.shields.io/badge/ANTsX_paper-Open_Access-8DABFF?logo=pubmed)](https://pubmed.ncbi.nlm.nih.gov/33907199/) -## Advanced Normalization Tools in Python (ants-py) +## Advanced Normalization Tools in Python (ANTsPy) Search [ANTsPy documentation at read the docs.](https://antspyx.readthedocs.io/en/latest/?badge=latest) From 6dbeb72202b9ac95d3014daa216c7d383eb6e539 Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Thu, 15 Feb 2024 23:51:16 +0100 Subject: [PATCH 3/4] fix inits --- ants/__init__.py | 2 + ants/core/__init__.py | 69 +++++++++++++++-- ants/learn/__init__.py | 6 +- ants/registration/__init__.py | 30 ++++---- ants/segmentation/__init__.py | 21 +++-- ants/utils/__init__.py | 132 +++++++++++++++++++++----------- ants/utils/average_transform.py | 1 + ants/utils/averaging.py | 1 + ants/viz/__init__.py | 19 +++-- 9 files changed, 202 insertions(+), 79 deletions(-) diff --git a/ants/__init__.py b/ants/__init__.py index a1a6ef3f..1ff3e4c3 100644 --- a/ants/__init__.py +++ b/ants/__init__.py @@ -12,3 +12,5 @@ from .viz import * from . import contrib + +print('here') \ No newline at end of file diff --git a/ants/core/__init__.py b/ants/core/__init__.py index c90d9fc0..9fddd447 100644 --- a/ants/core/__init__.py +++ b/ants/core/__init__.py @@ -1,9 +1,66 @@ -from .ants_image import * -from .ants_image_io import * +from .ants_image_io import ( + image_header_info, + image_clone, + image_read, + dicom_read, + image_write, + make_image, + matrix_to_images, + images_from_matrix, + image_list_to_matrix, + images_to_matrix, + matrix_from_images, + timeseries_to_matrix, + matrix_to_timeseries, + from_numpy, + _from_numpy +) + +from .ants_image import ( + ANTsImage, + LabelImage, + copy_image_info, + set_origin, + get_origin, + set_direction, + get_direction, + set_spacing, + get_spacing, + image_physical_space_consistency, + image_type_cast, + allclose +) + +from .ants_metric_io import ( + new_ants_metric, + create_ants_metric, + supported_metrics +) + +from .ants_transform_io import ( + create_ants_transform, + new_ants_transform, + read_transform, + write_transform, + transform_from_displacement_field, + transform_to_displacement_field +) + +from .ants_transform import ( + ANTsTransform, + set_ants_transform_parameters, + get_ants_transform_parameters, + get_ants_transform_fixed_parameters, + set_ants_transform_fixed_parameters, + apply_ants_transform, + apply_ants_transform_to_point, + apply_ants_transform_to_vector, + apply_ants_transform_to_image, + invert_ants_transform, + compose_ants_transforms, + transform_index_to_physical_point, + transform_physical_point_to_index +) -from .ants_transform import * -from .ants_transform_io import * -from .ants_metric import * -from .ants_metric_io import * \ No newline at end of file diff --git a/ants/learn/__init__.py b/ants/learn/__init__.py index 3fa88be1..22912057 100644 --- a/ants/learn/__init__.py +++ b/ants/learn/__init__.py @@ -1,2 +1,6 @@ -from .decomposition import * \ No newline at end of file +from .decomposition import ( + eig_seg, + initialize_eigenanatomy, + sparse_decom2 +) \ No newline at end of file diff --git a/ants/registration/__init__.py b/ants/registration/__init__.py index 9c9717e0..52ca4d46 100644 --- a/ants/registration/__init__.py +++ b/ants/registration/__init__.py @@ -1,18 +1,22 @@ -from .affine_initializer import * -from .apply_transforms import * +from .affine_initializer import affine_initializer +from .apply_transforms import (apply_transforms,apply_transforms_to_points) from .create_jacobian_determinant_image import create_jacobian_determinant_image from .create_jacobian_determinant_image import deformation_gradient -from .create_warped_grid import * -from .fsl2antstransform import * -from .make_points_image import * -from .metrics import * -from .reflect_image import * -from .reorient_image import * -from .resample_image import * -from .symmetrize_image import * -from .build_template import * -from .landmark_transforms import * +from .create_warped_grid import create_warped_grid +from .fsl2antstransform import fsl2antstransform +from .make_points_image import make_points_image +from .metrics import image_mutual_information +from .reflect_image import reflect_image +from .reorient_image import (get_orientation, + reorient_image2, + get_possible_orientations, + get_center_of_mass) +from .resample_image import (resample_image, + resample_image_to_target) +from .symmetrize_image import symmetrize_image +from .build_template import build_template +from .landmark_transforms import (fit_transform_to_paired_points, fit_time_varying_transform_to_point_sets) -from .interface import * +from .interface import (registration, motion_correction) diff --git a/ants/segmentation/__init__.py b/ants/segmentation/__init__.py index f785cb1b..2d26f4b2 100644 --- a/ants/segmentation/__init__.py +++ b/ants/segmentation/__init__.py @@ -1,11 +1,10 @@ -from .anti_alias import * -from .atropos import * -from .kmeans import * -from .functional_lung_segmentation import * -from .fuzzy_spatial_cmeans_segmentation import * -from .kelly_kapowski import * -from .joint_label_fusion import joint_label_fusion -from .joint_label_fusion import local_joint_label_fusion -from .label_geometry_measures import * -from .otsu import * -from .prior_based_segmentation import * +from .anti_alias import anti_alias +from .atropos import atropos +from .kmeans import kmeans_segmentation +from .functional_lung_segmentation import functional_lung_segmentation +from .fuzzy_spatial_cmeans_segmentation import fuzzy_spatial_cmeans_segmentation +from .kelly_kapowski import kelly_kapowski +from .joint_label_fusion import joint_label_fusion, local_joint_label_fusion +from .label_geometry_measures import label_geometry_measures +from .otsu import otsu_segmentation +from .prior_based_segmentation import prior_based_segmentation diff --git a/ants/utils/__init__.py b/ants/utils/__init__.py index d0541fd9..f13af7f8 100644 --- a/ants/utils/__init__.py +++ b/ants/utils/__init__.py @@ -1,45 +1,91 @@ -from .add_noise_to_image import * -from .bias_correction import * -from .channels import * -from .compose_displacement_fields import * -from .convert_nibabel import * -from .crop_image import * -from .denoise_image import * -from .fit_bspline_object_to_scattered_data import * -from .fit_bspline_displacement_field import * -from .fit_thin_plate_spline_displacement_field import * -from .get_ants_data import * -from .get_centroids import * -from .get_mask import * -from .get_neighborhood import * -from .histogram_match_image import * -from .hausdorff_distance import * -from .image_similarity import * -from .image_to_cluster_images import * -from .iMath import * -from .impute import * -from .integrate_velocity_field import * -from .invariant_image_similarity import * -from .invert_displacement_field import * -from .label_clusters import * -from .label_image_centroids import * -from .label_overlap_measures import * -from .label_stats import * -from .labels_to_matrix import * -from .mask_image import * -from .mni2tal import * -from .morphology import * -from .multi_label_morphology import * -from .ndimage_to_list import * -from .pad_image import * -from .process_args import * -from .quantile import * -from .scalar_rgb_vector import * -from .simulate_displacement_field import * -from .slice_image import * -from .smooth_image import * -from .threshold_image import * -from .weingarten_image_curvature import * -from .average_transform import * +from .add_noise_to_image import add_noise_to_image +from .bias_correction import (n3_bias_field_correction, n3_bias_field_correction2, n4_bias_field_correction, abp_n4) +from .channels import merge_channels, split_channels +from .compose_displacement_fields import compose_displacement_fields +from .convert_nibabel import (to_nibabel, from_nibabel, nifti_to_ants) +from .crop_image import (crop_image, + crop_indices, + decrop_image) +from .denoise_image import denoise_image +from .fit_bspline_object_to_scattered_data import fit_bspline_object_to_scattered_data +from .fit_bspline_displacement_field import fit_bspline_displacement_field +from .fit_thin_plate_spline_displacement_field import fit_thin_plate_spline_displacement_field +from .get_ants_data import (get_ants_data, + get_data) +from .get_centroids import get_centroids +from .get_mask import get_mask +from .get_neighborhood import (get_neighborhood_in_mask, + get_neighborhood_at_voxel) +from .histogram_match_image import histogram_match_image +from .hausdorff_distance import hausdorff_distance +from .image_similarity import image_similarity +from .image_to_cluster_images import image_to_cluster_images +from .iMath import (iMath, + image_math, + multiply_images, + iMath_get_largest_component, + iMath_normalize, + iMath_truncate_intensity, + iMath_sharpen, + iMath_pad, + iMath_maurer_distance, + iMath_perona_malik, + iMath_grad, + iMath_laplacian, + iMath_canny, + iMath_histogram_equalization, + iMath_MD, + iMath_ME, + iMath_MO, + iMath_MC, + iMath_GD, + iMath_GE, + iMath_GO, + iMath_GC, + iMath_fill_holes, + iMath_get_largest_component, + iMath_normalize, + iMath_truncate_intensity, + iMath_sharpen, + iMath_propagate_labels_through_mask) +from .impute import impute +from .integrate_velocity_field import integrate_velocity_field +from .invariant_image_similarity import (invariant_image_similarity, + convolve_image) +from .invert_displacement_field import invert_displacement_field +from .label_clusters import label_clusters +from .label_image_centroids import label_image_centroids +from .label_overlap_measures import label_overlap_measures +from .label_stats import label_stats +from .labels_to_matrix import labels_to_matrix +from .mask_image import mask_image +from .mni2tal import mni2tal +from .morphology import morphology +from .multi_label_morphology import multi_label_morphology +from .ndimage_to_list import (ndimage_to_list, + list_to_ndimage) +from .pad_image import pad_image +from .process_args import ( + get_pointer_string, + short_ptype, + _ptrstr, + _int_antsProcessArguments, + get_lib_fn, +) +from .quantile import (ilr, + rank_intensity, + quantile, + regress_poly, + regress_components, + get_average_of_timeseries, + compcor, + bandpass_filter_matrix ) +from .scalar_rgb_vector import (rgb_to_vector, vector_to_rgb, scalar_to_rgb) +from .simulate_displacement_field import simulate_displacement_field +from .slice_image import slice_image +from .smooth_image import smooth_image +from .threshold_image import threshold_image +from .weingarten_image_curvature import weingarten_image_curvature +from .average_transform import average_affine_transform, average_affine_transform_no_rigid from .averaging import average_images diff --git a/ants/utils/average_transform.py b/ants/utils/average_transform.py index 617b5630..057f2f23 100644 --- a/ants/utils/average_transform.py +++ b/ants/utils/average_transform.py @@ -2,6 +2,7 @@ from tempfile import mktemp import os +__all__ = ['average_affine_transform', 'average_affine_transform_no_rigid'] def _average_affine_transform_driver(transformlist, referencetransform=None, funcname="AverageAffineTransform"): diff --git a/ants/utils/averaging.py b/ants/utils/averaging.py index 80136ae7..27b6002a 100644 --- a/ants/utils/averaging.py +++ b/ants/utils/averaging.py @@ -8,6 +8,7 @@ from ..core import ants_image_io as iio2 from .. import registration as reg +__all__ = ['average_images'] ######################## def average_images( x, normalize=True, mask=None, imagetype=0, sum_image_threshold=3, return_sum_image=False, verbose=False ): """ diff --git a/ants/viz/__init__.py b/ants/viz/__init__.py index 7e585f10..1ebd977d 100644 --- a/ants/viz/__init__.py +++ b/ants/viz/__init__.py @@ -1,5 +1,14 @@ -from .create_tiled_mosaic import * -from .plot import * -from .render_surface_function import * -from .surface import * -from .volume import * +from .create_tiled_mosaic import create_tiled_mosaic +from .plot import ( + plot, + movie, + plot_hist, + plot_grid, + plot_ortho, + plot_ortho_double, + plot_ortho_stack, + plot_directory, +) +from .render_surface_function import render_surface_function +from .surface import (surf, surf_fold, surf_smooth, get_canonical_views) +from .volume import (vol, vol_fold) From 6e04e8f5f6f922ac4de45d4db3abc51af9865935 Mon Sep 17 00:00:00 2001 From: ncullen93 Date: Fri, 16 Feb 2024 00:01:07 +0100 Subject: [PATCH 4/4] remove print --- ants/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ants/__init__.py b/ants/__init__.py index 1ff3e4c3..193ddf21 100644 --- a/ants/__init__.py +++ b/ants/__init__.py @@ -11,6 +11,4 @@ from .learn import * from .viz import * -from . import contrib - -print('here') \ No newline at end of file +from . import contrib \ No newline at end of file