repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mkorpela/pabot | pabot/pabotlib.py | PabotLib.get_value_from_set | def get_value_from_set(self, key):
"""
Get a value from previously reserved value set.
"""
#TODO: This should be done locally.
# We do not really need to call centralised server if the set is already
# reserved as the data there is immutable during execution
key ... | python | def get_value_from_set(self, key):
"""
Get a value from previously reserved value set.
"""
#TODO: This should be done locally.
# We do not really need to call centralised server if the set is already
# reserved as the data there is immutable during execution
key ... | [
"def",
"get_value_from_set",
"(",
"self",
",",
"key",
")",
":",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"if",
"self",
".",
"_remotelib",
":",
"while",
"True",
":",
"value",
"=",
"self",
".",
"_remotelib",
".",
"run_keyword",
"(",
"'get_value_from_set'... | Get a value from previously reserved value set. | [
"Get",
"a",
"value",
"from",
"previously",
"reserved",
"value",
"set",
"."
] | b7d85546a58e398d579bb14fd9135858ec08a031 | https://github.com/mkorpela/pabot/blob/b7d85546a58e398d579bb14fd9135858ec08a031/pabot/pabotlib.py#L260-L277 | train |
mkorpela/pabot | pabot/pabotlib.py | PabotLib.release_value_set | def release_value_set(self):
"""
Release a reserved value set so that other executions can use it also.
"""
if self._remotelib:
self._remotelib.run_keyword('release_value_set', [self._my_id], {})
else:
_PabotLib.release_value_set(self, self._my_id) | python | def release_value_set(self):
"""
Release a reserved value set so that other executions can use it also.
"""
if self._remotelib:
self._remotelib.run_keyword('release_value_set', [self._my_id], {})
else:
_PabotLib.release_value_set(self, self._my_id) | [
"def",
"release_value_set",
"(",
"self",
")",
":",
"if",
"self",
".",
"_remotelib",
":",
"self",
".",
"_remotelib",
".",
"run_keyword",
"(",
"'release_value_set'",
",",
"[",
"self",
".",
"_my_id",
"]",
",",
"{",
"}",
")",
"else",
":",
"_PabotLib",
".",
... | Release a reserved value set so that other executions can use it also. | [
"Release",
"a",
"reserved",
"value",
"set",
"so",
"that",
"other",
"executions",
"can",
"use",
"it",
"also",
"."
] | b7d85546a58e398d579bb14fd9135858ec08a031 | https://github.com/mkorpela/pabot/blob/b7d85546a58e398d579bb14fd9135858ec08a031/pabot/pabotlib.py#L279-L286 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/client_hooks/__init__.py | install_all_patches | def install_all_patches():
"""
A convenience method that installs all available hooks.
If a specific module is not available on the path, it is ignored.
"""
from . import mysqldb
from . import psycopg2
from . import strict_redis
from . import sqlalchemy
from . import tornado_http
... | python | def install_all_patches():
"""
A convenience method that installs all available hooks.
If a specific module is not available on the path, it is ignored.
"""
from . import mysqldb
from . import psycopg2
from . import strict_redis
from . import sqlalchemy
from . import tornado_http
... | [
"def",
"install_all_patches",
"(",
")",
":",
"from",
".",
"import",
"mysqldb",
"from",
".",
"import",
"psycopg2",
"from",
".",
"import",
"strict_redis",
"from",
".",
"import",
"sqlalchemy",
"from",
".",
"import",
"tornado_http",
"from",
".",
"import",
"urllib"... | A convenience method that installs all available hooks.
If a specific module is not available on the path, it is ignored. | [
"A",
"convenience",
"method",
"that",
"installs",
"all",
"available",
"hooks",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/client_hooks/__init__.py#L33-L55 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/client_hooks/__init__.py | install_patches | def install_patches(patchers='all'):
"""
Usually called from middleware to install client hooks
specified in the client_hooks section of the configuration.
:param patchers: a list of patchers to run. Acceptable values include:
* None - installs all client patches
* 'all' - installs all clie... | python | def install_patches(patchers='all'):
"""
Usually called from middleware to install client hooks
specified in the client_hooks section of the configuration.
:param patchers: a list of patchers to run. Acceptable values include:
* None - installs all client patches
* 'all' - installs all clie... | [
"def",
"install_patches",
"(",
"patchers",
"=",
"'all'",
")",
":",
"if",
"patchers",
"is",
"None",
"or",
"patchers",
"==",
"'all'",
":",
"install_all_patches",
"(",
")",
"return",
"if",
"not",
"_valid_args",
"(",
"patchers",
")",
":",
"raise",
"ValueError",
... | Usually called from middleware to install client hooks
specified in the client_hooks section of the configuration.
:param patchers: a list of patchers to run. Acceptable values include:
* None - installs all client patches
* 'all' - installs all client patches
* empty list - does not install ... | [
"Usually",
"called",
"from",
"middleware",
"to",
"install",
"client",
"hooks",
"specified",
"in",
"the",
"client_hooks",
"section",
"of",
"the",
"configuration",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/client_hooks/__init__.py#L58-L79 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/client_hooks/__init__.py | install_client_interceptors | def install_client_interceptors(client_interceptors=()):
"""
Install client interceptors for the patchers.
:param client_interceptors: a list of client interceptors to install.
Should be a list of classes
"""
if not _valid_args(client_interceptors):
raise ValueError('client_intercep... | python | def install_client_interceptors(client_interceptors=()):
"""
Install client interceptors for the patchers.
:param client_interceptors: a list of client interceptors to install.
Should be a list of classes
"""
if not _valid_args(client_interceptors):
raise ValueError('client_intercep... | [
"def",
"install_client_interceptors",
"(",
"client_interceptors",
"=",
"(",
")",
")",
":",
"if",
"not",
"_valid_args",
"(",
"client_interceptors",
")",
":",
"raise",
"ValueError",
"(",
"'client_interceptors argument must be a list'",
")",
"from",
".",
".",
"http_clien... | Install client interceptors for the patchers.
:param client_interceptors: a list of client interceptors to install.
Should be a list of classes | [
"Install",
"client",
"interceptors",
"for",
"the",
"patchers",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/client_hooks/__init__.py#L82-L98 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/client_hooks/__init__.py | _load_symbol | def _load_symbol(name):
"""Load a symbol by name.
:param str name: The name to load, specified by `module.attr`.
:returns: The attribute value. If the specified module does not contain
the requested attribute then `None` is returned.
"""
module_name, key = name.rsplit('.', 1)
try:... | python | def _load_symbol(name):
"""Load a symbol by name.
:param str name: The name to load, specified by `module.attr`.
:returns: The attribute value. If the specified module does not contain
the requested attribute then `None` is returned.
"""
module_name, key = name.rsplit('.', 1)
try:... | [
"def",
"_load_symbol",
"(",
"name",
")",
":",
"module_name",
",",
"key",
"=",
"name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"try",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"except",
"ImportError",
"as",
"err",
... | Load a symbol by name.
:param str name: The name to load, specified by `module.attr`.
:returns: The attribute value. If the specified module does not contain
the requested attribute then `None` is returned. | [
"Load",
"a",
"symbol",
"by",
"name",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/client_hooks/__init__.py#L106-L129 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/request_context.py | span_in_stack_context | def span_in_stack_context(span):
"""
Create Tornado's StackContext that stores the given span in the
thread-local request context. This function is intended for use
in Tornado applications based on IOLoop, although will work fine
in single-threaded apps like Flask, albeit with more overhead.
##... | python | def span_in_stack_context(span):
"""
Create Tornado's StackContext that stores the given span in the
thread-local request context. This function is intended for use
in Tornado applications based on IOLoop, although will work fine
in single-threaded apps like Flask, albeit with more overhead.
##... | [
"def",
"span_in_stack_context",
"(",
"span",
")",
":",
"if",
"not",
"isinstance",
"(",
"opentracing",
".",
"tracer",
".",
"scope_manager",
",",
"TornadoScopeManager",
")",
":",
"raise",
"RuntimeError",
"(",
"'scope_manager is not TornadoScopeManager'",
")",
"context",... | Create Tornado's StackContext that stores the given span in the
thread-local request context. This function is intended for use
in Tornado applications based on IOLoop, although will work fine
in single-threaded apps like Flask, albeit with more overhead.
## Usage example in Tornado application
Su... | [
"Create",
"Tornado",
"s",
"StackContext",
"that",
"stores",
"the",
"given",
"span",
"in",
"the",
"thread",
"-",
"local",
"request",
"context",
".",
"This",
"function",
"is",
"intended",
"for",
"use",
"in",
"Tornado",
"applications",
"based",
"on",
"IOLoop",
... | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/request_context.py#L181-L226 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/local_span.py | traced_function | def traced_function(func=None, name=None, on_start=None,
require_active_trace=False):
"""
A decorator that enables tracing of the wrapped function or
Tornado co-routine provided there is a parent span already established.
.. code-block:: python
@traced_function
def ... | python | def traced_function(func=None, name=None, on_start=None,
require_active_trace=False):
"""
A decorator that enables tracing of the wrapped function or
Tornado co-routine provided there is a parent span already established.
.. code-block:: python
@traced_function
def ... | [
"def",
"traced_function",
"(",
"func",
"=",
"None",
",",
"name",
"=",
"None",
",",
"on_start",
"=",
"None",
",",
"require_active_trace",
"=",
"False",
")",
":",
"if",
"func",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"traced_function",... | A decorator that enables tracing of the wrapped function or
Tornado co-routine provided there is a parent span already established.
.. code-block:: python
@traced_function
def my_function1(arg1, arg2=None)
...
:param func: decorated function or Tornado co-routine
:param na... | [
"A",
"decorator",
"that",
"enables",
"tracing",
"of",
"the",
"wrapped",
"function",
"or",
"Tornado",
"co",
"-",
"routine",
"provided",
"there",
"is",
"a",
"parent",
"span",
"already",
"established",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/local_span.py#L64-L153 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/utils.py | start_child_span | def start_child_span(operation_name, tracer=None, parent=None, tags=None):
"""
Start a new span as a child of parent_span. If parent_span is None,
start a new root span.
:param operation_name: operation name
:param tracer: Tracer or None (defaults to opentracing.tracer)
:param parent: parent Sp... | python | def start_child_span(operation_name, tracer=None, parent=None, tags=None):
"""
Start a new span as a child of parent_span. If parent_span is None,
start a new root span.
:param operation_name: operation name
:param tracer: Tracer or None (defaults to opentracing.tracer)
:param parent: parent Sp... | [
"def",
"start_child_span",
"(",
"operation_name",
",",
"tracer",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"tracer",
"=",
"tracer",
"or",
"opentracing",
".",
"tracer",
"return",
"tracer",
".",
"start_span",
"(",
"operatio... | Start a new span as a child of parent_span. If parent_span is None,
start a new root span.
:param operation_name: operation name
:param tracer: Tracer or None (defaults to opentracing.tracer)
:param parent: parent Span or None
:param tags: optional tags
:return: new span | [
"Start",
"a",
"new",
"span",
"as",
"a",
"child",
"of",
"parent_span",
".",
"If",
"parent_span",
"is",
"None",
"start",
"a",
"new",
"root",
"span",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/utils.py#L25-L41 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/http_server.py | before_request | def before_request(request, tracer=None):
"""
Attempts to extract a tracing span from incoming request.
If no tracing context is passed in the headers, or the data
cannot be parsed, a new root span is started.
:param request: HTTP request with `.headers` property exposed
that satisfies a re... | python | def before_request(request, tracer=None):
"""
Attempts to extract a tracing span from incoming request.
If no tracing context is passed in the headers, or the data
cannot be parsed, a new root span is started.
:param request: HTTP request with `.headers` property exposed
that satisfies a re... | [
"def",
"before_request",
"(",
"request",
",",
"tracer",
"=",
"None",
")",
":",
"if",
"tracer",
"is",
"None",
":",
"tracer",
"=",
"opentracing",
".",
"tracer",
"tags_dict",
"=",
"{",
"tags",
".",
"SPAN_KIND",
":",
"tags",
".",
"SPAN_KIND_RPC_SERVER",
",",
... | Attempts to extract a tracing span from incoming request.
If no tracing context is passed in the headers, or the data
cannot be parsed, a new root span is started.
:param request: HTTP request with `.headers` property exposed
that satisfies a regular dictionary interface
:param tracer: optional... | [
"Attempts",
"to",
"extract",
"a",
"tracing",
"span",
"from",
"incoming",
"request",
".",
"If",
"no",
"tracing",
"context",
"is",
"passed",
"in",
"the",
"headers",
"or",
"the",
"data",
"cannot",
"be",
"parsed",
"a",
"new",
"root",
"span",
"is",
"started",
... | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/http_server.py#L35-L86 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/http_server.py | WSGIRequestWrapper._parse_wsgi_headers | def _parse_wsgi_headers(wsgi_environ):
"""
HTTP headers are presented in WSGI environment with 'HTTP_' prefix.
This method finds those headers, removes the prefix, converts
underscores to dashes, and converts to lower case.
:param wsgi_environ:
:return: returns a diction... | python | def _parse_wsgi_headers(wsgi_environ):
"""
HTTP headers are presented in WSGI environment with 'HTTP_' prefix.
This method finds those headers, removes the prefix, converts
underscores to dashes, and converts to lower case.
:param wsgi_environ:
:return: returns a diction... | [
"def",
"_parse_wsgi_headers",
"(",
"wsgi_environ",
")",
":",
"prefix",
"=",
"'HTTP_'",
"p_len",
"=",
"len",
"(",
"prefix",
")",
"headers",
"=",
"{",
"key",
"[",
"p_len",
":",
"]",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
".",
"lower",
"(",
")",
... | HTTP headers are presented in WSGI environment with 'HTTP_' prefix.
This method finds those headers, removes the prefix, converts
underscores to dashes, and converts to lower case.
:param wsgi_environ:
:return: returns a dictionary of headers | [
"HTTP",
"headers",
"are",
"presented",
"in",
"WSGI",
"environment",
"with",
"HTTP_",
"prefix",
".",
"This",
"method",
"finds",
"those",
"headers",
"removes",
"the",
"prefix",
"converts",
"underscores",
"to",
"dashes",
"and",
"converts",
"to",
"lower",
"case",
... | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/http_server.py#L174-L191 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/interceptors.py | ClientInterceptors.append | def append(cls, interceptor):
"""
Add interceptor to the end of the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.append(interceptor) | python | def append(cls, interceptor):
"""
Add interceptor to the end of the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.append(interceptor) | [
"def",
"append",
"(",
"cls",
",",
"interceptor",
")",
":",
"cls",
".",
"_check",
"(",
"interceptor",
")",
"cls",
".",
"_interceptors",
".",
"append",
"(",
"interceptor",
")"
] | Add interceptor to the end of the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor`` | [
"Add",
"interceptor",
"to",
"the",
"end",
"of",
"the",
"internal",
"list",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/interceptors.py#L80-L88 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/interceptors.py | ClientInterceptors.insert | def insert(cls, index, interceptor):
"""
Add interceptor to the given index in the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.insert(index, interceptor) | python | def insert(cls, index, interceptor):
"""
Add interceptor to the given index in the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.insert(index, interceptor) | [
"def",
"insert",
"(",
"cls",
",",
"index",
",",
"interceptor",
")",
":",
"cls",
".",
"_check",
"(",
"interceptor",
")",
"cls",
".",
"_interceptors",
".",
"insert",
"(",
"index",
",",
"interceptor",
")"
] | Add interceptor to the given index in the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor`` | [
"Add",
"interceptor",
"to",
"the",
"given",
"index",
"in",
"the",
"internal",
"list",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/interceptors.py#L91-L99 | train |
uber-common/opentracing-python-instrumentation | opentracing_instrumentation/client_hooks/_singleton.py | singleton | def singleton(func):
"""
This decorator allows you to make sure that a function is called once and
only once. Note that recursive functions will still work.
WARNING: Not thread-safe!!!
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if wrapper.__call_state__ == CALLED:
... | python | def singleton(func):
"""
This decorator allows you to make sure that a function is called once and
only once. Note that recursive functions will still work.
WARNING: Not thread-safe!!!
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if wrapper.__call_state__ == CALLED:
... | [
"def",
"singleton",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"wrapper",
".",
"__call_state__",
"==",
"CALLED",
":",
"return",
"ret",
"=",
"func",... | This decorator allows you to make sure that a function is called once and
only once. Note that recursive functions will still work.
WARNING: Not thread-safe!!! | [
"This",
"decorator",
"allows",
"you",
"to",
"make",
"sure",
"that",
"a",
"function",
"is",
"called",
"once",
"and",
"only",
"once",
".",
"Note",
"that",
"recursive",
"functions",
"will",
"still",
"work",
"."
] | 57b29fb9f647e073cde8c75155f4708cb5661d20 | https://github.com/uber-common/opentracing-python-instrumentation/blob/57b29fb9f647e073cde8c75155f4708cb5661d20/opentracing_instrumentation/client_hooks/_singleton.py#L30-L55 | train |
ANTsX/ANTsPy | ants/utils/smooth_image.py | smooth_image | def smooth_image(image, sigma, sigma_in_physical_coordinates=True, FWHM=False, max_kernel_width=32):
"""
Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is... | python | def smooth_image(image, sigma, sigma_in_physical_coordinates=True, FWHM=False, max_kernel_width=32):
"""
Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is... | [
"def",
"smooth_image",
"(",
"image",
",",
"sigma",
",",
"sigma_in_physical_coordinates",
"=",
"True",
",",
"FWHM",
"=",
"False",
",",
"max_kernel_width",
"=",
"32",
")",
":",
"if",
"image",
".",
"components",
"==",
"1",
":",
"return",
"_smooth_image_helper",
... | Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is applied to each dimension, or a vector of length dim(inimage) to specify a unique smoothness for each dimension.... | [
"Smooth",
"an",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/smooth_image.py#L34-L75 | train |
ANTsX/ANTsPy | ants/registration/build_template.py | build_template | def build_template(
initial_template=None,
image_list=None,
iterations = 3,
gradient_step = 0.2,
**kwargs ):
"""
Estimate an optimal template from an input image_list
ANTsR function: N/A
Arguments
---------
initial_template : ANTsImage
initialization for the templat... | python | def build_template(
initial_template=None,
image_list=None,
iterations = 3,
gradient_step = 0.2,
**kwargs ):
"""
Estimate an optimal template from an input image_list
ANTsR function: N/A
Arguments
---------
initial_template : ANTsImage
initialization for the templat... | [
"def",
"build_template",
"(",
"initial_template",
"=",
"None",
",",
"image_list",
"=",
"None",
",",
"iterations",
"=",
"3",
",",
"gradient_step",
"=",
"0.2",
",",
"**",
"kwargs",
")",
":",
"wt",
"=",
"1.0",
"/",
"len",
"(",
"image_list",
")",
"if",
"in... | Estimate an optimal template from an input image_list
ANTsR function: N/A
Arguments
---------
initial_template : ANTsImage
initialization for the template building
image_list : ANTsImages
images from which to estimate template
iterations : integer
number of template b... | [
"Estimate",
"an",
"optimal",
"template",
"from",
"an",
"input",
"image_list"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/build_template.py#L13-L77 | train |
ANTsX/ANTsPy | ants/registration/resample_image.py | resample_image | def resample_image(image, resample_params, use_voxels=False, interp_type=1):
"""
Resample image by spacing or number of voxels with
various interpolators. Works with multi-channel images.
ANTsR function: `resampleImage`
Arguments
---------
image : ANTsImage
input image
re... | python | def resample_image(image, resample_params, use_voxels=False, interp_type=1):
"""
Resample image by spacing or number of voxels with
various interpolators. Works with multi-channel images.
ANTsR function: `resampleImage`
Arguments
---------
image : ANTsImage
input image
re... | [
"def",
"resample_image",
"(",
"image",
",",
"resample_params",
",",
"use_voxels",
"=",
"False",
",",
"interp_type",
"=",
"1",
")",
":",
"if",
"image",
".",
"components",
"==",
"1",
":",
"inimage",
"=",
"image",
".",
"clone",
"(",
"'float'",
")",
"outimag... | Resample image by spacing or number of voxels with
various interpolators. Works with multi-channel images.
ANTsR function: `resampleImage`
Arguments
---------
image : ANTsImage
input image
resample_params : tuple/list
vector of size dimension with numeric values
... | [
"Resample",
"image",
"by",
"spacing",
"or",
"number",
"of",
"voxels",
"with",
"various",
"interpolators",
".",
"Works",
"with",
"multi",
"-",
"channel",
"images",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/resample_image.py#L12-L56 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | apply_ants_transform | def apply_ants_transform(transform, data, data_type="point", reference=None, **kwargs):
"""
Apply ANTsTransform to data
ANTsR function: `applyAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to apply to image
data : ndarray/list/tuple
data to which t... | python | def apply_ants_transform(transform, data, data_type="point", reference=None, **kwargs):
"""
Apply ANTsTransform to data
ANTsR function: `applyAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to apply to image
data : ndarray/list/tuple
data to which t... | [
"def",
"apply_ants_transform",
"(",
"transform",
",",
"data",
",",
"data_type",
"=",
"\"point\"",
",",
"reference",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"return",
"transform",
".",
"apply",
"(",
"data",
",",
"data_type",
",",
"reference",
",",
"**",... | Apply ANTsTransform to data
ANTsR function: `applyAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to apply to image
data : ndarray/list/tuple
data to which transform will be applied
data_type : string
type of data
Options :
... | [
"Apply",
"ANTsTransform",
"to",
"data"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L225-L258 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | compose_ants_transforms | def compose_ants_transforms(transform_list):
"""
Compose multiple ANTsTransform's together
ANTsR function: `composeAntsrTransforms`
Arguments
---------
transform_list : list/tuple of ANTsTransform object
list of transforms to compose together
Returns
-------
ANTsTransform
... | python | def compose_ants_transforms(transform_list):
"""
Compose multiple ANTsTransform's together
ANTsR function: `composeAntsrTransforms`
Arguments
---------
transform_list : list/tuple of ANTsTransform object
list of transforms to compose together
Returns
-------
ANTsTransform
... | [
"def",
"compose_ants_transforms",
"(",
"transform_list",
")",
":",
"precision",
"=",
"transform_list",
"[",
"0",
"]",
".",
"precision",
"dimension",
"=",
"transform_list",
"[",
"0",
"]",
".",
"dimension",
"for",
"tx",
"in",
"transform_list",
":",
"if",
"precis... | Compose multiple ANTsTransform's together
ANTsR function: `composeAntsrTransforms`
Arguments
---------
transform_list : list/tuple of ANTsTransform object
list of transforms to compose together
Returns
-------
ANTsTransform
one transform that contains all given transforms
... | [
"Compose",
"multiple",
"ANTsTransform",
"s",
"together"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L355-L400 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | transform_index_to_physical_point | def transform_index_to_physical_point(image, index):
"""
Get spatial point from index of an image.
ANTsR function: `antsTransformIndexToPhysicalPoint`
Arguments
---------
img : ANTsImage
image to get values from
index : list or tuple or numpy.ndarray
location in image
... | python | def transform_index_to_physical_point(image, index):
"""
Get spatial point from index of an image.
ANTsR function: `antsTransformIndexToPhysicalPoint`
Arguments
---------
img : ANTsImage
image to get values from
index : list or tuple or numpy.ndarray
location in image
... | [
"def",
"transform_index_to_physical_point",
"(",
"image",
",",
"index",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"iio",
".",
"ANTsImage",
")",
":",
"raise",
"ValueError",
"(",
"'image must be ANTsImage type'",
")",
"if",
"isinstance",
"(",
"index"... | Get spatial point from index of an image.
ANTsR function: `antsTransformIndexToPhysicalPoint`
Arguments
---------
img : ANTsImage
image to get values from
index : list or tuple or numpy.ndarray
location in image
Returns
-------
tuple
Example
-------
>>> i... | [
"Get",
"spatial",
"point",
"from",
"index",
"of",
"an",
"image",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L403-L446 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | ANTsTransform.invert | def invert(self):
""" Invert the transform """
libfn = utils.get_lib_fn('inverseTransform%s' % (self._libsuffix))
inv_tx_ptr = libfn(self.pointer)
new_tx = ANTsTransform(precision=self.precision, dimension=self.dimension,
transform_type=self.transform_typ... | python | def invert(self):
""" Invert the transform """
libfn = utils.get_lib_fn('inverseTransform%s' % (self._libsuffix))
inv_tx_ptr = libfn(self.pointer)
new_tx = ANTsTransform(precision=self.precision, dimension=self.dimension,
transform_type=self.transform_typ... | [
"def",
"invert",
"(",
"self",
")",
":",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'inverseTransform%s'",
"%",
"(",
"self",
".",
"_libsuffix",
")",
")",
"inv_tx_ptr",
"=",
"libfn",
"(",
"self",
".",
"pointer",
")",
"new_tx",
"=",
"ANTsTransform",
"(... | Invert the transform | [
"Invert",
"the",
"transform"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L87-L95 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | ANTsTransform.apply | def apply(self, data, data_type='point', reference=None, **kwargs):
"""
Apply transform to data
"""
if data_type == 'point':
return self.apply_to_point(data)
elif data_type == 'vector':
return self.apply_to_vector(data)
elif data_type == 'image':
... | python | def apply(self, data, data_type='point', reference=None, **kwargs):
"""
Apply transform to data
"""
if data_type == 'point':
return self.apply_to_point(data)
elif data_type == 'vector':
return self.apply_to_vector(data)
elif data_type == 'image':
... | [
"def",
"apply",
"(",
"self",
",",
"data",
",",
"data_type",
"=",
"'point'",
",",
"reference",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"data_type",
"==",
"'point'",
":",
"return",
"self",
".",
"apply_to_point",
"(",
"data",
")",
"elif",
"data_... | Apply transform to data | [
"Apply",
"transform",
"to",
"data"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L97-L107 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | ANTsTransform.apply_to_point | def apply_to_point(self, point):
"""
Apply transform to a point
Arguments
---------
point : list/tuple
point to which the transform will be applied
Returns
-------
list : transformed point
Example
-------
>>> import a... | python | def apply_to_point(self, point):
"""
Apply transform to a point
Arguments
---------
point : list/tuple
point to which the transform will be applied
Returns
-------
list : transformed point
Example
-------
>>> import a... | [
"def",
"apply_to_point",
"(",
"self",
",",
"point",
")",
":",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'transformPoint%s'",
"%",
"(",
"self",
".",
"_libsuffix",
")",
")",
"return",
"tuple",
"(",
"libfn",
"(",
"self",
".",
"pointer",
",",
"point",
... | Apply transform to a point
Arguments
---------
point : list/tuple
point to which the transform will be applied
Returns
-------
list : transformed point
Example
-------
>>> import ants
>>> tx = ants.new_ants_transform()
... | [
"Apply",
"transform",
"to",
"a",
"point"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L109-L131 | train |
ANTsX/ANTsPy | ants/core/ants_transform.py | ANTsTransform.apply_to_vector | def apply_to_vector(self, vector):
"""
Apply transform to a vector
Arguments
---------
vector : list/tuple
vector to which the transform will be applied
Returns
-------
list : transformed vector
"""
if isinstance(vector, np.nd... | python | def apply_to_vector(self, vector):
"""
Apply transform to a vector
Arguments
---------
vector : list/tuple
vector to which the transform will be applied
Returns
-------
list : transformed vector
"""
if isinstance(vector, np.nd... | [
"def",
"apply_to_vector",
"(",
"self",
",",
"vector",
")",
":",
"if",
"isinstance",
"(",
"vector",
",",
"np",
".",
"ndarray",
")",
":",
"vector",
"=",
"vector",
".",
"tolist",
"(",
")",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'transformVector%s'"... | Apply transform to a vector
Arguments
---------
vector : list/tuple
vector to which the transform will be applied
Returns
-------
list : transformed vector | [
"Apply",
"transform",
"to",
"a",
"vector"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform.py#L133-L150 | train |
ANTsX/ANTsPy | ants/viz/plot.py | plot_hist | def plot_hist(image, threshold=0., fit_line=False, normfreq=True,
## plot label arguments
title=None, grid=True, xlabel=None, ylabel=None,
## other plot arguments
facecolor='green', alpha=0.75):
"""
Plot a histogram from an ANTsImage
Arguments
---------
image : ANTsImage
ima... | python | def plot_hist(image, threshold=0., fit_line=False, normfreq=True,
## plot label arguments
title=None, grid=True, xlabel=None, ylabel=None,
## other plot arguments
facecolor='green', alpha=0.75):
"""
Plot a histogram from an ANTsImage
Arguments
---------
image : ANTsImage
ima... | [
"def",
"plot_hist",
"(",
"image",
",",
"threshold",
"=",
"0.",
",",
"fit_line",
"=",
"False",
",",
"normfreq",
"=",
"True",
",",
"title",
"=",
"None",
",",
"grid",
"=",
"True",
",",
"xlabel",
"=",
"None",
",",
"ylabel",
"=",
"None",
",",
"facecolor",... | Plot a histogram from an ANTsImage
Arguments
---------
image : ANTsImage
image from which histogram will be created | [
"Plot",
"a",
"histogram",
"from",
"an",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/viz/plot.py#L91-L124 | train |
ANTsX/ANTsPy | ants/utils/morphology.py | morphology | def morphology(image, operation, radius, mtype='binary', value=1,
shape='ball', radius_is_parametric=False, thickness=1,
lines=3, include_center=False):
"""
Apply morphological operations to an image
ANTsR function: `morphology`
Arguments
---------
input : ANTsIma... | python | def morphology(image, operation, radius, mtype='binary', value=1,
shape='ball', radius_is_parametric=False, thickness=1,
lines=3, include_center=False):
"""
Apply morphological operations to an image
ANTsR function: `morphology`
Arguments
---------
input : ANTsIma... | [
"def",
"morphology",
"(",
"image",
",",
"operation",
",",
"radius",
",",
"mtype",
"=",
"'binary'",
",",
"value",
"=",
"1",
",",
"shape",
"=",
"'ball'",
",",
"radius_is_parametric",
"=",
"False",
",",
"thickness",
"=",
"1",
",",
"lines",
"=",
"3",
",",
... | Apply morphological operations to an image
ANTsR function: `morphology`
Arguments
---------
input : ANTsImage
input image
operation : string
operation to apply
"close" Morpholgical closing
"dilate" Morpholgical dilation
"erode" Morpholgical eros... | [
"Apply",
"morphological",
"operations",
"to",
"an",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/morphology.py#L8-L120 | train |
ANTsX/ANTsPy | ants/utils/scalar_rgb_vector.py | rgb_to_vector | def rgb_to_vector(image):
"""
Convert an RGB ANTsImage to a Vector ANTsImage
Arguments
---------
image : ANTsImage
RGB image to be converted
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni_rg... | python | def rgb_to_vector(image):
"""
Convert an RGB ANTsImage to a Vector ANTsImage
Arguments
---------
image : ANTsImage
RGB image to be converted
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni_rg... | [
"def",
"rgb_to_vector",
"(",
"image",
")",
":",
"if",
"image",
".",
"pixeltype",
"!=",
"'unsigned char'",
":",
"image",
"=",
"image",
".",
"clone",
"(",
"'unsigned char'",
")",
"idim",
"=",
"image",
".",
"dimension",
"libfn",
"=",
"utils",
".",
"get_lib_fn... | Convert an RGB ANTsImage to a Vector ANTsImage
Arguments
---------
image : ANTsImage
RGB image to be converted
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni_rgb = mni.scalar_to_rgb()
>>> mni_ve... | [
"Convert",
"an",
"RGB",
"ANTsImage",
"to",
"a",
"Vector",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/scalar_rgb_vector.py#L78-L106 | train |
ANTsX/ANTsPy | ants/utils/scalar_rgb_vector.py | vector_to_rgb | def vector_to_rgb(image):
"""
Convert an Vector ANTsImage to a RGB ANTsImage
Arguments
---------
image : ANTsImage
RGB image to be converted
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> img = ants.image_read(ants.get_data('r16'), pixeltype='uns... | python | def vector_to_rgb(image):
"""
Convert an Vector ANTsImage to a RGB ANTsImage
Arguments
---------
image : ANTsImage
RGB image to be converted
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> img = ants.image_read(ants.get_data('r16'), pixeltype='uns... | [
"def",
"vector_to_rgb",
"(",
"image",
")",
":",
"if",
"image",
".",
"pixeltype",
"!=",
"'unsigned char'",
":",
"image",
"=",
"image",
".",
"clone",
"(",
"'unsigned char'",
")",
"idim",
"=",
"image",
".",
"dimension",
"libfn",
"=",
"utils",
".",
"get_lib_fn... | Convert an Vector ANTsImage to a RGB ANTsImage
Arguments
---------
image : ANTsImage
RGB image to be converted
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> img = ants.image_read(ants.get_data('r16'), pixeltype='unsigned char')
>>> img_rgb = img.clo... | [
"Convert",
"an",
"Vector",
"ANTsImage",
"to",
"a",
"RGB",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/scalar_rgb_vector.py#L109-L137 | train |
ANTsX/ANTsPy | ants/utils/quantile.py | quantile | def quantile(image, q, nonzero=True):
"""
Get the quantile values from an ANTsImage
"""
img_arr = image.numpy()
if isinstance(q, (list,tuple)):
q = [qq*100. if qq <= 1. else qq for qq in q]
if nonzero:
img_arr = img_arr[img_arr>0]
vals = [np.percentile(img_arr, qq... | python | def quantile(image, q, nonzero=True):
"""
Get the quantile values from an ANTsImage
"""
img_arr = image.numpy()
if isinstance(q, (list,tuple)):
q = [qq*100. if qq <= 1. else qq for qq in q]
if nonzero:
img_arr = img_arr[img_arr>0]
vals = [np.percentile(img_arr, qq... | [
"def",
"quantile",
"(",
"image",
",",
"q",
",",
"nonzero",
"=",
"True",
")",
":",
"img_arr",
"=",
"image",
".",
"numpy",
"(",
")",
"if",
"isinstance",
"(",
"q",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"q",
"=",
"[",
"qq",
"*",
"100.",
... | Get the quantile values from an ANTsImage | [
"Get",
"the",
"quantile",
"values",
"from",
"an",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/quantile.py#L153-L171 | train |
ANTsX/ANTsPy | ants/utils/quantile.py | bandpass_filter_matrix | def bandpass_filter_matrix( matrix,
tr=1, lowf=0.01, highf=0.1, order = 3):
"""
Bandpass filter the input time series image
ANTsR function: `frequencyFilterfMRI`
Arguments
---------
image: input time series image
tr: sampling time interval (inverse of sampling rate)
lowf: lo... | python | def bandpass_filter_matrix( matrix,
tr=1, lowf=0.01, highf=0.1, order = 3):
"""
Bandpass filter the input time series image
ANTsR function: `frequencyFilterfMRI`
Arguments
---------
image: input time series image
tr: sampling time interval (inverse of sampling rate)
lowf: lo... | [
"def",
"bandpass_filter_matrix",
"(",
"matrix",
",",
"tr",
"=",
"1",
",",
"lowf",
"=",
"0.01",
",",
"highf",
"=",
"0.1",
",",
"order",
"=",
"3",
")",
":",
"from",
"scipy",
".",
"signal",
"import",
"butter",
",",
"filtfilt",
"def",
"butter_bandpass",
"(... | Bandpass filter the input time series image
ANTsR function: `frequencyFilterfMRI`
Arguments
---------
image: input time series image
tr: sampling time interval (inverse of sampling rate)
lowf: low frequency cutoff
highf: high frequency cutoff
order: order of the butterworth fi... | [
"Bandpass",
"filter",
"the",
"input",
"time",
"series",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/quantile.py#L227-L292 | train |
ANTsX/ANTsPy | ants/utils/quantile.py | compcor | def compcor( boldImage, ncompcor=4, quantile=0.975, mask=None, filter_type=False, degree=2 ):
"""
Compute noise components from the input image
ANTsR function: `compcor`
this is adapted from nipy code https://github.com/nipy/nipype/blob/e29ac95fc0fc00fedbcaa0adaf29d5878408ca7c/nipype/algorithms/confou... | python | def compcor( boldImage, ncompcor=4, quantile=0.975, mask=None, filter_type=False, degree=2 ):
"""
Compute noise components from the input image
ANTsR function: `compcor`
this is adapted from nipy code https://github.com/nipy/nipype/blob/e29ac95fc0fc00fedbcaa0adaf29d5878408ca7c/nipype/algorithms/confou... | [
"def",
"compcor",
"(",
"boldImage",
",",
"ncompcor",
"=",
"4",
",",
"quantile",
"=",
"0.975",
",",
"mask",
"=",
"None",
",",
"filter_type",
"=",
"False",
",",
"degree",
"=",
"2",
")",
":",
"def",
"compute_tSTD",
"(",
"M",
",",
"quantile",
",",
"x",
... | Compute noise components from the input image
ANTsR function: `compcor`
this is adapted from nipy code https://github.com/nipy/nipype/blob/e29ac95fc0fc00fedbcaa0adaf29d5878408ca7c/nipype/algorithms/confounds.py
Arguments
---------
boldImage: input time series image
ncompcor: number of nois... | [
"Compute",
"noise",
"components",
"from",
"the",
"input",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/quantile.py#L295-L367 | train |
ANTsX/ANTsPy | ants/utils/bias_correction.py | n3_bias_field_correction | def n3_bias_field_correction(image, downsample_factor=3):
"""
N3 Bias Field Correction
ANTsR function: `n3BiasFieldCorrection`
Arguments
---------
image : ANTsImage
image to be bias corrected
downsample_factor : scalar
how much to downsample image before performing bias co... | python | def n3_bias_field_correction(image, downsample_factor=3):
"""
N3 Bias Field Correction
ANTsR function: `n3BiasFieldCorrection`
Arguments
---------
image : ANTsImage
image to be bias corrected
downsample_factor : scalar
how much to downsample image before performing bias co... | [
"def",
"n3_bias_field_correction",
"(",
"image",
",",
"downsample_factor",
"=",
"3",
")",
":",
"outimage",
"=",
"image",
".",
"clone",
"(",
")",
"args",
"=",
"[",
"image",
".",
"dimension",
",",
"image",
",",
"outimage",
",",
"downsample_factor",
"]",
"pro... | N3 Bias Field Correction
ANTsR function: `n3BiasFieldCorrection`
Arguments
---------
image : ANTsImage
image to be bias corrected
downsample_factor : scalar
how much to downsample image before performing bias correction
Returns
-------
ANTsImage
Example
-----... | [
"N3",
"Bias",
"Field",
"Correction"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/bias_correction.py#L17-L46 | train |
ANTsX/ANTsPy | ants/utils/bias_correction.py | n4_bias_field_correction | def n4_bias_field_correction(image, mask=None, shrink_factor=4,
convergence={'iters':[50,50,50,50], 'tol':1e-07},
spline_param=200, verbose=False, weight_mask=None):
"""
N4 Bias Field Correction
ANTsR function: `n4BiasFieldCorrection`
Arguments... | python | def n4_bias_field_correction(image, mask=None, shrink_factor=4,
convergence={'iters':[50,50,50,50], 'tol':1e-07},
spline_param=200, verbose=False, weight_mask=None):
"""
N4 Bias Field Correction
ANTsR function: `n4BiasFieldCorrection`
Arguments... | [
"def",
"n4_bias_field_correction",
"(",
"image",
",",
"mask",
"=",
"None",
",",
"shrink_factor",
"=",
"4",
",",
"convergence",
"=",
"{",
"'iters'",
":",
"[",
"50",
",",
"50",
",",
"50",
",",
"50",
"]",
",",
"'tol'",
":",
"1e-07",
"}",
",",
"spline_pa... | N4 Bias Field Correction
ANTsR function: `n4BiasFieldCorrection`
Arguments
---------
image : ANTsImage
image to bias correct
mask : ANTsImage
input mask, if one is not passed one will be made
shrink_factor : scalar
Shrink factor for multi-resolution correction, typica... | [
"N4",
"Bias",
"Field",
"Correction"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/bias_correction.py#L49-L126 | train |
ANTsX/ANTsPy | ants/utils/bias_correction.py | abp_n4 | def abp_n4(image, intensity_truncation=(0.025,0.975,256), mask=None, usen3=False):
"""
Truncate outlier intensities and bias correct with the N4 algorithm.
ANTsR function: `abpN4`
Arguments
---------
image : ANTsImage
image to correct and truncate
intensity_truncation : 3-tuple
... | python | def abp_n4(image, intensity_truncation=(0.025,0.975,256), mask=None, usen3=False):
"""
Truncate outlier intensities and bias correct with the N4 algorithm.
ANTsR function: `abpN4`
Arguments
---------
image : ANTsImage
image to correct and truncate
intensity_truncation : 3-tuple
... | [
"def",
"abp_n4",
"(",
"image",
",",
"intensity_truncation",
"=",
"(",
"0.025",
",",
"0.975",
",",
"256",
")",
",",
"mask",
"=",
"None",
",",
"usen3",
"=",
"False",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"intensity_truncation",
",",
"(",
"list",... | Truncate outlier intensities and bias correct with the N4 algorithm.
ANTsR function: `abpN4`
Arguments
---------
image : ANTsImage
image to correct and truncate
intensity_truncation : 3-tuple
quantiles for intensity truncation
mask : ANTsImage (optional)
mask for bias... | [
"Truncate",
"outlier",
"intensities",
"and",
"bias",
"correct",
"with",
"the",
"N4",
"algorithm",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/bias_correction.py#L129-L169 | train |
ANTsX/ANTsPy | ants/registration/metrics.py | image_mutual_information | def image_mutual_information(image1, image2):
"""
Compute mutual information between two ANTsImage types
ANTsR function: `antsImageMutualInformation`
Arguments
---------
image1 : ANTsImage
image 1
image2 : ANTsImage
image 2
Returns
-------
scalar
Exam... | python | def image_mutual_information(image1, image2):
"""
Compute mutual information between two ANTsImage types
ANTsR function: `antsImageMutualInformation`
Arguments
---------
image1 : ANTsImage
image 1
image2 : ANTsImage
image 2
Returns
-------
scalar
Exam... | [
"def",
"image_mutual_information",
"(",
"image1",
",",
"image2",
")",
":",
"if",
"(",
"image1",
".",
"pixeltype",
"!=",
"'float'",
")",
"or",
"(",
"image2",
".",
"pixeltype",
"!=",
"'float'",
")",
":",
"raise",
"ValueError",
"(",
"'Both images must have float ... | Compute mutual information between two ANTsImage types
ANTsR function: `antsImageMutualInformation`
Arguments
---------
image1 : ANTsImage
image 1
image2 : ANTsImage
image 2
Returns
-------
scalar
Example
-------
>>> import ants
>>> fi = ants.imag... | [
"Compute",
"mutual",
"information",
"between",
"two",
"ANTsImage",
"types"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/metrics.py#L10-L42 | train |
ANTsX/ANTsPy | ants/utils/get_mask.py | get_mask | def get_mask(image, low_thresh=None, high_thresh=None, cleanup=2):
"""
Get a binary mask image from the given image after thresholding
ANTsR function: `getMask`
Arguments
---------
image : ANTsImage
image from which mask will be computed. Can be an antsImage of 2, 3 or 4 dimensions.
... | python | def get_mask(image, low_thresh=None, high_thresh=None, cleanup=2):
"""
Get a binary mask image from the given image after thresholding
ANTsR function: `getMask`
Arguments
---------
image : ANTsImage
image from which mask will be computed. Can be an antsImage of 2, 3 or 4 dimensions.
... | [
"def",
"get_mask",
"(",
"image",
",",
"low_thresh",
"=",
"None",
",",
"high_thresh",
"=",
"None",
",",
"cleanup",
"=",
"2",
")",
":",
"cleanup",
"=",
"int",
"(",
"cleanup",
")",
"if",
"isinstance",
"(",
"image",
",",
"iio",
".",
"ANTsImage",
")",
":"... | Get a binary mask image from the given image after thresholding
ANTsR function: `getMask`
Arguments
---------
image : ANTsImage
image from which mask will be computed. Can be an antsImage of 2, 3 or 4 dimensions.
low_thresh : scalar (optional)
An inclusive lower threshold for voxe... | [
"Get",
"a",
"binary",
"mask",
"image",
"from",
"the",
"given",
"image",
"after",
"thresholding"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/get_mask.py#L13-L78 | train |
ANTsX/ANTsPy | ants/utils/label_image_centroids.py | label_image_centroids | def label_image_centroids(image, physical=False, convex=True, verbose=False):
"""
Converts a label image to coordinates summarizing their positions
ANTsR function: `labelImageCentroids`
Arguments
---------
image : ANTsImage
image of integer labels
physical : boolean
wh... | python | def label_image_centroids(image, physical=False, convex=True, verbose=False):
"""
Converts a label image to coordinates summarizing their positions
ANTsR function: `labelImageCentroids`
Arguments
---------
image : ANTsImage
image of integer labels
physical : boolean
wh... | [
"def",
"label_image_centroids",
"(",
"image",
",",
"physical",
"=",
"False",
",",
"convex",
"=",
"True",
",",
"verbose",
"=",
"False",
")",
":",
"d",
"=",
"image",
".",
"shape",
"if",
"len",
"(",
"d",
")",
"!=",
"3",
":",
"raise",
"ValueError",
"(",
... | Converts a label image to coordinates summarizing their positions
ANTsR function: `labelImageCentroids`
Arguments
---------
image : ANTsImage
image of integer labels
physical : boolean
whether you want physical space coordinates or not
convex : boolean
if True... | [
"Converts",
"a",
"label",
"image",
"to",
"coordinates",
"summarizing",
"their",
"positions"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/label_image_centroids.py#L10-L89 | train |
ANTsX/ANTsPy | ants/contrib/sampling/transforms.py | MultiResolutionImage.transform | def transform(self, X, y=None):
"""
Generate a set of multi-resolution ANTsImage types
Arguments
---------
X : ANTsImage
image to transform
y : ANTsImage (optional)
another image to transform
Example
-------
>>> import an... | python | def transform(self, X, y=None):
"""
Generate a set of multi-resolution ANTsImage types
Arguments
---------
X : ANTsImage
image to transform
y : ANTsImage (optional)
another image to transform
Example
-------
>>> import an... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"insuffix",
"=",
"X",
".",
"_libsuffix",
"multires_fn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'multiResolutionAntsImage%s'",
"%",
"(",
"insuffix",
")",
")",
"casted_ptrs",
"=",
... | Generate a set of multi-resolution ANTsImage types
Arguments
---------
X : ANTsImage
image to transform
y : ANTsImage (optional)
another image to transform
Example
-------
>>> import ants
>>> multires = ants.contrib.MultiResoluti... | [
"Generate",
"a",
"set",
"of",
"multi",
"-",
"resolution",
"ANTsImage",
"types"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/transforms.py#L60-L91 | train |
ANTsX/ANTsPy | ants/contrib/sampling/transforms.py | LocallyBlurIntensity.transform | def transform(self, X, y=None):
"""
Locally blur an image by applying a gradient anisotropic diffusion filter.
Arguments
---------
X : ANTsImage
image to transform
y : ANTsImage (optional)
another image to transform.
Example
----... | python | def transform(self, X, y=None):
"""
Locally blur an image by applying a gradient anisotropic diffusion filter.
Arguments
---------
X : ANTsImage
image to transform
y : ANTsImage (optional)
another image to transform.
Example
----... | [
"def",
"transform",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
")",
":",
"insuffix",
"=",
"X",
".",
"_libsuffix",
"cast_fn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'locallyBlurAntsImage%s'",
"%",
"(",
"insuffix",
")",
")",
"casted_ptr",
"=",
"cast_fn"... | Locally blur an image by applying a gradient anisotropic diffusion filter.
Arguments
---------
X : ANTsImage
image to transform
y : ANTsImage (optional)
another image to transform.
Example
-------
>>> import ants
>>> blur = ants.... | [
"Locally",
"blur",
"an",
"image",
"by",
"applying",
"a",
"gradient",
"anisotropic",
"diffusion",
"filter",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/transforms.py#L242-L273 | train |
ANTsX/ANTsPy | ants/utils/get_ants_data.py | get_data | def get_data(name=None):
"""
Get ANTsPy test data filename
ANTsR function: `getANTsRData`
Arguments
---------
name : string
name of test image tag to retrieve
Options:
- 'r16'
- 'r27'
- 'r64'
- 'r85'
- 'ch2'
... | python | def get_data(name=None):
"""
Get ANTsPy test data filename
ANTsR function: `getANTsRData`
Arguments
---------
name : string
name of test image tag to retrieve
Options:
- 'r16'
- 'r27'
- 'r64'
- 'r85'
- 'ch2'
... | [
"def",
"get_data",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"files",
"=",
"[",
"]",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"data_path",
")",
":",
"if",
"(",
"fname",
".",
"endswith",
"(",
"'.nii.gz'",
")",
")... | Get ANTsPy test data filename
ANTsR function: `getANTsRData`
Arguments
---------
name : string
name of test image tag to retrieve
Options:
- 'r16'
- 'r27'
- 'r64'
- 'r85'
- 'ch2'
- 'mni'
- 'surf'
... | [
"Get",
"ANTsPy",
"test",
"data",
"filename"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/get_ants_data.py#L11-L54 | train |
ANTsX/ANTsPy | ants/utils/invariant_image_similarity.py | convolve_image | def convolve_image(image, kernel_image, crop=True):
"""
Convolve one image with another
ANTsR function: `convolveImage`
Arguments
---------
image : ANTsImage
image to convolve
kernel_image : ANTsImage
image acting as kernel
crop : boolean
whether to automatica... | python | def convolve_image(image, kernel_image, crop=True):
"""
Convolve one image with another
ANTsR function: `convolveImage`
Arguments
---------
image : ANTsImage
image to convolve
kernel_image : ANTsImage
image acting as kernel
crop : boolean
whether to automatica... | [
"def",
"convolve_image",
"(",
"image",
",",
"kernel_image",
",",
"crop",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"iio",
".",
"ANTsImage",
")",
":",
"raise",
"ValueError",
"(",
"'image must be ANTsImage type'",
")",
"if",
"not",
... | Convolve one image with another
ANTsR function: `convolveImage`
Arguments
---------
image : ANTsImage
image to convolve
kernel_image : ANTsImage
image acting as kernel
crop : boolean
whether to automatically crop kernel_image
Returns
-------
ANTsImage
... | [
"Convolve",
"one",
"image",
"with",
"another"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/invariant_image_similarity.py#L200-L255 | train |
ANTsX/ANTsPy | ants/utils/ndimage_to_list.py | ndimage_to_list | def ndimage_to_list(image):
"""
Split a n dimensional ANTsImage into a list
of n-1 dimensional ANTsImages
Arguments
---------
image : ANTsImage
n-dimensional image to split
Returns
-------
list of ANTsImage types
Example
-------
>>> import ants
>>> image = ... | python | def ndimage_to_list(image):
"""
Split a n dimensional ANTsImage into a list
of n-1 dimensional ANTsImages
Arguments
---------
image : ANTsImage
n-dimensional image to split
Returns
-------
list of ANTsImage types
Example
-------
>>> import ants
>>> image = ... | [
"def",
"ndimage_to_list",
"(",
"image",
")",
":",
"inpixeltype",
"=",
"image",
".",
"pixeltype",
"dimension",
"=",
"image",
".",
"dimension",
"components",
"=",
"1",
"imageShape",
"=",
"image",
".",
"shape",
"nSections",
"=",
"imageShape",
"[",
"dimension",
... | Split a n dimensional ANTsImage into a list
of n-1 dimensional ANTsImages
Arguments
---------
image : ANTsImage
n-dimensional image to split
Returns
-------
list of ANTsImage types
Example
-------
>>> import ants
>>> image = ants.image_read(ants.get_ants_data('r16'... | [
"Split",
"a",
"n",
"dimensional",
"ANTsImage",
"into",
"a",
"list",
"of",
"n",
"-",
"1",
"dimensional",
"ANTsImages"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/ndimage_to_list.py#L67-L113 | train |
ANTsX/ANTsPy | ants/utils/process_args.py | _int_antsProcessArguments | def _int_antsProcessArguments(args):
"""
Needs to be better validated.
"""
p_args = []
if isinstance(args, dict):
for argname, argval in args.items():
if '-MULTINAME-' in argname:
# have this little hack because python doesnt support
# multiple dic... | python | def _int_antsProcessArguments(args):
"""
Needs to be better validated.
"""
p_args = []
if isinstance(args, dict):
for argname, argval in args.items():
if '-MULTINAME-' in argname:
# have this little hack because python doesnt support
# multiple dic... | [
"def",
"_int_antsProcessArguments",
"(",
"args",
")",
":",
"p_args",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"args",
",",
"dict",
")",
":",
"for",
"argname",
",",
"argval",
"in",
"args",
".",
"items",
"(",
")",
":",
"if",
"'-MULTINAME-'",
"in",
"argnam... | Needs to be better validated. | [
"Needs",
"to",
"be",
"better",
"validated",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/process_args.py#L34-L71 | train |
ANTsX/ANTsPy | ants/learn/decomposition.py | initialize_eigenanatomy | def initialize_eigenanatomy(initmat, mask=None, initlabels=None, nreps=1, smoothing=0):
"""
InitializeEigenanatomy is a helper function to initialize sparseDecom
and sparseDecom2. Can be used to estimate sparseness parameters per
eigenvector. The user then only chooses nvecs and optional
regularizat... | python | def initialize_eigenanatomy(initmat, mask=None, initlabels=None, nreps=1, smoothing=0):
"""
InitializeEigenanatomy is a helper function to initialize sparseDecom
and sparseDecom2. Can be used to estimate sparseness parameters per
eigenvector. The user then only chooses nvecs and optional
regularizat... | [
"def",
"initialize_eigenanatomy",
"(",
"initmat",
",",
"mask",
"=",
"None",
",",
"initlabels",
"=",
"None",
",",
"nreps",
"=",
"1",
",",
"smoothing",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"initmat",
",",
"iio",
".",
"ANTsImage",
")",
":",
"if",
... | InitializeEigenanatomy is a helper function to initialize sparseDecom
and sparseDecom2. Can be used to estimate sparseness parameters per
eigenvector. The user then only chooses nvecs and optional
regularization parameters.
Arguments
---------
initmat : np.ndarray or ANTsImage
input mat... | [
"InitializeEigenanatomy",
"is",
"a",
"helper",
"function",
"to",
"initialize",
"sparseDecom",
"and",
"sparseDecom2",
".",
"Can",
"be",
"used",
"to",
"estimate",
"sparseness",
"parameters",
"per",
"eigenvector",
".",
"The",
"user",
"then",
"only",
"chooses",
"nvecs... | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/learn/decomposition.py#L251-L338 | train |
ANTsX/ANTsPy | ants/learn/decomposition.py | eig_seg | def eig_seg(mask, img_list, apply_segmentation_to_images=False, cthresh=0, smooth=1):
"""
Segment a mask into regions based on the max value in an image list.
At a given voxel the segmentation label will contain the index to the image
that has the largest value. If the 3rd image has the greatest value,
... | python | def eig_seg(mask, img_list, apply_segmentation_to_images=False, cthresh=0, smooth=1):
"""
Segment a mask into regions based on the max value in an image list.
At a given voxel the segmentation label will contain the index to the image
that has the largest value. If the 3rd image has the greatest value,
... | [
"def",
"eig_seg",
"(",
"mask",
",",
"img_list",
",",
"apply_segmentation_to_images",
"=",
"False",
",",
"cthresh",
"=",
"0",
",",
"smooth",
"=",
"1",
")",
":",
"maskvox",
"=",
"mask",
">",
"0",
"maskseg",
"=",
"mask",
".",
"clone",
"(",
")",
"maskseg",... | Segment a mask into regions based on the max value in an image list.
At a given voxel the segmentation label will contain the index to the image
that has the largest value. If the 3rd image has the greatest value,
the segmentation label will be 3 at that voxel.
Arguments
---------
mask : ANTsIm... | [
"Segment",
"a",
"mask",
"into",
"regions",
"based",
"on",
"the",
"max",
"value",
"in",
"an",
"image",
"list",
".",
"At",
"a",
"given",
"voxel",
"the",
"segmentation",
"label",
"will",
"contain",
"the",
"index",
"to",
"the",
"image",
"that",
"has",
"the",... | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/learn/decomposition.py#L342-L409 | train |
ANTsX/ANTsPy | ants/utils/label_stats.py | label_stats | def label_stats(image, label_image):
"""
Get label statistics from image
ANTsR function: `labelStats`
Arguments
---------
image : ANTsImage
Image from which statistics will be calculated
label_image : ANTsImage
Label image
Returns
-------
ndarray ?
... | python | def label_stats(image, label_image):
"""
Get label statistics from image
ANTsR function: `labelStats`
Arguments
---------
image : ANTsImage
Image from which statistics will be calculated
label_image : ANTsImage
Label image
Returns
-------
ndarray ?
... | [
"def",
"label_stats",
"(",
"image",
",",
"label_image",
")",
":",
"image_float",
"=",
"image",
".",
"clone",
"(",
"'float'",
")",
"label_image_int",
"=",
"label_image",
".",
"clone",
"(",
"'unsigned int'",
")",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
... | Get label statistics from image
ANTsR function: `labelStats`
Arguments
---------
image : ANTsImage
Image from which statistics will be calculated
label_image : ANTsImage
Label image
Returns
-------
ndarray ?
Example
-------
>>> import ants
... | [
"Get",
"label",
"statistics",
"from",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/label_stats.py#L8-L41 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.spacing | def spacing(self):
"""
Get image spacing
Returns
-------
tuple
"""
libfn = utils.get_lib_fn('getSpacing%s'%self._libsuffix)
return libfn(self.pointer) | python | def spacing(self):
"""
Get image spacing
Returns
-------
tuple
"""
libfn = utils.get_lib_fn('getSpacing%s'%self._libsuffix)
return libfn(self.pointer) | [
"def",
"spacing",
"(",
"self",
")",
":",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'getSpacing%s'",
"%",
"self",
".",
"_libsuffix",
")",
"return",
"libfn",
"(",
"self",
".",
"pointer",
")"
] | Get image spacing
Returns
-------
tuple | [
"Get",
"image",
"spacing"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L95-L104 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.set_spacing | def set_spacing(self, new_spacing):
"""
Set image spacing
Arguments
---------
new_spacing : tuple or list
updated spacing for the image.
should have one value for each dimension
Returns
-------
None
"""
if not isin... | python | def set_spacing(self, new_spacing):
"""
Set image spacing
Arguments
---------
new_spacing : tuple or list
updated spacing for the image.
should have one value for each dimension
Returns
-------
None
"""
if not isin... | [
"def",
"set_spacing",
"(",
"self",
",",
"new_spacing",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_spacing",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"raise",
"ValueError",
"(",
"'arg must be tuple or list'",
")",
"if",
"len",
"(",
"new_spacing",
... | Set image spacing
Arguments
---------
new_spacing : tuple or list
updated spacing for the image.
should have one value for each dimension
Returns
-------
None | [
"Set",
"image",
"spacing"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L106-L126 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.origin | def origin(self):
"""
Get image origin
Returns
-------
tuple
"""
libfn = utils.get_lib_fn('getOrigin%s'%self._libsuffix)
return libfn(self.pointer) | python | def origin(self):
"""
Get image origin
Returns
-------
tuple
"""
libfn = utils.get_lib_fn('getOrigin%s'%self._libsuffix)
return libfn(self.pointer) | [
"def",
"origin",
"(",
"self",
")",
":",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'getOrigin%s'",
"%",
"self",
".",
"_libsuffix",
")",
"return",
"libfn",
"(",
"self",
".",
"pointer",
")"
] | Get image origin
Returns
-------
tuple | [
"Get",
"image",
"origin"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L129-L138 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.set_origin | def set_origin(self, new_origin):
"""
Set image origin
Arguments
---------
new_origin : tuple or list
updated origin for the image.
should have one value for each dimension
Returns
-------
None
"""
if not isinstanc... | python | def set_origin(self, new_origin):
"""
Set image origin
Arguments
---------
new_origin : tuple or list
updated origin for the image.
should have one value for each dimension
Returns
-------
None
"""
if not isinstanc... | [
"def",
"set_origin",
"(",
"self",
",",
"new_origin",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_origin",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"raise",
"ValueError",
"(",
"'arg must be tuple or list'",
")",
"if",
"len",
"(",
"new_origin",
")",... | Set image origin
Arguments
---------
new_origin : tuple or list
updated origin for the image.
should have one value for each dimension
Returns
-------
None | [
"Set",
"image",
"origin"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L140-L160 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.direction | def direction(self):
"""
Get image direction
Returns
-------
tuple
"""
libfn = utils.get_lib_fn('getDirection%s'%self._libsuffix)
return libfn(self.pointer) | python | def direction(self):
"""
Get image direction
Returns
-------
tuple
"""
libfn = utils.get_lib_fn('getDirection%s'%self._libsuffix)
return libfn(self.pointer) | [
"def",
"direction",
"(",
"self",
")",
":",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'getDirection%s'",
"%",
"self",
".",
"_libsuffix",
")",
"return",
"libfn",
"(",
"self",
".",
"pointer",
")"
] | Get image direction
Returns
-------
tuple | [
"Get",
"image",
"direction"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L163-L172 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.set_direction | def set_direction(self, new_direction):
"""
Set image direction
Arguments
---------
new_direction : numpy.ndarray or tuple or list
updated direction for the image.
should have one value for each dimension
Returns
-------
None
... | python | def set_direction(self, new_direction):
"""
Set image direction
Arguments
---------
new_direction : numpy.ndarray or tuple or list
updated direction for the image.
should have one value for each dimension
Returns
-------
None
... | [
"def",
"set_direction",
"(",
"self",
",",
"new_direction",
")",
":",
"if",
"isinstance",
"(",
"new_direction",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"new_direction",
"=",
"np",
".",
"asarray",
"(",
"new_direction",
")",
"if",
"not",
"isinstance",
... | Set image direction
Arguments
---------
new_direction : numpy.ndarray or tuple or list
updated direction for the image.
should have one value for each dimension
Returns
-------
None | [
"Set",
"image",
"direction"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L174-L197 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.astype | def astype(self, dtype):
"""
Cast & clone an ANTsImage to a given numpy datatype.
Map:
uint8 : unsigned char
uint32 : unsigned int
float32 : float
float64 : double
"""
if dtype not in _supported_dtypes:
raise ValueEr... | python | def astype(self, dtype):
"""
Cast & clone an ANTsImage to a given numpy datatype.
Map:
uint8 : unsigned char
uint32 : unsigned int
float32 : float
float64 : double
"""
if dtype not in _supported_dtypes:
raise ValueEr... | [
"def",
"astype",
"(",
"self",
",",
"dtype",
")",
":",
"if",
"dtype",
"not",
"in",
"_supported_dtypes",
":",
"raise",
"ValueError",
"(",
"'Datatype %s not supported. Supported types are %s'",
"%",
"(",
"dtype",
",",
"_supported_dtypes",
")",
")",
"pixeltype",
"=",
... | Cast & clone an ANTsImage to a given numpy datatype.
Map:
uint8 : unsigned char
uint32 : unsigned int
float32 : float
float64 : double | [
"Cast",
"&",
"clone",
"an",
"ANTsImage",
"to",
"a",
"given",
"numpy",
"datatype",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L302-L316 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.new_image_like | def new_image_like(self, data):
"""
Create a new ANTsImage with the same header information, but with
a new image array.
Arguments
---------
data : ndarray or py::capsule
New array or pointer for the image.
It must have the same shape as the cur... | python | def new_image_like(self, data):
"""
Create a new ANTsImage with the same header information, but with
a new image array.
Arguments
---------
data : ndarray or py::capsule
New array or pointer for the image.
It must have the same shape as the cur... | [
"def",
"new_image_like",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"'data must be a numpy array'",
")",
"if",
"not",
"self",
".",
"has_components",
":",
"if"... | Create a new ANTsImage with the same header information, but with
a new image array.
Arguments
---------
data : ndarray or py::capsule
New array or pointer for the image.
It must have the same shape as the current
image data.
Returns
... | [
"Create",
"a",
"new",
"ANTsImage",
"with",
"the",
"same",
"header",
"information",
"but",
"with",
"a",
"new",
"image",
"array",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L318-L345 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.to_file | def to_file(self, filename):
"""
Write the ANTsImage to file
Args
----
filename : string
filepath to which the image will be written
"""
filename = os.path.expanduser(filename)
libfn = utils.get_lib_fn('toFile%s'%self._libsuffix)
libfn... | python | def to_file(self, filename):
"""
Write the ANTsImage to file
Args
----
filename : string
filepath to which the image will be written
"""
filename = os.path.expanduser(filename)
libfn = utils.get_lib_fn('toFile%s'%self._libsuffix)
libfn... | [
"def",
"to_file",
"(",
"self",
",",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'toFile%s'",
"%",
"self",
".",
"_libsuffix",
")",
"libfn",
"(",
"self... | Write the ANTsImage to file
Args
----
filename : string
filepath to which the image will be written | [
"Write",
"the",
"ANTsImage",
"to",
"file"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L347-L358 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.apply | def apply(self, fn):
"""
Apply an arbitrary function to ANTsImage.
Args
----
fn : python function or lambda
function to apply to ENTIRE image at once
Returns
-------
ANTsImage
image with function applied to it
"""
... | python | def apply(self, fn):
"""
Apply an arbitrary function to ANTsImage.
Args
----
fn : python function or lambda
function to apply to ENTIRE image at once
Returns
-------
ANTsImage
image with function applied to it
"""
... | [
"def",
"apply",
"(",
"self",
",",
"fn",
")",
":",
"this_array",
"=",
"self",
".",
"numpy",
"(",
")",
"new_array",
"=",
"fn",
"(",
"this_array",
")",
"return",
"self",
".",
"new_image_like",
"(",
"new_array",
")"
] | Apply an arbitrary function to ANTsImage.
Args
----
fn : python function or lambda
function to apply to ENTIRE image at once
Returns
-------
ANTsImage
image with function applied to it | [
"Apply",
"an",
"arbitrary",
"function",
"to",
"ANTsImage",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L361-L377 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.sum | def sum(self, axis=None, keepdims=False):
""" Return sum along specified axis """
return self.numpy().sum(axis=axis, keepdims=keepdims) | python | def sum(self, axis=None, keepdims=False):
""" Return sum along specified axis """
return self.numpy().sum(axis=axis, keepdims=keepdims) | [
"def",
"sum",
"(",
"self",
",",
"axis",
"=",
"None",
",",
"keepdims",
"=",
"False",
")",
":",
"return",
"self",
".",
"numpy",
"(",
")",
".",
"sum",
"(",
"axis",
"=",
"axis",
",",
"keepdims",
"=",
"keepdims",
")"
] | Return sum along specified axis | [
"Return",
"sum",
"along",
"specified",
"axis"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L395-L397 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.range | def range(self, axis=None):
""" Return range tuple along specified axis """
return (self.min(axis=axis), self.max(axis=axis)) | python | def range(self, axis=None):
""" Return range tuple along specified axis """
return (self.min(axis=axis), self.max(axis=axis)) | [
"def",
"range",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"min",
"(",
"axis",
"=",
"axis",
")",
",",
"self",
".",
"max",
"(",
"axis",
"=",
"axis",
")",
")"
] | Return range tuple along specified axis | [
"Return",
"range",
"tuple",
"along",
"specified",
"axis"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L404-L406 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.argrange | def argrange(self, axis=None):
""" Return argrange along specified axis """
amin = self.argmin(axis=axis)
amax = self.argmax(axis=axis)
if axis is None:
return (amin, amax)
else:
return np.stack([amin, amax]).T | python | def argrange(self, axis=None):
""" Return argrange along specified axis """
amin = self.argmin(axis=axis)
amax = self.argmax(axis=axis)
if axis is None:
return (amin, amax)
else:
return np.stack([amin, amax]).T | [
"def",
"argrange",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"amin",
"=",
"self",
".",
"argmin",
"(",
"axis",
"=",
"axis",
")",
"amax",
"=",
"self",
".",
"argmax",
"(",
"axis",
"=",
"axis",
")",
"if",
"axis",
"is",
"None",
":",
"return",
... | Return argrange along specified axis | [
"Return",
"argrange",
"along",
"specified",
"axis"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L413-L420 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | ANTsImage.unique | def unique(self, sort=False):
""" Return unique set of values in image """
unique_vals = np.unique(self.numpy())
if sort:
unique_vals = np.sort(unique_vals)
return unique_vals | python | def unique(self, sort=False):
""" Return unique set of values in image """
unique_vals = np.unique(self.numpy())
if sort:
unique_vals = np.sort(unique_vals)
return unique_vals | [
"def",
"unique",
"(",
"self",
",",
"sort",
"=",
"False",
")",
":",
"unique_vals",
"=",
"np",
".",
"unique",
"(",
"self",
".",
"numpy",
"(",
")",
")",
"if",
"sort",
":",
"unique_vals",
"=",
"np",
".",
"sort",
"(",
"unique_vals",
")",
"return",
"uniq... | Return unique set of values in image | [
"Return",
"unique",
"set",
"of",
"values",
"in",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L427-L432 | train |
ANTsX/ANTsPy | ants/core/ants_image.py | LabelImage.uniquekeys | def uniquekeys(self, metakey=None):
"""
Get keys for a given metakey
"""
if metakey is None:
return self._uniquekeys
else:
if metakey not in self.metakeys():
raise ValueError('metakey %s does not exist' % metakey)
return self._u... | python | def uniquekeys(self, metakey=None):
"""
Get keys for a given metakey
"""
if metakey is None:
return self._uniquekeys
else:
if metakey not in self.metakeys():
raise ValueError('metakey %s does not exist' % metakey)
return self._u... | [
"def",
"uniquekeys",
"(",
"self",
",",
"metakey",
"=",
"None",
")",
":",
"if",
"metakey",
"is",
"None",
":",
"return",
"self",
".",
"_uniquekeys",
"else",
":",
"if",
"metakey",
"not",
"in",
"self",
".",
"metakeys",
"(",
")",
":",
"raise",
"ValueError",... | Get keys for a given metakey | [
"Get",
"keys",
"for",
"a",
"given",
"metakey"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image.py#L731-L740 | train |
ANTsX/ANTsPy | ants/utils/label_clusters.py | label_clusters | def label_clusters(image, min_cluster_size=50, min_thresh=1e-6, max_thresh=1, fully_connected=False):
"""
This will give a unique ID to each connected
component 1 through N of size > min_cluster_size
ANTsR function: `labelClusters`
Arguments
---------
image : ANTsImage
input imag... | python | def label_clusters(image, min_cluster_size=50, min_thresh=1e-6, max_thresh=1, fully_connected=False):
"""
This will give a unique ID to each connected
component 1 through N of size > min_cluster_size
ANTsR function: `labelClusters`
Arguments
---------
image : ANTsImage
input imag... | [
"def",
"label_clusters",
"(",
"image",
",",
"min_cluster_size",
"=",
"50",
",",
"min_thresh",
"=",
"1e-6",
",",
"max_thresh",
"=",
"1",
",",
"fully_connected",
"=",
"False",
")",
":",
"dim",
"=",
"image",
".",
"dimension",
"clust",
"=",
"threshold_image",
... | This will give a unique ID to each connected
component 1 through N of size > min_cluster_size
ANTsR function: `labelClusters`
Arguments
---------
image : ANTsImage
input image e.g. a statistical map
min_cluster_size : integer
throw away clusters smaller than this value... | [
"This",
"will",
"give",
"a",
"unique",
"ID",
"to",
"each",
"connected",
"component",
"1",
"through",
"N",
"of",
"size",
">",
"min_cluster_size"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/label_clusters.py#L11-L53 | train |
ANTsX/ANTsPy | ants/registration/make_points_image.py | make_points_image | def make_points_image(pts, mask, radius=5):
"""
Create label image from physical space points
Creates spherical points in the coordinate space of the target image based
on the n-dimensional matrix of points that the user supplies. The image
defines the dimensionality of the data so if the input ima... | python | def make_points_image(pts, mask, radius=5):
"""
Create label image from physical space points
Creates spherical points in the coordinate space of the target image based
on the n-dimensional matrix of points that the user supplies. The image
defines the dimensionality of the data so if the input ima... | [
"def",
"make_points_image",
"(",
"pts",
",",
"mask",
",",
"radius",
"=",
"5",
")",
":",
"powers_lblimg",
"=",
"mask",
"*",
"0",
"npts",
"=",
"len",
"(",
"pts",
")",
"dim",
"=",
"mask",
".",
"dimension",
"if",
"pts",
".",
"shape",
"[",
"1",
"]",
"... | Create label image from physical space points
Creates spherical points in the coordinate space of the target image based
on the n-dimensional matrix of points that the user supplies. The image
defines the dimensionality of the data so if the input image is 3D then
the input points should be 2D or 3D.
... | [
"Create",
"label",
"image",
"from",
"physical",
"space",
"points"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/make_points_image.py#L11-L60 | train |
ANTsX/ANTsPy | ants/utils/weingarten_image_curvature.py | weingarten_image_curvature | def weingarten_image_curvature(image, sigma=1.0, opt='mean'):
"""
Uses the weingarten map to estimate image mean or gaussian curvature
ANTsR function: `weingartenImageCurvature`
Arguments
---------
image : ANTsImage
image from which curvature is calculated
sigma : scalar
... | python | def weingarten_image_curvature(image, sigma=1.0, opt='mean'):
"""
Uses the weingarten map to estimate image mean or gaussian curvature
ANTsR function: `weingartenImageCurvature`
Arguments
---------
image : ANTsImage
image from which curvature is calculated
sigma : scalar
... | [
"def",
"weingarten_image_curvature",
"(",
"image",
",",
"sigma",
"=",
"1.0",
",",
"opt",
"=",
"'mean'",
")",
":",
"if",
"image",
".",
"dimension",
"not",
"in",
"{",
"2",
",",
"3",
"}",
":",
"raise",
"ValueError",
"(",
"'image must be 2D or 3D'",
")",
"if... | Uses the weingarten map to estimate image mean or gaussian curvature
ANTsR function: `weingartenImageCurvature`
Arguments
---------
image : ANTsImage
image from which curvature is calculated
sigma : scalar
smoothing parameter
opt : string
mean by default, ... | [
"Uses",
"the",
"weingarten",
"map",
"to",
"estimate",
"image",
"mean",
"or",
"gaussian",
"curvature"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/weingarten_image_curvature.py#L11-L69 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | from_numpy | def from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False):
"""
Create an ANTsImage object from a numpy array
ANTsR function: `as.antsImage`
Arguments
---------
data : ndarray
image data array
origin : tuple/list
image origin
s... | python | def from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False):
"""
Create an ANTsImage object from a numpy array
ANTsR function: `as.antsImage`
Arguments
---------
data : ndarray
image data array
origin : tuple/list
image origin
s... | [
"def",
"from_numpy",
"(",
"data",
",",
"origin",
"=",
"None",
",",
"spacing",
"=",
"None",
",",
"direction",
"=",
"None",
",",
"has_components",
"=",
"False",
",",
"is_rgb",
"=",
"False",
")",
":",
"data",
"=",
"data",
".",
"astype",
"(",
"'float32'",
... | Create an ANTsImage object from a numpy array
ANTsR function: `as.antsImage`
Arguments
---------
data : ndarray
image data array
origin : tuple/list
image origin
spacing : tuple/list
image spacing
direction : list/ndarray
image direction
has_componen... | [
"Create",
"an",
"ANTsImage",
"object",
"from",
"a",
"numpy",
"array"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L76-L106 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | _from_numpy | def _from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False):
"""
Internal function for creating an ANTsImage
"""
if is_rgb: has_components = True
ndim = data.ndim
if has_components:
ndim -= 1
dtype = data.dtype.name
ptype = _npy_to_itk_map... | python | def _from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False):
"""
Internal function for creating an ANTsImage
"""
if is_rgb: has_components = True
ndim = data.ndim
if has_components:
ndim -= 1
dtype = data.dtype.name
ptype = _npy_to_itk_map... | [
"def",
"_from_numpy",
"(",
"data",
",",
"origin",
"=",
"None",
",",
"spacing",
"=",
"None",
",",
"direction",
"=",
"None",
",",
"has_components",
"=",
"False",
",",
"is_rgb",
"=",
"False",
")",
":",
"if",
"is_rgb",
":",
"has_components",
"=",
"True",
"... | Internal function for creating an ANTsImage | [
"Internal",
"function",
"for",
"creating",
"an",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L109-L152 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | make_image | def make_image(imagesize, voxval=0, spacing=None, origin=None, direction=None, has_components=False, pixeltype='float'):
"""
Make an image with given size and voxel value or given a mask and vector
ANTsR function: `makeImage`
Arguments
---------
shape : tuple/ANTsImage
input image size... | python | def make_image(imagesize, voxval=0, spacing=None, origin=None, direction=None, has_components=False, pixeltype='float'):
"""
Make an image with given size and voxel value or given a mask and vector
ANTsR function: `makeImage`
Arguments
---------
shape : tuple/ANTsImage
input image size... | [
"def",
"make_image",
"(",
"imagesize",
",",
"voxval",
"=",
"0",
",",
"spacing",
"=",
"None",
",",
"origin",
"=",
"None",
",",
"direction",
"=",
"None",
",",
"has_components",
"=",
"False",
",",
"pixeltype",
"=",
"'float'",
")",
":",
"if",
"isinstance",
... | Make an image with given size and voxel value or given a mask and vector
ANTsR function: `makeImage`
Arguments
---------
shape : tuple/ANTsImage
input image size or mask
voxval : scalar
input image value or vector, size of mask
spacing : tuple/list
image spatial resol... | [
"Make",
"an",
"image",
"with",
"given",
"size",
"and",
"voxel",
"value",
"or",
"given",
"a",
"mask",
"and",
"vector"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L155-L205 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | matrix_to_images | def matrix_to_images(data_matrix, mask):
"""
Unmasks rows of a matrix and writes as images
ANTsR function: `matrixToImages`
Arguments
---------
data_matrix : numpy.ndarray
each row corresponds to an image
array should have number of columns equal to non-zero voxels in the mask
... | python | def matrix_to_images(data_matrix, mask):
"""
Unmasks rows of a matrix and writes as images
ANTsR function: `matrixToImages`
Arguments
---------
data_matrix : numpy.ndarray
each row corresponds to an image
array should have number of columns equal to non-zero voxels in the mask
... | [
"def",
"matrix_to_images",
"(",
"data_matrix",
",",
"mask",
")",
":",
"if",
"data_matrix",
".",
"ndim",
">",
"2",
":",
"data_matrix",
"=",
"data_matrix",
".",
"reshape",
"(",
"data_matrix",
".",
"shape",
"[",
"0",
"]",
",",
"-",
"1",
")",
"numimages",
... | Unmasks rows of a matrix and writes as images
ANTsR function: `matrixToImages`
Arguments
---------
data_matrix : numpy.ndarray
each row corresponds to an image
array should have number of columns equal to non-zero voxels in the mask
mask : ANTsImage
image containing a bina... | [
"Unmasks",
"rows",
"of",
"a",
"matrix",
"and",
"writes",
"as",
"images"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L208-L243 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | images_to_matrix | def images_to_matrix(image_list, mask=None, sigma=None, epsilon=0.5 ):
"""
Read images into rows of a matrix, given a mask - much faster for
large datasets as it is based on C++ implementations.
ANTsR function: `imagesToMatrix`
Arguments
---------
image_list : list of ANTsImage types
... | python | def images_to_matrix(image_list, mask=None, sigma=None, epsilon=0.5 ):
"""
Read images into rows of a matrix, given a mask - much faster for
large datasets as it is based on C++ implementations.
ANTsR function: `imagesToMatrix`
Arguments
---------
image_list : list of ANTsImage types
... | [
"def",
"images_to_matrix",
"(",
"image_list",
",",
"mask",
"=",
"None",
",",
"sigma",
"=",
"None",
",",
"epsilon",
"=",
"0.5",
")",
":",
"def",
"listfunc",
"(",
"x",
")",
":",
"if",
"np",
".",
"sum",
"(",
"np",
".",
"array",
"(",
"x",
".",
"shape... | Read images into rows of a matrix, given a mask - much faster for
large datasets as it is based on C++ implementations.
ANTsR function: `imagesToMatrix`
Arguments
---------
image_list : list of ANTsImage types
images to convert to ndarray
mask : ANTsImage (optional)
image cont... | [
"Read",
"images",
"into",
"rows",
"of",
"a",
"matrix",
"given",
"a",
"mask",
"-",
"much",
"faster",
"for",
"large",
"datasets",
"as",
"it",
"is",
"based",
"on",
"C",
"++",
"implementations",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L247-L301 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | timeseries_to_matrix | def timeseries_to_matrix( image, mask=None ):
"""
Convert a timeseries image into a matrix.
ANTsR function: `timeseries2matrix`
Arguments
---------
image : image whose slices we convert to a matrix. E.g. a 3D image of size
x by y by z will convert to a z by x*y sized matrix
mas... | python | def timeseries_to_matrix( image, mask=None ):
"""
Convert a timeseries image into a matrix.
ANTsR function: `timeseries2matrix`
Arguments
---------
image : image whose slices we convert to a matrix. E.g. a 3D image of size
x by y by z will convert to a z by x*y sized matrix
mas... | [
"def",
"timeseries_to_matrix",
"(",
"image",
",",
"mask",
"=",
"None",
")",
":",
"temp",
"=",
"utils",
".",
"ndimage_to_list",
"(",
"image",
")",
"if",
"mask",
"is",
"None",
":",
"mask",
"=",
"temp",
"[",
"0",
"]",
"*",
"0",
"+",
"1",
"return",
"im... | Convert a timeseries image into a matrix.
ANTsR function: `timeseries2matrix`
Arguments
---------
image : image whose slices we convert to a matrix. E.g. a 3D image of size
x by y by z will convert to a z by x*y sized matrix
mask : ANTsImage (optional)
image containing binary m... | [
"Convert",
"a",
"timeseries",
"image",
"into",
"a",
"matrix",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L307-L336 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | matrix_to_timeseries | def matrix_to_timeseries( image, matrix, mask=None ):
"""
converts a matrix to a ND image.
ANTsR function: `matrix2timeseries`
Arguments
---------
image: reference ND image
matrix: matrix to convert to image
mask: mask image defining voxels of interest
Returns
-------
... | python | def matrix_to_timeseries( image, matrix, mask=None ):
"""
converts a matrix to a ND image.
ANTsR function: `matrix2timeseries`
Arguments
---------
image: reference ND image
matrix: matrix to convert to image
mask: mask image defining voxels of interest
Returns
-------
... | [
"def",
"matrix_to_timeseries",
"(",
"image",
",",
"matrix",
",",
"mask",
"=",
"None",
")",
":",
"if",
"mask",
"is",
"None",
":",
"mask",
"=",
"temp",
"[",
"0",
"]",
"*",
"0",
"+",
"1",
"temp",
"=",
"matrix_to_images",
"(",
"matrix",
",",
"mask",
")... | converts a matrix to a ND image.
ANTsR function: `matrix2timeseries`
Arguments
---------
image: reference ND image
matrix: matrix to convert to image
mask: mask image defining voxels of interest
Returns
-------
ANTsImage
Example
-------
>>> import ants
>>> img... | [
"converts",
"a",
"matrix",
"to",
"a",
"ND",
"image",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L339-L374 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | image_header_info | def image_header_info(filename):
"""
Read file info from image header
ANTsR function: `antsImageHeaderInfo`
Arguments
---------
filename : string
name of image file from which info will be read
Returns
-------
dict
"""
if not os.path.exists(filename):
raise... | python | def image_header_info(filename):
"""
Read file info from image header
ANTsR function: `antsImageHeaderInfo`
Arguments
---------
filename : string
name of image file from which info will be read
Returns
-------
dict
"""
if not os.path.exists(filename):
raise... | [
"def",
"image_header_info",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"raise",
"Exception",
"(",
"'filename does not exist'",
")",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'antsImageHeaderInfo'"... | Read file info from image header
ANTsR function: `antsImageHeaderInfo`
Arguments
---------
filename : string
name of image file from which info will be read
Returns
-------
dict | [
"Read",
"file",
"info",
"from",
"image",
"header"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L377-L401 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | image_read | def image_read(filename, dimension=None, pixeltype='float', reorient=False):
"""
Read an ANTsImage from file
ANTsR function: `antsImageRead`
Arguments
---------
filename : string
Name of the file to read the image from.
dimension : int
Number of dimensions of the image rea... | python | def image_read(filename, dimension=None, pixeltype='float', reorient=False):
"""
Read an ANTsImage from file
ANTsR function: `antsImageRead`
Arguments
---------
filename : string
Name of the file to read the image from.
dimension : int
Number of dimensions of the image rea... | [
"def",
"image_read",
"(",
"filename",
",",
"dimension",
"=",
"None",
",",
"pixeltype",
"=",
"'float'",
",",
"reorient",
"=",
"False",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.npy'",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expand... | Read an ANTsImage from file
ANTsR function: `antsImageRead`
Arguments
---------
filename : string
Name of the file to read the image from.
dimension : int
Number of dimensions of the image read. This need not be the same as
the dimensions of the image in the file. Allowed ... | [
"Read",
"an",
"ANTsImage",
"from",
"file"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L425-L515 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | dicom_read | def dicom_read(directory, pixeltype='float'):
"""
Read a set of dicom files in a directory into a single ANTsImage.
The origin of the resulting 3D image will be the origin of the
first dicom image read.
Arguments
---------
directory : string
folder in which all the dicom images exis... | python | def dicom_read(directory, pixeltype='float'):
"""
Read a set of dicom files in a directory into a single ANTsImage.
The origin of the resulting 3D image will be the origin of the
first dicom image read.
Arguments
---------
directory : string
folder in which all the dicom images exis... | [
"def",
"dicom_read",
"(",
"directory",
",",
"pixeltype",
"=",
"'float'",
")",
":",
"slices",
"=",
"[",
"]",
"imgidx",
"=",
"0",
"for",
"imgpath",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"if",
"imgpath",
".",
"endswith",
"(",
"'.dcm'",
... | Read a set of dicom files in a directory into a single ANTsImage.
The origin of the resulting 3D image will be the origin of the
first dicom image read.
Arguments
---------
directory : string
folder in which all the dicom images exist
Returns
-------
ANTsImage
Example
... | [
"Read",
"a",
"set",
"of",
"dicom",
"files",
"in",
"a",
"directory",
"into",
"a",
"single",
"ANTsImage",
".",
"The",
"origin",
"of",
"the",
"resulting",
"3D",
"image",
"will",
"be",
"the",
"origin",
"of",
"the",
"first",
"dicom",
"image",
"read",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L518-L555 | train |
ANTsX/ANTsPy | ants/core/ants_image_io.py | image_write | def image_write(image, filename, ri=False):
"""
Write an ANTsImage to file
ANTsR function: `antsImageWrite`
Arguments
---------
image : ANTsImage
image to save to file
filename : string
name of file to which image will be saved
ri : boolean
if True, return ima... | python | def image_write(image, filename, ri=False):
"""
Write an ANTsImage to file
ANTsR function: `antsImageWrite`
Arguments
---------
image : ANTsImage
image to save to file
filename : string
name of file to which image will be saved
ri : boolean
if True, return ima... | [
"def",
"image_write",
"(",
"image",
",",
"filename",
",",
"ri",
"=",
"False",
")",
":",
"if",
"filename",
".",
"endswith",
"(",
"'.npy'",
")",
":",
"img_array",
"=",
"image",
".",
"numpy",
"(",
")",
"img_header",
"=",
"{",
"'origin'",
":",
"image",
"... | Write an ANTsImage to file
ANTsR function: `antsImageWrite`
Arguments
---------
image : ANTsImage
image to save to file
filename : string
name of file to which image will be saved
ri : boolean
if True, return image. This allows for using this function in a pipeline:
... | [
"Write",
"an",
"ANTsImage",
"to",
"file"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L558-L589 | train |
ANTsX/ANTsPy | ants/segmentation/otsu.py | otsu_segmentation | def otsu_segmentation(image, k, mask=None):
"""
Otsu image segmentation
This is a very fast segmentation algorithm good for quick explortation,
but does not return probability maps.
ANTsR function: `thresholdImage(image, 'Otsu', k)`
Arguments
---------
image : ANTsImage
... | python | def otsu_segmentation(image, k, mask=None):
"""
Otsu image segmentation
This is a very fast segmentation algorithm good for quick explortation,
but does not return probability maps.
ANTsR function: `thresholdImage(image, 'Otsu', k)`
Arguments
---------
image : ANTsImage
... | [
"def",
"otsu_segmentation",
"(",
"image",
",",
"k",
",",
"mask",
"=",
"None",
")",
":",
"if",
"mask",
"is",
"not",
"None",
":",
"image",
"=",
"image",
".",
"mask_image",
"(",
"mask",
")",
"seg",
"=",
"image",
".",
"threshold_image",
"(",
"'Otsu'",
",... | Otsu image segmentation
This is a very fast segmentation algorithm good for quick explortation,
but does not return probability maps.
ANTsR function: `thresholdImage(image, 'Otsu', k)`
Arguments
---------
image : ANTsImage
input image
k : integer
integer number ... | [
"Otsu",
"image",
"segmentation"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/segmentation/otsu.py#L7-L43 | train |
ANTsX/ANTsPy | ants/utils/crop_image.py | crop_image | def crop_image(image, label_image=None, label=1):
"""
Use a label image to crop a smaller ANTsImage from within a larger ANTsImage
ANTsR function: `cropImage`
Arguments
---------
image : ANTsImage
image to crop
label_image : ANTsImage
image with label values. If ... | python | def crop_image(image, label_image=None, label=1):
"""
Use a label image to crop a smaller ANTsImage from within a larger ANTsImage
ANTsR function: `cropImage`
Arguments
---------
image : ANTsImage
image to crop
label_image : ANTsImage
image with label values. If ... | [
"def",
"crop_image",
"(",
"image",
",",
"label_image",
"=",
"None",
",",
"label",
"=",
"1",
")",
":",
"inpixeltype",
"=",
"image",
".",
"pixeltype",
"ndim",
"=",
"image",
".",
"dimension",
"if",
"image",
".",
"pixeltype",
"!=",
"'float'",
":",
"image",
... | Use a label image to crop a smaller ANTsImage from within a larger ANTsImage
ANTsR function: `cropImage`
Arguments
---------
image : ANTsImage
image to crop
label_image : ANTsImage
image with label values. If not supplied, estimated from data.
label : integer ... | [
"Use",
"a",
"label",
"image",
"to",
"crop",
"a",
"smaller",
"ANTsImage",
"from",
"within",
"a",
"larger",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/crop_image.py#L14-L56 | train |
ANTsX/ANTsPy | ants/utils/crop_image.py | decrop_image | def decrop_image(cropped_image, full_image):
"""
The inverse function for `ants.crop_image`
ANTsR function: `decropImage`
Arguments
---------
cropped_image : ANTsImage
cropped image
full_image : ANTsImage
image in which the cropped image will be put back
Returns
... | python | def decrop_image(cropped_image, full_image):
"""
The inverse function for `ants.crop_image`
ANTsR function: `decropImage`
Arguments
---------
cropped_image : ANTsImage
cropped image
full_image : ANTsImage
image in which the cropped image will be put back
Returns
... | [
"def",
"decrop_image",
"(",
"cropped_image",
",",
"full_image",
")",
":",
"inpixeltype",
"=",
"'float'",
"if",
"cropped_image",
".",
"pixeltype",
"!=",
"'float'",
":",
"inpixeltype",
"=",
"cropped_image",
".",
"pixeltype",
"cropped_image",
"=",
"cropped_image",
".... | The inverse function for `ants.crop_image`
ANTsR function: `decropImage`
Arguments
---------
cropped_image : ANTsImage
cropped image
full_image : ANTsImage
image in which the cropped image will be put back
Returns
-------
ANTsImage
Example
-------
>>>... | [
"The",
"inverse",
"function",
"for",
"ants",
".",
"crop_image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/crop_image.py#L108-L149 | train |
ANTsX/ANTsPy | ants/segmentation/kmeans.py | kmeans_segmentation | def kmeans_segmentation(image, k, kmask=None, mrf=0.1):
"""
K-means image segmentation that is a wrapper around `ants.atropos`
ANTsR function: `kmeansSegmentation`
Arguments
---------
image : ANTsImage
input image
k : integer
integer number of classes
kmask : ANTsImag... | python | def kmeans_segmentation(image, k, kmask=None, mrf=0.1):
"""
K-means image segmentation that is a wrapper around `ants.atropos`
ANTsR function: `kmeansSegmentation`
Arguments
---------
image : ANTsImage
input image
k : integer
integer number of classes
kmask : ANTsImag... | [
"def",
"kmeans_segmentation",
"(",
"image",
",",
"k",
",",
"kmask",
"=",
"None",
",",
"mrf",
"=",
"0.1",
")",
":",
"dim",
"=",
"image",
".",
"dimension",
"kmimage",
"=",
"utils",
".",
"iMath",
"(",
"image",
",",
"'Normalize'",
")",
"if",
"kmask",
"is... | K-means image segmentation that is a wrapper around `ants.atropos`
ANTsR function: `kmeansSegmentation`
Arguments
---------
image : ANTsImage
input image
k : integer
integer number of classes
kmask : ANTsImage (optional)
segment inside this mask
mrf : scalar
... | [
"K",
"-",
"means",
"image",
"segmentation",
"that",
"is",
"a",
"wrapper",
"around",
"ants",
".",
"atropos"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/segmentation/kmeans.py#L9-L49 | train |
ANTsX/ANTsPy | ants/registration/reorient_image.py | reorient_image2 | def reorient_image2(image, orientation='RAS'):
"""
Reorient an image.
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = mni.reorient_image2()
"""
if image.dimension != 3:
raise ValueError('image must have 3 dimensions')
inpixelt... | python | def reorient_image2(image, orientation='RAS'):
"""
Reorient an image.
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = mni.reorient_image2()
"""
if image.dimension != 3:
raise ValueError('image must have 3 dimensions')
inpixelt... | [
"def",
"reorient_image2",
"(",
"image",
",",
"orientation",
"=",
"'RAS'",
")",
":",
"if",
"image",
".",
"dimension",
"!=",
"3",
":",
"raise",
"ValueError",
"(",
"'image must have 3 dimensions'",
")",
"inpixeltype",
"=",
"image",
".",
"pixeltype",
"ndim",
"=",
... | Reorient an image.
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = mni.reorient_image2() | [
"Reorient",
"an",
"image",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/reorient_image.py#L56-L82 | train |
ANTsX/ANTsPy | ants/registration/reorient_image.py | reorient_image | def reorient_image(image, axis1, axis2=None, doreflection=False, doscale=0, txfn=None):
"""
Align image along a specified axis
ANTsR function: `reorientImage`
Arguments
---------
image : ANTsImage
image to reorient
axis1 : list/tuple of integers
vector of size dim,... | python | def reorient_image(image, axis1, axis2=None, doreflection=False, doscale=0, txfn=None):
"""
Align image along a specified axis
ANTsR function: `reorientImage`
Arguments
---------
image : ANTsImage
image to reorient
axis1 : list/tuple of integers
vector of size dim,... | [
"def",
"reorient_image",
"(",
"image",
",",
"axis1",
",",
"axis2",
"=",
"None",
",",
"doreflection",
"=",
"False",
",",
"doscale",
"=",
"0",
",",
"txfn",
"=",
"None",
")",
":",
"inpixeltype",
"=",
"image",
".",
"pixeltype",
"if",
"image",
".",
"pixelty... | Align image along a specified axis
ANTsR function: `reorientImage`
Arguments
---------
image : ANTsImage
image to reorient
axis1 : list/tuple of integers
vector of size dim, might need to play w/axis sign
axis2 : list/tuple of integers
vector of size dim f... | [
"Align",
"image",
"along",
"a",
"specified",
"axis"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/reorient_image.py#L85-L168 | train |
ANTsX/ANTsPy | ants/registration/reorient_image.py | get_center_of_mass | def get_center_of_mass(image):
"""
Compute an image center of mass in physical space which is defined
as the mean of the intensity weighted voxel coordinate system.
ANTsR function: `getCenterOfMass`
Arguments
---------
image : ANTsImage
image from which center of mass will be ... | python | def get_center_of_mass(image):
"""
Compute an image center of mass in physical space which is defined
as the mean of the intensity weighted voxel coordinate system.
ANTsR function: `getCenterOfMass`
Arguments
---------
image : ANTsImage
image from which center of mass will be ... | [
"def",
"get_center_of_mass",
"(",
"image",
")",
":",
"if",
"image",
".",
"pixeltype",
"!=",
"'float'",
":",
"image",
"=",
"image",
".",
"clone",
"(",
"'float'",
")",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'centerOfMass%s'",
"%",
"image",
".",
"_... | Compute an image center of mass in physical space which is defined
as the mean of the intensity weighted voxel coordinate system.
ANTsR function: `getCenterOfMass`
Arguments
---------
image : ANTsImage
image from which center of mass will be computed
Returns
-------
scala... | [
"Compute",
"an",
"image",
"center",
"of",
"mass",
"in",
"physical",
"space",
"which",
"is",
"defined",
"as",
"the",
"mean",
"of",
"the",
"intensity",
"weighted",
"voxel",
"coordinate",
"system",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/reorient_image.py#L171-L200 | train |
ANTsX/ANTsPy | ants/utils/convert_nibabel.py | to_nibabel | def to_nibabel(image):
"""
Convert an ANTsImage to a Nibabel image
"""
if image.dimension != 3:
raise ValueError('Only 3D images currently supported')
import nibabel as nib
array_data = image.numpy()
affine = np.hstack([image.direction*np.diag(image.spacing),np.array(image.origin).r... | python | def to_nibabel(image):
"""
Convert an ANTsImage to a Nibabel image
"""
if image.dimension != 3:
raise ValueError('Only 3D images currently supported')
import nibabel as nib
array_data = image.numpy()
affine = np.hstack([image.direction*np.diag(image.spacing),np.array(image.origin).r... | [
"def",
"to_nibabel",
"(",
"image",
")",
":",
"if",
"image",
".",
"dimension",
"!=",
"3",
":",
"raise",
"ValueError",
"(",
"'Only 3D images currently supported'",
")",
"import",
"nibabel",
"as",
"nib",
"array_data",
"=",
"image",
".",
"numpy",
"(",
")",
"affi... | Convert an ANTsImage to a Nibabel image | [
"Convert",
"an",
"ANTsImage",
"to",
"a",
"Nibabel",
"image"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/convert_nibabel.py#L10-L23 | train |
ANTsX/ANTsPy | ants/utils/convert_nibabel.py | from_nibabel | def from_nibabel(nib_image):
"""
Convert a nibabel image to an ANTsImage
"""
tmpfile = mktemp(suffix='.nii.gz')
nib_image.to_filename(tmpfile)
new_img = iio2.image_read(tmpfile)
os.remove(tmpfile)
return new_img | python | def from_nibabel(nib_image):
"""
Convert a nibabel image to an ANTsImage
"""
tmpfile = mktemp(suffix='.nii.gz')
nib_image.to_filename(tmpfile)
new_img = iio2.image_read(tmpfile)
os.remove(tmpfile)
return new_img | [
"def",
"from_nibabel",
"(",
"nib_image",
")",
":",
"tmpfile",
"=",
"mktemp",
"(",
"suffix",
"=",
"'.nii.gz'",
")",
"nib_image",
".",
"to_filename",
"(",
"tmpfile",
")",
"new_img",
"=",
"iio2",
".",
"image_read",
"(",
"tmpfile",
")",
"os",
".",
"remove",
... | Convert a nibabel image to an ANTsImage | [
"Convert",
"a",
"nibabel",
"image",
"to",
"an",
"ANTsImage"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/convert_nibabel.py#L26-L34 | train |
ANTsX/ANTsPy | ants/contrib/sampling/affine3d.py | RandomShear3D.transform | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with
shear parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
... | python | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with
shear parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
... | [
"def",
"transform",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"shear_x",
"=",
"random",
".",
"gauss",
"(",
"self",
".",
"shear_range",
"[",
"0",
"]",
",",
"self",
".",
"shear_range",
"[",
"1",
"]",
")",
"shear_y",
"=",
... | Transform an image using an Affine transform with
shear parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another image to t... | [
"Transform",
"an",
"image",
"using",
"an",
"Affine",
"transform",
"with",
"shear",
"parameters",
"randomly",
"generated",
"from",
"the",
"user",
"-",
"specified",
"range",
".",
"Return",
"the",
"transform",
"if",
"X",
"=",
"None",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/affine3d.py#L304-L339 | train |
ANTsX/ANTsPy | ants/contrib/sampling/affine3d.py | RandomZoom3D.transform | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with
zoom parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
... | python | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with
zoom parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
... | [
"def",
"transform",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"zoom_x",
"=",
"np",
".",
"exp",
"(",
"random",
".",
"gauss",
"(",
"np",
".",
"log",
"(",
"self",
".",
"zoom_range",
"[",
"0",
"]",
")",
",",
"np",
".",
... | Transform an image using an Affine transform with
zoom parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another image to tr... | [
"Transform",
"an",
"image",
"using",
"an",
"Affine",
"transform",
"with",
"zoom",
"parameters",
"randomly",
"generated",
"from",
"the",
"user",
"-",
"specified",
"range",
".",
"Return",
"the",
"transform",
"if",
"X",
"=",
"None",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/affine3d.py#L629-L670 | train |
ANTsX/ANTsPy | ants/contrib/sampling/affine2d.py | Translate2D.transform | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with the given
translation parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
An... | python | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with the given
translation parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
An... | [
"def",
"transform",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"translation_x",
",",
"translation_y",
"=",
"self",
".",
"translation",
"translation_matrix",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"transl... | Transform an image using an Affine transform with the given
translation parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another image to transform
Returns
-------... | [
"Transform",
"an",
"image",
"using",
"an",
"Affine",
"transform",
"with",
"the",
"given",
"translation",
"parameters",
".",
"Return",
"the",
"transform",
"if",
"X",
"=",
"None",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/affine2d.py#L62-L101 | train |
ANTsX/ANTsPy | ants/contrib/sampling/affine2d.py | RandomTranslate2D.transform | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with
translation parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
... | python | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with
translation parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
... | [
"def",
"transform",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"translation_x",
"=",
"random",
".",
"gauss",
"(",
"self",
".",
"translation_range",
"[",
"0",
"]",
",",
"self",
".",
"translation_range",
"[",
"1",
"]",
")",
... | Transform an image using an Affine transform with
translation parameters randomly generated from the user-specified
range. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another ima... | [
"Transform",
"an",
"image",
"using",
"an",
"Affine",
"transform",
"with",
"translation",
"parameters",
"randomly",
"generated",
"from",
"the",
"user",
"-",
"specified",
"range",
".",
"Return",
"the",
"transform",
"if",
"X",
"=",
"None",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/affine2d.py#L141-L175 | train |
ANTsX/ANTsPy | ants/contrib/sampling/affine2d.py | Shear2D.transform | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with the given
shear parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another... | python | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with the given
shear parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another... | [
"def",
"transform",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"shear",
"=",
"[",
"math",
".",
"pi",
"/",
"180",
"*",
"s",
"for",
"s",
"in",
"self",
".",
"shear",
"]",
"shear_x",
",",
"shear_y",
"=",
"shear",
"shear_ma... | Transform an image using an Affine transform with the given
shear parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another image to transform
Returns
-------
... | [
"Transform",
"an",
"image",
"using",
"an",
"Affine",
"transform",
"with",
"the",
"given",
"shear",
"parameters",
".",
"Return",
"the",
"transform",
"if",
"X",
"=",
"None",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/affine2d.py#L217-L259 | train |
ANTsX/ANTsPy | ants/contrib/sampling/affine2d.py | Zoom2D.transform | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with the given
zoom parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another ... | python | def transform(self, X=None, y=None):
"""
Transform an image using an Affine transform with the given
zoom parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another ... | [
"def",
"transform",
"(",
"self",
",",
"X",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"zoom_x",
",",
"zoom_y",
"=",
"self",
".",
"zoom",
"self",
".",
"params",
"=",
"(",
"zoom_x",
",",
"zoom_y",
")",
"zoom_matrix",
"=",
"np",
".",
"array",
"("... | Transform an image using an Affine transform with the given
zoom parameters. Return the transform if X=None.
Arguments
---------
X : ANTsImage
Image to transform
y : ANTsImage (optional)
Another image to transform
Returns
-------
... | [
"Transform",
"an",
"image",
"using",
"an",
"Affine",
"transform",
"with",
"the",
"given",
"zoom",
"parameters",
".",
"Return",
"the",
"transform",
"if",
"X",
"=",
"None",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/affine2d.py#L526-L560 | train |
ANTsX/ANTsPy | ants/segmentation/kelly_kapowski.py | kelly_kapowski | def kelly_kapowski(s, g, w, its=50, r=0.025, m=1.5, **kwargs):
"""
Compute cortical thickness using the DiReCT algorithm.
Diffeomorphic registration-based cortical thickness based on probabilistic
segmentation of an image. This is an optimization algorithm.
Arguments
---------
s : AN... | python | def kelly_kapowski(s, g, w, its=50, r=0.025, m=1.5, **kwargs):
"""
Compute cortical thickness using the DiReCT algorithm.
Diffeomorphic registration-based cortical thickness based on probabilistic
segmentation of an image. This is an optimization algorithm.
Arguments
---------
s : AN... | [
"def",
"kelly_kapowski",
"(",
"s",
",",
"g",
",",
"w",
",",
"its",
"=",
"50",
",",
"r",
"=",
"0.025",
",",
"m",
"=",
"1.5",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"iio",
".",
"ANTsImage",
")",
":",
"s",
"=",
"s",
... | Compute cortical thickness using the DiReCT algorithm.
Diffeomorphic registration-based cortical thickness based on probabilistic
segmentation of an image. This is an optimization algorithm.
Arguments
---------
s : ANTsimage
segmentation image
g : ANTsImage
gray matt... | [
"Compute",
"cortical",
"thickness",
"using",
"the",
"DiReCT",
"algorithm",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/segmentation/kelly_kapowski.py#L11-L77 | train |
ANTsX/ANTsPy | ants/core/ants_transform_io.py | new_ants_transform | def new_ants_transform(precision='float', dimension=3, transform_type='AffineTransform', parameters=None):
"""
Create a new ANTsTransform
ANTsR function: None
Example
-------
>>> import ants
>>> tx = ants.new_ants_transform()
"""
libfn = utils.get_lib_fn('newAntsTransform%s%i' % (u... | python | def new_ants_transform(precision='float', dimension=3, transform_type='AffineTransform', parameters=None):
"""
Create a new ANTsTransform
ANTsR function: None
Example
-------
>>> import ants
>>> tx = ants.new_ants_transform()
"""
libfn = utils.get_lib_fn('newAntsTransform%s%i' % (u... | [
"def",
"new_ants_transform",
"(",
"precision",
"=",
"'float'",
",",
"dimension",
"=",
"3",
",",
"transform_type",
"=",
"'AffineTransform'",
",",
"parameters",
"=",
"None",
")",
":",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'newAntsTransform%s%i'",
"%",
... | Create a new ANTsTransform
ANTsR function: None
Example
-------
>>> import ants
>>> tx = ants.new_ants_transform() | [
"Create",
"a",
"new",
"ANTsTransform"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform_io.py#L16-L35 | train |
ANTsX/ANTsPy | ants/core/ants_transform_io.py | create_ants_transform | def create_ants_transform(transform_type='AffineTransform',
precision='float',
dimension=3,
matrix=None,
offset=None,
center=None,
translation=None,
... | python | def create_ants_transform(transform_type='AffineTransform',
precision='float',
dimension=3,
matrix=None,
offset=None,
center=None,
translation=None,
... | [
"def",
"create_ants_transform",
"(",
"transform_type",
"=",
"'AffineTransform'",
",",
"precision",
"=",
"'float'",
",",
"dimension",
"=",
"3",
",",
"matrix",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"center",
"=",
"None",
",",
"translation",
"=",
"None"... | Create and initialize an ANTsTransform
ANTsR function: `createAntsrTransform`
Arguments
---------
transform_type : string
type of transform(s)
precision : string
numerical precision
dimension : integer
spatial dimension of transform
matrix : ndarra... | [
"Create",
"and",
"initialize",
"an",
"ANTsTransform"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform_io.py#L38-L187 | train |
ANTsX/ANTsPy | ants/core/ants_transform_io.py | read_transform | def read_transform(filename, dimension=2, precision='float'):
"""
Read a transform from file
ANTsR function: `readAntsrTransform`
Arguments
---------
filename : string
filename of transform
dimension : integer
spatial dimension of transform
precision : string
... | python | def read_transform(filename, dimension=2, precision='float'):
"""
Read a transform from file
ANTsR function: `readAntsrTransform`
Arguments
---------
filename : string
filename of transform
dimension : integer
spatial dimension of transform
precision : string
... | [
"def",
"read_transform",
"(",
"filename",
",",
"dimension",
"=",
"2",
",",
"precision",
"=",
"'float'",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename... | Read a transform from file
ANTsR function: `readAntsrTransform`
Arguments
---------
filename : string
filename of transform
dimension : integer
spatial dimension of transform
precision : string
numerical precision of transform
Returns
-------
ANTsTran... | [
"Read",
"a",
"transform",
"from",
"file"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform_io.py#L223-L266 | train |
ANTsX/ANTsPy | ants/core/ants_transform_io.py | write_transform | def write_transform(transform, filename):
"""
Write ANTsTransform to file
ANTsR function: `writeAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to save
filename : string
filename of transform (file extension is ".mat" for affine transforms)
... | python | def write_transform(transform, filename):
"""
Write ANTsTransform to file
ANTsR function: `writeAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to save
filename : string
filename of transform (file extension is ".mat" for affine transforms)
... | [
"def",
"write_transform",
"(",
"transform",
",",
"filename",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
"libfn",
"=",
"utils",
".",
"get_lib_fn",
"(",
"'writeTransform%s'",
"%",
"(",
"transform",
".",
"_libsuffix",... | Write ANTsTransform to file
ANTsR function: `writeAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to save
filename : string
filename of transform (file extension is ".mat" for affine transforms)
Returns
-------
N/A
Example
-------
... | [
"Write",
"ANTsTransform",
"to",
"file"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_transform_io.py#L269-L297 | train |
ANTsX/ANTsPy | ants/registration/reflect_image.py | reflect_image | def reflect_image(image, axis=None, tx=None, metric='mattes'):
"""
Reflect an image along an axis
ANTsR function: `reflectImage`
Arguments
---------
image : ANTsImage
image to reflect
axis : integer (optional)
which dimension to reflect across, numbered from 0 to image... | python | def reflect_image(image, axis=None, tx=None, metric='mattes'):
"""
Reflect an image along an axis
ANTsR function: `reflectImage`
Arguments
---------
image : ANTsImage
image to reflect
axis : integer (optional)
which dimension to reflect across, numbered from 0 to image... | [
"def",
"reflect_image",
"(",
"image",
",",
"axis",
"=",
"None",
",",
"tx",
"=",
"None",
",",
"metric",
"=",
"'mattes'",
")",
":",
"if",
"axis",
"is",
"None",
":",
"axis",
"=",
"image",
".",
"dimension",
"-",
"1",
"if",
"(",
"axis",
">",
"image",
... | Reflect an image along an axis
ANTsR function: `reflectImage`
Arguments
---------
image : ANTsImage
image to reflect
axis : integer (optional)
which dimension to reflect across, numbered from 0 to imageDimension-1
tx : string (optional)
transformation type to ... | [
"Reflect",
"an",
"image",
"along",
"an",
"axis"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/registration/reflect_image.py#L12-L61 | train |
ANTsX/ANTsPy | ants/contrib/bids/cohort.py | BIDSCohort.create_sampler | def create_sampler(self, inputs, targets, input_reader=None, target_reader=None,
input_transform=None, target_transform=None, co_transform=None,
input_return_processor=None, target_return_processor=None, co_return_processor=None):
"""
Create a BIDSSampler that can be used to generate in... | python | def create_sampler(self, inputs, targets, input_reader=None, target_reader=None,
input_transform=None, target_transform=None, co_transform=None,
input_return_processor=None, target_return_processor=None, co_return_processor=None):
"""
Create a BIDSSampler that can be used to generate in... | [
"def",
"create_sampler",
"(",
"self",
",",
"inputs",
",",
"targets",
",",
"input_reader",
"=",
"None",
",",
"target_reader",
"=",
"None",
",",
"input_transform",
"=",
"None",
",",
"target_transform",
"=",
"None",
",",
"co_transform",
"=",
"None",
",",
"input... | Create a BIDSSampler that can be used to generate infinite augmented samples | [
"Create",
"a",
"BIDSSampler",
"that",
"can",
"be",
"used",
"to",
"generate",
"infinite",
"augmented",
"samples"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/bids/cohort.py#L88-L94 | train |
ANTsX/ANTsPy | ants/utils/slice_image.py | slice_image | def slice_image(image, axis=None, idx=None):
"""
Slice an image.
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = ants.slice_image(mni, axis=1, idx=100)
"""
if image.dimension < 3:
raise ValueError('image must have at least 3 dimensi... | python | def slice_image(image, axis=None, idx=None):
"""
Slice an image.
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = ants.slice_image(mni, axis=1, idx=100)
"""
if image.dimension < 3:
raise ValueError('image must have at least 3 dimensi... | [
"def",
"slice_image",
"(",
"image",
",",
"axis",
"=",
"None",
",",
"idx",
"=",
"None",
")",
":",
"if",
"image",
".",
"dimension",
"<",
"3",
":",
"raise",
"ValueError",
"(",
"'image must have at least 3 dimensions'",
")",
"inpixeltype",
"=",
"image",
".",
"... | Slice an image.
Example
-------
>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = ants.slice_image(mni, axis=1, idx=100) | [
"Slice",
"an",
"image",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/slice_image.py#L10-L32 | train |
ANTsX/ANTsPy | ants/utils/pad_image.py | pad_image | def pad_image(image, shape=None, pad_width=None, value=0.0, return_padvals=False):
"""
Pad an image to have the given shape or to be isotropic.
Arguments
---------
image : ANTsImage
image to pad
shape : tuple
- if shape is given, the image will be padded in each dimension
... | python | def pad_image(image, shape=None, pad_width=None, value=0.0, return_padvals=False):
"""
Pad an image to have the given shape or to be isotropic.
Arguments
---------
image : ANTsImage
image to pad
shape : tuple
- if shape is given, the image will be padded in each dimension
... | [
"def",
"pad_image",
"(",
"image",
",",
"shape",
"=",
"None",
",",
"pad_width",
"=",
"None",
",",
"value",
"=",
"0.0",
",",
"return_padvals",
"=",
"False",
")",
":",
"inpixeltype",
"=",
"image",
".",
"pixeltype",
"ndim",
"=",
"image",
".",
"dimension",
... | Pad an image to have the given shape or to be isotropic.
Arguments
---------
image : ANTsImage
image to pad
shape : tuple
- if shape is given, the image will be padded in each dimension
until it has this shape
- if shape is not given, the image will be padded along ea... | [
"Pad",
"an",
"image",
"to",
"have",
"the",
"given",
"shape",
"or",
"to",
"be",
"isotropic",
"."
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/pad_image.py#L10-L75 | train |
ANTsX/ANTsPy | ants/core/ants_metric.py | ANTsImageToImageMetric.set_fixed_image | def set_fixed_image(self, image):
"""
Set Fixed ANTsImage for metric
"""
if not isinstance(image, iio.ANTsImage):
raise ValueError('image must be ANTsImage type')
if image.dimension != self.dimension:
raise ValueError('image dim (%i) does not match metric... | python | def set_fixed_image(self, image):
"""
Set Fixed ANTsImage for metric
"""
if not isinstance(image, iio.ANTsImage):
raise ValueError('image must be ANTsImage type')
if image.dimension != self.dimension:
raise ValueError('image dim (%i) does not match metric... | [
"def",
"set_fixed_image",
"(",
"self",
",",
"image",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"iio",
".",
"ANTsImage",
")",
":",
"raise",
"ValueError",
"(",
"'image must be ANTsImage type'",
")",
"if",
"image",
".",
"dimension",
"!=",
"self",
... | Set Fixed ANTsImage for metric | [
"Set",
"Fixed",
"ANTsImage",
"for",
"metric"
] | 638020af2cdfc5ff4bdb9809ffe67aa505727a3b | https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_metric.py#L48-L59 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.