text stringlengths 81 112k |
|---|
, python2 will not show flags
def show_all(self, as_string=True):
""", python2 will not show flags"""
result = []
for item in self.container:
pattern = str(item[0])[10:] if PY3 else item[0].pattern
instances = item[2] or []
value = (
'%s "%s"'... |
Call self.log_func(self) and return expect_string.
def x(self):
"""Call self.log_func(self) and return expect_string."""
self._log_after_del = False
passed_string = self.string
if self.log_func:
self.log_func(self)
else:
print_info(
"Timer... |
Return the time cost string as expect.
def tick(self):
"""Return the time cost string as expect."""
string = self.passed
if self.rounding:
string = round(string)
if self.readable:
string = self.readable(string)
return string |
Decorator for Timer.
def watch(*timer_args, **timer_kwargs):
"""Decorator for Timer."""
def wrapper(function):
@wraps(function)
def inner(*args, **kwargs):
args1 = ", ".join(map(repr, args)) if args else ""
kwargs1 = ", ".join(
... |
Default clean the \\n in text.
def default_callback(self, text):
"""Default clean the \\n in text."""
text = text.replace("\r\n", "\n")
text = "%s\n" % text
flush_print(text, sep="", end="")
return text |
Block method to watch the clipboard changing.
def watch(self, limit=None, timeout=None):
"""Block method to watch the clipboard changing."""
start_time = time.time()
count = 0
while not timeout or time.time() - start_time < timeout:
new = self.read()
if new != se... |
Non-block method to watch the clipboard changing.
def watch_async(self, limit=None, timeout=None):
"""Non-block method to watch the clipboard changing."""
return self.watch(limit=limit, timeout=timeout) |
JS-like match object. Use index number to get groups, if not match or no group, will return ''.
Basic Usage::
>>> from torequests.utils import find_one
>>> string = "abcd"
>>> find_one("a.*", string)
<torequests.utils.RegMatch object at 0x0705F1D0>
>... |
create a Github issue, given a title, body, repo, and token.
Parameters
==========
title: the issue title
body: the issue body
repo: the full name of the repo
token: the user's personal Github token
def create_issue(title, body, repo, token):
'''create a Github issue, giv... |
Given a URL, get the webmention endpoint
async def get_target(config, url):
""" Given a URL, get the webmention endpoint """
previous = config.cache.get(
'target', url, schema_version=SCHEMA_VERSION) if config.cache else None
headers = previous.caching if previous else None
request = await u... |
Send a webmention to this target from the specified entry
async def send(self, config, entry):
""" Send a webmention to this target from the specified entry """
if self.endpoint:
LOGGER.debug("%s -> %s", entry.url, self.url)
try:
await self.endpoint.send(config, ... |
get the correct helper depending on the environment variable
HELPME_CLIENT
quiet: if True, suppress most output about the client (e.g. speak)
def get_helper(name=None, quiet=True, **kwargs):
'''
get the correct helper depending on the environment variable
HELPME_CLIENT
quiet: i... |
Mock the BaBLEInterface class with some controllers inside.
def mock_bable(monkeypatch):
""" Mock the BaBLEInterface class with some controllers inside. """
mocked_bable = MockBaBLE()
mocked_bable.set_controllers([
Controller(0, '11:22:33:44:55:66', '#0'),
Controller(1, '22:33:44:55:66:11',... |
Executes the actual Stratum program.
def handle(self):
"""
Executes the actual Stratum program.
"""
self.output = PyStratumStyle(self.input, self.output)
command = self.get_application().find('constants')
ret = command.execute(self.input, self.output)
if ret:
... |
Load a python module from its absolute filesystem path
Borrowed from django-cms
def load_from_file(module_path):
"""
Load a python module from its absolute filesystem path
Borrowed from django-cms
"""
from imp import load_module, PY_SOURCE
imported = None
if module_path:
with... |
Context manager version of os.chdir. When exited, returns to the working
directory prior to entering.
Grabbed from cookiecutter, thanks audreyr!
def work_in(dirname=None):
"""
Context manager version of os.chdir. When exited, returns to the working
directory prior to entering.
Grabbed from co... |
Hackish way to reset the django instance settings and AppConfig
:param settings: django settings module
def _reset_django(settings):
"""
Hackish way to reset the django instance settings and AppConfig
:param settings: django settings module
"""
if settings._wrapped != empty:
clear_url_c... |
Setup the Django settings
:param args: docopt arguments
:param default_settings: default Django settings
:param settings: Django settings module
:param STATIC_ROOT: static root directory
:param MEDIA_ROOT: media root directory
:return:
def _make_settings(args, application, settings, STATIC_ROOT... |
Iterate over args_list, make it unicode if needed and ensure that there
are no duplicates.
Returns list of unicoded arguments in the same order.
def ensure_unicoded_and_unique(args_list, application):
"""
Iterate over args_list, make it unicode if needed and ensure that there
are no duplicates.
... |
shutil.rmtree() but also handle junction points and access errors on Windows.
def rmtree(path):
"""shutil.rmtree() but also handle junction points and access errors on Windows.
"""
if islink(path):
unlink(path)
elif os.path.isdir(path):
for sub in os.listdir(path):
sub = os.... |
os.path.islink() but return True for junction points on Windows.
def islink(path):
"""os.path.islink() but return True for junction points on Windows.
"""
if platform.system() == "Windows":
if sys.version_info[:2] < (3, 5):
try:
# pylint: disable=undefined-variable
... |
os.unlink() but handle junction points on Windows.
def unlink(link):
"""os.unlink() but handle junction points on Windows.
"""
if islink(link) and platform.system() == "Windows" and sys.version_info[:2] < (3, 5):
# deleting junction points was added to os.unlink in 3.5
# https://bugs.python... |
os.symlink() but use a junction point on Windows.
def symlink(target, link):
"""os.symlink() but use a junction point on Windows.
"""
if islink(link):
unlink(link)
if platform.system() == "Windows":
if sys.version_info[:2] < (3, 5):
with open(os.devnull, "w") as nul:
... |
Writes a file in two phase to the filesystem.
First write the data to a temporary file (in the same directory) and than renames the temporary file. If the
file already exists and its content is equal to the data that must be written no action is taken. This has the
following advantages:
... |
Given an entry URL, return the entry
Arguments:
config -- the configuration
url -- the URL of the entry
Returns: 3-tuple of (current, previous, updated)
async def get_entry(config, url):
""" Given an entry URL, return the entry
Arguments:
config -- the configuration
url -- the URL ... |
Check a link's relations against the whitelist or blacklist.
First, this will reject based on blacklist.
Next, if there is a whitelist, there must be at least one rel that matches.
To explicitly allow links without a rel you can add None to the whitelist
(e.g. ['in-reply-to',None])
de... |
Check that a link is not on the same domain as the source URL
def _domain_differs(self, href):
""" Check that a link is not on the same domain as the source URL """
target = utils.get_domain(href)
if not target:
return False
origin = utils.get_domain(self.url)
retur... |
Given an Entry object, return all of the outgoing links.
def get_targets(self, config):
""" Given an Entry object, return all of the outgoing links. """
return {urllib.parse.urljoin(self.url, attrs['href'])
for attrs in self._targets
if self._check_rel(attrs, config.rel... |
Executes loader command.
def handle(self):
"""
Executes loader command.
"""
self.output = PyStratumStyle(self.input, self.output)
config_file = self.argument('config_file')
sources = self.argument('file_names')
status = self.run_command(config_file, sources)
... |
:param str config_file: The name of config file.
:param list sources: The list with source files.
def run_command(self, config_file, sources):
"""
:param str config_file: The name of config file.
:param list sources: The list with source files.
"""
config = configparser.... |
Factory for creating a Routine Loader objects (i.e. objects for loading stored routines into a RDBMS instance
from (pseudo) SQL files.
:param str rdbms: The target RDBMS (i.e. mysql, mssql or pgsql).
:rtype: pystratum.RoutineLoader.RoutineLoader
def create_routine_loader(self, rdbms):
... |
Dummy create_vm func.
async def create_vm(self, *, preset_name, image, flavor, security_groups=None,
userdata=None, key_name=None, availability_zone=None,
subnet=None):
"""
Dummy create_vm func.
"""
info = {
'id': next(self._id... |
Dummy list_vms func
async def list_vms(self, preset_name):
"""Dummy list_vms func"""
return list(vm for vm in self._vms.values() if vm.name == preset_name) |
Dummy terminate_vm func
async def terminate_vm(self, vm_id):
""" Dummy terminate_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
del self._vms[vm_id]
return None |
Dummy get_vm func
async def get_vm(self, vm_id):
""" Dummy get_vm func """
if vm_id not in self._vms:
raise DummyIaasVmNotFound()
return self._vms[vm_id] |
Try if exist path and append number to its end.
For debug you can set as input if file exists or not.
def suggest_filename(file_path, exists=None):
"""
Try if exist path and append number to its end.
For debug you can set as input if file exists or not.
"""
import os.path
import re
if n... |
Read object from file
def obj_from_file(filename='annotation.yaml', filetype='auto'):
''' Read object from file '''
if filetype == 'auto':
_, ext = os.path.splitext(filename)
filetype = ext[1:]
if filetype in ('yaml', 'yml'):
from ruamel.yaml import YAML
yaml = YAML(typ="u... |
Try read zipped or not zipped pickle file
def read_pkl_and_pklz(filename):
"""
Try read zipped or not zipped pickle file
"""
fcontent = None
try:
import gzip
f = gzip.open(filename, 'rb')
fcontent = f.read()
f.close()
except IOError as e:
# if the problem... |
Writes annotation in file.
:param filetype:
auto
yaml
pkl, pickle
pklz, picklezip
:param ndarray_to_list: convert ndarrays in obj to lists
:param squeeze: squeeze ndarray
def obj_to_file(obj, filename, filetype='auto', ndarray_to_list=False, squeeze=True):
'''Writes ann... |
Function resize input data to specific shape.
:param data: input 3d array-like data
:param shape: shape of output data
:param zoom: zoom is used for back compatibility
:mode: default is 'nearest'
def resize_to_shape(data, shape, zoom=None, mode='nearest', order=0):
"""
Function resize input da... |
Function can resize data3d or segmentation to specifed voxelsize_mm
:new_voxelsize_mm: requested voxelsize. List of 3 numbers, also
can be a string 'orig', 'orgi*2' and 'orgi*4'.
:voxelsize_mm: size of voxel
:mode: default is 'nearest'
def resize_to_mm(data3d, voxelsize_mm, new_voxelsize_mm, mode=... |
Check whether range of values can be stored into defined data type.
:param mn: range minimum
:param mx: range maximum
:param dtype:
:return:
def suits_with_dtype(mn, mx, dtype):
"""
Check whether range of values can be stored into defined data type.
:param mn: range minimum
:param mx: r... |
Use more economic integer-like dtype if it is possible.
:param data3d:
:param dtype: if dtype is not used, the automatic is used
:return:
def use_economic_dtype(data3d, slope=1, inter=0, dtype=None):
""" Use more economic integer-like dtype if it is possible.
:param data3d:
:param dtype: if d... |
Prepare SimpleItk Image object and rescale data to unsigned types.
Simple ITK with version higher than 1.0.0 can not write signed int16. This function check
the SimpleITK version and use work around with Rescale Intercept and Rescale Slope
:param data3d:
:return:
def get_sitk_image_from_ndarray(data3d... |
Get scale and intercept from pydicom file object.
:param dcmdata:
:return:
def get_slope_and_intercept_from_pdcm(dcmdata):
"""
Get scale and intercept from pydicom file object.
:param dcmdata:
:return:
"""
if hasattr(dcmdata, "RescaleSlope") and hasattr(dcmdata, "RescaleIntercept"):
... |
Split an integer into evenly distributed list
>>> split_evenly(7, 3)
[3, 2, 2]
>>> split_evenly(12, 3)
[4, 4, 4]
>>> split_evenly(35, 10)
[4, 4, 4, 4, 4, 3, 3, 3, 3, 3]
>>> split_evenly(1, 2)
Traceback (most recent call last):
...
ChunkingError: Number of chunks is greate... |
ensure that variable envar is set to some value,
otherwise exit on error.
Parameters
==========
envar: the environment variable name
value: the setting that shouldn't be None
def check_env(self, envar, value):
'''ensure that variable envar is set... |
the discourse API requires the interactions to be signed, so we
generate a keypair on behalf of the user
def _generate_keys(self):
'''the discourse API requires the interactions to be signed, so we
generate a keypair on behalf of the user
'''
from helpme.defaults import ... |
submit the question to the board. When we get here we should have
(under self.data)
{'record_environment': [('DISPLAY', ':0')],
'user_prompt_board': 'http://127.0.0.1',
'user_prompt_issue': 'I want to know why dinosaurs are so great!',
... |
Retrieve an object which `id_field` matches `id_val`. If it exists in
the cache, it will be fetched from Redis. If not, it will be fetched
via the `fetch` method and cached in Redis (unless the cache flag got
invalidated in the meantime).
def get(self, cls, id_field, id_val):
"""
... |
Verify that the object we retrieved from cache matches the requested
`id_field`/`id_val`.
def verify(self, cls, id_field, id_val, obj_from_cache):
"""
Verify that the object we retrieved from cache matches the requested
`id_field`/`id_val`.
"""
return getattr(obj_from_ca... |
Invalidate the cache for a given Mongo object by deleting the cached
data and the cache flag.
def invalidate(self, cls, id_field, id_val):
"""
Invalidate the cache for a given Mongo object by deleting the cached
data and the cache flag.
"""
cache_key, flag_key = self.get... |
Manage function docstring
async def manage(self):
""" Manage function docstring"""
self._vms = await self.iaas.list_vms(self.name)
vms_stat = Counter([vm.get_state() for vm in self._vms])
missing = self.count - len(self._vms) if len(self._vms) < self.count else 0
logging.info(
... |
Update the state of the NukiLock
:param aggressive: Whether to aggressively poll the Bridge. If set to
True, this will actively query the Lock, thus using more battery.
:type aggressive: bool
def update(self, aggressive=False):
"""
Update the state of the NukiLock
:param... |
Return a tuple containing the item properties.
:param item: a single dict resource
:param fields: tuple of strings with the desired field names
:param mixed_case_fields: tuple of field names to preserve case
:param formatters: dictionary mapping field names to callables
to format the values
def ... |
Logs a method and its arguments when entered.
def log_method(log, level=logging.DEBUG):
"""Logs a method and its arguments when entered."""
def decorator(func):
func_name = func.__name__
@six.wraps(func)
def wrapper(self, *args, **kwargs):
if log.isEnabledFor(level):
... |
Verify required directories exist.
This functions checks the current working directory to ensure that
the required directories exist. If they do not exist, it will create them.
def check_local() -> None:
"""
Verify required directories exist.
This functions checks the current working directory to... |
Create file to replay.
Create file with ``rc`` command that will be called against the
LaunchDarkly API when ``rc playback`` is called from the main CLI.
:param project: LaunchDarkly Project
:param environment: LaunchDarkly Environment
:param feature: LaunchDarkly Feature
:param state: State t... |
Execute all commands.
For every command that is found in replay/toDo, execute each of them
and move the file to the replay/archive directory.
def execute_replay() -> None:
"""
Execute all commands.
For every command that is found in replay/toDo, execute each of them
and move the file to the r... |
Ask the user for a prompt, and only return when one of the requested
options is provided.
Parameters
==========
prompt: the prompt to ask the user
choices: a list of choices that are valid, defaults to [Y/N/y/n]
def choice_prompt(prompt, choices=None, choice=None):
'''Ask the us... |
Ask the user for a text entry that matches a regular expression
Parameters
==========
prompt: the prompt to ask the user
regexp: the regular expression to match. defaults to anything.
def regexp_prompt(prompt, regexp='.', answer=''):
'''Ask the user for a text entry that matches a regu... |
get_install will return the path to where an executable is installed.
def which(software, strip_newline=True):
'''get_install will return the path to where an executable is installed.
'''
if software is None:
software = "singularity"
cmd = ['which', software ]
try:
result = run_comm... |
Try to guess the encoding of a request without going through the slow chardet process
def guess_encoding(request):
""" Try to guess the encoding of a request without going through the slow chardet process"""
ctype = request.headers.get('content-type')
if not ctype:
# we don't have a content-type, s... |
Replace the kwargs with one where the headers include our user-agent
def _make_headers(config, kwargs):
""" Replace the kwargs with one where the headers include our user-agent """
headers = kwargs.get('headers')
headers = headers.copy() if headers is not None else {}
headers['User-Agent'] = config.ar... |
aiohttp wrapper for GET
async def retry_get(config, url, *args, **kwargs):
""" aiohttp wrapper for GET """
return await _retry_do(config.session.get, url, *args,
**_make_headers(config, kwargs)) |
aiohttp wrapper for POST
async def retry_post(config, url, *args, **kwargs):
""" aiohttp wrapper for POST """
return await _retry_do(config.session.post, url, *args,
**_make_headers(config, kwargs)) |
run the entire helper procedure, including:
- start: initialize the helper, collection preferences
- record: record any relevant features for the environment / session
- interact: interact with the user for additional informatoin
- submit: submit the completed reques... |
start the helper flow. We check helper system configurations to
determine components that should be collected for the submission.
This is where the client can also pass on any extra (positional)
arguments in a list from the user.
def start(self, positionals=None):
'''start the ... |
given a name of a configuration key and the provided content, collect
the required metadata from the user.
Parameters
==========
step: the key in the configuration. Can be one of:
user_message_<name>
runtime_arg_<name>
... |
given a key in the configuration, collect the runtime argument if
provided. Otherwise, prompt the user for the value.
Parameters
==========
step: the name of the step, should be 'runtime_arg_<name>'
message: the content of the step, the message to show the user if... |
collect a limited set of environment variables based on the list
under record_envirionment in the configuration file.
def record_environment(self):
'''collect a limited set of environment variables based on the list
under record_envirionment in the configuration file.
'''
... |
record an asciinema from the user session, saving the file to
a temporary file and showing the user so if he/she needs to do it
again, the file can be provided. The flow of events below makes
the following checks:
1. The user confirms it is ok to record
2. The rec... |
a function for the helper to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client.
def speak(self):
'''
a function for the helper to announce him... |
:param str config_filename: The config filename.
:param str regex: The regular expression for columns which we want to use.
:rtype: int
def main(self, config_filename, regex):
"""
:param str config_filename: The config filename.
:param str regex: The regular expression for colu... |
Logs the number of constants generated.
def __log_number_of_constants(self):
"""
Logs the number of constants generated.
"""
n_id = len(self._labels)
n_widths = len(self._constants) - n_id
self._io.writeln('')
self._io.text('Number of constants based on column w... |
Reads parameters from the configuration file.
:param str config_filename: The name of the configuration file.
def _read_configuration_file(self, config_filename):
"""
Reads parameters from the configuration file.
:param str config_filename: The name of the configuration file.
... |
Inserts new and replaces old (if any) constant declaration statements in the class that acts like a namespace
for constants.
def __write_constant_class(self):
"""
Inserts new and replaces old (if any) constant declaration statements in the class that acts like a namespace
for constants.... |
Check Environment Variable to verify that it is set and not empty.
:param envvar: Environment Variable to Check.
:returns: True if Environment Variable is set and not empty.
:raises: KeyError if Environment Variable is not set or is empty.
.. versionadded:: 0.0.12
def _check_env_var(envvar: str) ->... |
Validate State Argument
Checks that either 'on' or 'off' was entered as an argument to the
CLI and make it lower case.
:param state: state to validate.
:returns: True if state is valid.
.. versionchanged:: 0.0.12
This moethod was renamed from validateState to valid_state to conform
... |
Validate that required env vars exist.
:returns: True if required env vars exist.
.. versionadded:: 0.0.12
def valid_env_vars() -> bool:
"""Validate that required env vars exist.
:returns: True if required env vars exist.
.. versionadded:: 0.0.12
"""
for envvar in _REQUIRED_ENV_VARS:
... |
Configure templates and routing
def configure_panel(self):
"""
Configure templates and routing
"""
webroot = os.path.dirname(__file__)
self.template_path = os.path.join(webroot, 'templates')
aiohttp_jinja2.setup(
self, loader=jinja2.FileSystemLoader(self.tem... |
Initialize and start WebServer
async def start(self):
"""
Initialize and start WebServer
"""
logging.info('Starting server, listening on %s.', self.port)
runner = web.AppRunner(self)
await runner.setup()
site = web.TCPSite(runner, '', self.port)
await sit... |
Inject all preset data to Panel and Render a Home Page
async def get(self):
"""
Inject all preset data to Panel and Render a Home Page
"""
shepherd = self.request.app.vmshepherd
data = {'presets': {}, 'config': shepherd.config}
presets = await shepherd.preset_manager.lis... |
Turn dictionary into argument like string.
def serialize(dictionary):
"""
Turn dictionary into argument like string.
"""
data = []
for key, value in dictionary.items():
data.append('{0}="{1}"'.format(key, value))
return ', '.join(data) |
Execute NewHostNumberOfEntries action to get the amount of known hosts.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: the amount of known hosts.
:rtype: int
.. seealso:: :meth:`~simpletr64... |
Execute GetGenericHostEntry action to get detailed information's of a connected host.
:param index: the index of the host
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: the detailed information's of... |
Get host details for a host specified by its MAC address.
:param str macAddress: MAC address in the form ``38:C9:86:26:7E:38``; be aware that the MAC address might
be case sensitive, depending on the router
:param int lanInterfaceId: the id of the LAN interface
:param float timeout:... |
Execute GetInfo action to get information's about the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: information's about the Ethernet interface.
:rtype: EthernetInfo
def getEthe... |
Execute GetStatistics action to get statistics of the Ethernet interface.
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
:return: statisticss of the Ethernet interface.
:rtype: EthernetStatistic
def getEthe... |
Set enable status for a LAN interface, be careful you don't cut yourself off.
:param bool status: enable or disable the interface
:param int lanInterfaceId: the id of the LAN interface
:param float timeout: the timeout to wait for the action to be executed
def setEnable(self, status, lanInterf... |
submit a uservoice ticket. When we get here we should have:
{'user_prompt_issue': 'I want to do the thing.',
'record_asciinema': '/tmp/helpme.93o__nt5.json',
'record_environment': ((1,1),(2,2)...(N,N))}
Required Client Variables
self.api_key
... |
authenticate with uservoice by creating a client.
def authenticate(self):
'''authenticate with uservoice by creating a client.'''
if not hasattr(self, 'client'):
self.client = uservoice.Client(self.subdomain,
self.api_key,
... |
post_ticket will post a ticket to the uservoice helpdesk
Parameters
==========
title: the title (subject) of the issue
body: the message to send
def post_ticket(self, title, body):
'''post_ticket will post a ticket to the uservoice helpdesk
Parameters
... |
Simple read function. Internally calls DataReader.Get3DData()
def read(datapath, qt_app=None, dataplus_format=True, gui=False, start=0, stop=None, step=1, convert_to_gray=True,
series_number=None, dicom_expected=None, **kwargs):
"""Simple read function. Internally calls DataReader.Get3DData()"""
dr = ... |
Function which returns metadata dict.
:param image: image to get spacing from
:param datapath: path to data
:return: {'series_number': '', 'datadir': '', 'voxelsize_mm': ''}
def _metadata(image, datapath):
"""Function which returns metadata dict.
:param image: image to get spacing from
:param... |
Returns 3D data and its metadata.
# NOTE(:param qt_app:) If it is set to None (as default) all dialogs for series selection are performed in
terminal. If qt_app is set to QtGui.QApplication() dialogs are in Qt.
:param datapath: directory with input data
:param qt_app: Dialog destinatio... |
This function is actually the ONE, which reads 3D data from file
:param datapath: path to file
:return: tuple (data3d, metadata)
def __ReadFromDirectory(self, datapath, dicom_expected=None):
"""This function is actually the ONE, which reads 3D data from file
:param datapath: path to f... |
Reads file and returns containing 3D data and its metadata.
Supported formats: pklz, pkl, hdf5, idx, dcm, Dcm, dicom, bz2 and "raw files"
:param datapath: path to file to read
:return: tuple (data3d, metadata)
def __ReadFromFile(self, datapath):
"""Reads file and returns containing 3D ... |
Reads file using SimpleITK. Returns array of pixels (image located in datapath) and its metadata.
:param datapath: path to file (img or dicom)
:return: tuple (data3d, metadata), where data3d is array of pixels
def _read_with_sitk(datapath):
"""Reads file using SimpleITK. Returns array of pixel... |
There is a bug in simple ITK for Z axis in 3D images. This is a fix.
:param path: path to dicom file to read
:param metadata: metadata to correct
:return: corrected metadata
def _fix_sitk_bug(path, metadata):
"""There is a bug in simple ITK for Z axis in 3D images. This is a fix.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.