text stringlengths 81 112k |
|---|
Cleans the DocBlock from leading and trailing white space and comment tokens.
def __clean_doc_block(self):
"""
Cleans the DocBlock from leading and trailing white space and comment tokens.
"""
# Return immediately if the DockBlock is empty.
if not self._comment:
retu... |
Extracts the description from the DocBlock. The description start at the first line and stops at the first tag
or the end of the DocBlock.
def __extract_description(self):
"""
Extracts the description from the DocBlock. The description start at the first line and stops at the first tag
... |
Extract tags from the DocBlock.
def __extract_tags(self):
"""
Extract tags from the DocBlock.
"""
tags = list()
current = None
for line in self._comment:
parts = re.match(r'^@(\w+)', line)
if parts:
current = (parts.group(1), list(... |
Executes constants command when PyStratumCommand is activated.
def handle(self):
"""
Executes constants command when PyStratumCommand is activated.
"""
self.output = PyStratumStyle(self.input, self.output)
config_file = self.input.get_argument('config_file')
self.run_co... |
:param str config_file: The name of config file.
def run_command(self, config_file):
"""
:param str config_file: The name of config file.
"""
config = configparser.ConfigParser()
config.read(config_file)
rdbms = config.get('database', 'rdbms').lower()
label_reg... |
Factory for creating a Constants objects (i.e. objects for creating constants based on column widths, and auto
increment columns and labels).
:param str rdbms: The target RDBMS (i.e. mysql, mssql or pgsql).
:rtype: pystratum.Constants.Constants
def create_constants(self, rdbms):
"""
... |
Return formatted redis key name.
def _format_key_name(self) -> str:
"""Return formatted redis key name."""
key_name = 'ld:{0}:{1}:features'.format(
self.project_key,
self.environment_key
)
return key_name |
Parse Connection string to extract host and port.
:param uri: full URI for redis connection in the form of host:port
:returns: list of RedisConnection objects
def connection_string_parser(uri: str) -> list:
"""
Parse Connection string to extract host and port.
:param uri: ful... |
Get feature flag record from redis.
:param feature_key: key for feature flag
:return: value of feature flag key in redis.
:raises: KeyError if key is not found.
def get_flag_record(self, feature_key: str) -> str:
"""Get feature flag record from redis.
:param feature_key: key... |
Update redis record with new state.
:param state: state for feature flag.
:param feature_key: key for feature flag.
def update_flag_record(self, state: str, feature_key: str) -> None:
"""Update redis record with new state.
:param state: state for feature flag.
:param feature_k... |
Wrap coro_function into the function return NewTask.
def Asyncme(func, n=None, interval=0, default_callback=None, loop=None):
"""Wrap coro_function into the function return NewTask."""
return coros(n, interval, default_callback, loop)(func) |
Decorator for wrap coro_function into the function return NewTask.
def coros(n=None, interval=0, default_callback=None, loop=None):
"""Decorator for wrap coro_function into the function return NewTask."""
submitter = Loop(
n=n, interval=interval, default_callback=default_callback, loop=loop
).submi... |
Set the callback's result as self._callback_result.
def wrap_callback(function):
"""Set the callback's result as self._callback_result."""
@wraps(function)
def wrapped(task):
task._callback_result = function(task)
return task._callback_result
return wrapped |
Recording the task_end_time and task_cost_time,
and prevent super()._schedule_callbacks to clean self._callbacks.
def _schedule_callbacks(self, clear_cb=False):
"""Recording the task_end_time and task_cost_time,
and prevent super()._schedule_callbacks to clean self._callbacks."""
... |
Blocking until the task finish and return the callback_result.until
def callback_result(self):
"""Blocking until the task finish and return the callback_result.until"""
if self._state == self._PENDING:
self._loop.run_until_complete(self)
if self._callbacks:
result = self... |
Blocking until the task finish and return the self.result()
def x(self):
"""Blocking until the task finish and return the self.result()"""
if self._state == self._PENDING:
self._loop.run_until_complete(self)
return self.result() |
Decorator set the coro_function has sem/interval control.
def _wrap_coro_function_with_sem(self, coro_func):
"""Decorator set the coro_function has sem/interval control."""
sem = self.frequency.sem
interval = self.frequency.interval
@wraps(coro_func)
async def new_coro_func(*ar... |
If `kwargs` needed, try like this: func=lambda: foo(*args, **kwargs)
def run_in_executor(self, executor=None, func=None, *args):
"""If `kwargs` needed, try like this: func=lambda: foo(*args, **kwargs)"""
return self.loop.run_in_executor(executor, func, *args) |
If `kwargs` needed, try like this: func=lambda: foo(*args, **kwargs)
def run_in_thread_pool(self, pool_size=None, func=None, *args):
"""If `kwargs` needed, try like this: func=lambda: foo(*args, **kwargs)"""
executor = Pool(pool_size)
return self.loop.run_in_executor(executor, func, *args) |
If `kwargs` needed, try like this: func=lambda: foo(*args, **kwargs)
def run_in_process_pool(self, pool_size=None, func=None, *args):
"""If `kwargs` needed, try like this: func=lambda: foo(*args, **kwargs)"""
executor = ProcessPool(pool_size)
return self.loop.run_in_executor(executor, func, *ar... |
Be used when loop running in a single non-main thread.
def run_coroutine_threadsafe(self, coro, loop=None, callback=None):
"""Be used when loop running in a single non-main thread."""
if not asyncio.iscoroutine(coro):
raise TypeError("A await in coroutines. object is required")
loop... |
Submit a coro_function(*args, **kwargs) as NewTask to self.loop with loop.frequncy control.
::
from torequests.dummy import Loop
import asyncio
loop = Loop()
async def test(i):
result = await asyncio.sleep(1)
return (loop.frequen... |
Submit a coro as NewTask to self.loop without loop.frequncy control.
::
from torequests.dummy import Loop
import asyncio
loop = Loop()
async def test(i):
result = await asyncio.sleep(1)
return (loop.frequency, i)
cor... |
Decorator to submit a coro-function as NewTask to self.loop with sem control.
Use default_callback frequency of loop.
def submitter(self, f):
"""Decorator to submit a coro-function as NewTask to self.loop with sem control.
Use default_callback frequency of loop."""
f = self._wrap_coro_f... |
Return tasks in loop which its state is pending.
def todo_tasks(self):
"""Return tasks in loop which its state is pending."""
tasks = [task for task in self.all_tasks if task._state == NewTask._PENDING]
return tasks |
Return tasks in loop which its state is not pending.
def done_tasks(self):
"""Return tasks in loop which its state is not pending."""
tasks = [task for task in self.all_tasks if task._state != NewTask._PENDING]
return tasks |
Block, run loop until all tasks completed.
def run(self, tasks=None, timeout=None):
"""Block, run loop until all tasks completed."""
timeout = self._timeout if timeout is None else timeout
if self.async_running or self.loop.is_running():
return self.wait_all_tasks_done(timeout)
... |
Block, only be used while loop running in a single non-main thread.
def wait_all_tasks_done(self, timeout=None, delay=0.5, interval=0.1):
"""Block, only be used while loop running in a single non-main thread."""
timeout = self._timeout if timeout is None else timeout
timeout = timeout or float(... |
Used for await in coroutines.
`await loop.pendings()`
`await loop.pendings(tasks)`
async def pendings(self, tasks=None):
"""Used for await in coroutines.
`await loop.pendings()`
`await loop.pendings(tasks)`
"""
tasks = tasks or self.todo_tasks
await async... |
Ensure frequencies is dict of host-frequencies.
def ensure_frequencies(self, frequencies):
"""Ensure frequencies is dict of host-frequencies."""
if not frequencies:
return {}
if not isinstance(frequencies, dict):
raise ValueError("frequencies should be dict")
fre... |
Set frequency for host with sem and interval.
def set_frequency(self, host, sem=None, interval=None):
"""Set frequency for host with sem and interval."""
# single sem or global sem
sem = sem or self.sem
interval = self.interval if interval is None else interval
frequency = Frequ... |
Should be closed[explicit] while using external session or connector,
instead of close by self.__del__.
def close(self):
"""Should be closed[explicit] while using external session or connector,
instead of close by self.__del__."""
try:
if not self.session.closed:
... |
Openstack exceptions decorator
def openstack_exception(func):
'''
Openstack exceptions decorator
'''
async def wrap(*args, **kwargs):
try:
return await func(*args, **kwargs)
except Exception as e:
logging.error(e)
... |
Initialize and refresh openstack connection
def initialize_openstack(func):
'''
Initialize and refresh openstack connection
'''
async def wrap(self, *args, **kwargs):
if not hasattr(self, 'auth') or not self.auth.is_token_valid():
self.auth = AuthPasswor... |
Initialize static data like images and flavores and set it as object property
async def initialize(self):
'''
Initialize static data like images and flavores and set it as object property
'''
flavors = await self._list_flavors()
images = await self._list_images()
self.... |
Create VM
:arg preset_name: string
:arg image: string image id
:arg flavor: string flavor id
:arg security_groups: list
:arg userdata: string
:arg key_name: string
:arg availability_zone: string
:arg subnets: list
:returns list Vm objects... |
List VMs by preset name
:arg present_name: string
async def list_vms(self, preset_name):
'''
List VMs by preset name
:arg present_name: string
'''
response = await self.nova.servers.list(name=f'^{preset_name}$')
result = []
for server in response['server... |
Terminate VM
:arg vm_id: string
async def terminate_vm(self, vm_id):
'''
Terminate VM
:arg vm_id: string
'''
try:
await self.nova.servers.force_delete(vm_id)
except JSONDecodeError as exc:
logging.info("nova sent 'content-type: applicat... |
Get VM
:arg vm_id: string
:returns vm: object
async def get_vm(self, vm_id):
'''
Get VM
:arg vm_id: string
:returns vm: object
'''
result = await self.nova.servers.get(vm_id)
return self._map_vm_structure(result["server"]) |
Vm unification
:arg vm: object
:returns object
def _map_vm_structure(self, vm):
'''
Vm unification
:arg vm: object
:returns object
'''
ip = self._extract_ips(vm['addresses'])
created = datetime.strptime(vm['created'], '%Y-%m-%dT%H:%M:%SZ')
... |
Map openstack vm statuses to vmshepherd vm statuses
openstack vm statuses: ACTIVE, BUILD, DELETED, ERROR, HARD_REBOOT, MIGRATING, PASSWORD, PAUSED, REBOOT,
REBUILD, RESCUE, RESIZE, REVERT_RESIZE, SHELVED, SHELVED_OFFLOADED, SHUTOFF, SOFT_DELETED, SUSPENDED, UNKNOWN,
VERIFY_RESIZE
:a... |
Extract ip addressess from openstack structure
{
'pl-krk-2-int-301-c2-int-1': [
{
'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:29:f1:bb',
'version': 4,
'addr': '10.185.138.36',
'OS-EXT-IPS:type': 'fixed'
}
]
}
:arg... |
Keep text before first colon and replace the rest with new text.
If there is no colon in the
:param obj:
:param text:
:param tooltip:
:param replace_all: No colon is searched and whole text is replaced
:return:
def _set_label_text(obj, text, tooltip=None, replace_all=False):
"""
Keep t... |
Draw a dialog for directory selection.
def __get_datafile(self, app=False):
"""
Draw a dialog for directory selection.
"""
if self.cache is not None:
cache_loadfiledir = self.cache.get_or_none('loadfiledir')
self.loadfiledir = str(cache_loadfiledir)
if ... |
Draw a dialog for directory selection.
def __get_datadir(self, app=False):
"""
Draw a dialog for directory selection.
"""
# if 'datadir' in self.oseg.cache.data.keys():
# if :
# directory = self.oseg.input_datapath_start
if self.cache is not None:
... |
Function is called in the end of process
:return:
def read_data_from_prepared_datapath(self):
"""
Function is called in the end of process
:return:
"""
reader = datareader.DataReader()
self.datap = reader.Get3DData(self.datapath, dataplus_format=True, gui=True,... |
The "main" of the wrapper generator. Returns 0 on success, 1 if one or more errors occurred.
:param str config_filename: The name of the configuration file.
:rtype: int
def main(self, config_filename):
"""
The "main" of the wrapper generator. Returns 0 on success, 1 if one or more err... |
Generates the wrapper class.
def __generate_wrapper_class(self):
"""
Generates the wrapper class.
"""
routines = self._read_routine_metadata()
self._write_class_header()
if routines:
for routine_name in sorted(routines):
if routines[routine_... |
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.
... |
Returns the metadata of stored routines.
:rtype: dict
def _read_routine_metadata(self):
"""
Returns the metadata of stored routines.
:rtype: dict
"""
metadata = {}
if os.path.isfile(self._metadata_filename):
with open(self._metadata_filename, 'r') a... |
Generate a class header for stored routine wrapper.
def _write_class_header(self):
"""
Generate a class header for stored routine wrapper.
"""
self._write_line('from {0!s} import {1!s}'.format(self._parent_class_namespace, self._parent_class_name))
self._write_line()
sel... |
Writes a line with Python code to the generate code buffer.
:param str text: The line with Python code.
def _write_line(self, text=''):
"""
Writes a line with Python code to the generate code buffer.
:param str text: The line with Python code.
"""
if text:
... |
Concise usage for pool.submit.
Basic Usage Asnyc & threads ::
from torequests.main import Async, threads
import time
def use_submit(i):
time.sleep(i)
result = 'use_submit: %s' % i
print(result)
return result
@threads()
def... |
Return as a generator of tasks order by completed sequence.
def get_results_generator(future_list, timeout=None, sort_by_completed=False):
"""Return as a generator of tasks order by completed sequence."""
try:
# python2 not support yield from
if sort_by_completed:
for future in as_c... |
Run the function after seconds asynchronously.
def run_after_async(seconds, func, *args, **kwargs):
"""Run the function after seconds asynchronously."""
t = Timer(seconds, func, args, kwargs)
t.daemon = True
t.start()
return t |
Decorator for let a normal function return the NewFuture
def async_func(self, function):
"""Decorator for let a normal function return the NewFuture"""
@wraps(function)
def wrapped(*args, **kwargs):
return self.submit(function, *args, **kwargs)
return wrapped |
Get the cpu count.
def _get_cpu_count(self):
"""Get the cpu count."""
try:
from multiprocessing import cpu_count
return cpu_count()
except Exception as e:
Config.main_logger.error("_get_cpu_count failed for %s" % e) |
Submit a function to the pool, `self.submit(function,arg1,arg2,arg3=3)`
def submit(self, func, *args, **kwargs):
"""Submit a function to the pool, `self.submit(function,arg1,arg2,arg3=3)`"""
with self._shutdown_lock:
if self._shutdown:
raise RuntimeError("cannot schedule ne... |
Submit a function to the pool, `self.submit(function,arg1,arg2,arg3=3)`
def submit(self, func, *args, **kwargs):
"""Submit a function to the pool, `self.submit(function,arg1,arg2,arg3=3)`"""
with self._shutdown_lock:
if PY3 and self._broken:
raise BrokenProcessPool(
... |
Record the task_end_time & task_cost_time, set result for self._callback_result.
def _invoke_callbacks(self):
"""Record the task_end_time & task_cost_time, set result for self._callback_result."""
self.task_end_time = time.time()
self.task_cost_time = self.task_end_time - self.task_start_time
... |
Block the main thead until future finish, return the future.callback_result.
def callback_result(self):
"""Block the main thead until future finish, return the future.callback_result."""
if self._state in [PENDING, RUNNING]:
self.x
if self._user_callbacks:
return self._c... |
Block the main thead until future finish, return the future.result().
def x(self):
"""Block the main thead until future finish, return the future.result()."""
with self._condition:
result = None
if not self.done():
self._condition.wait(self._timeout)
... |
Close session, shutdown pool.
def close(self, wait=False):
"""Close session, shutdown pool."""
self.session.close()
self.pool.shutdown(wait=wait) |
Similar to `requests.request`, but return as NewFuture.
def request(self, method, url, callback=None, retry=0, **kwargs):
"""Similar to `requests.request`, but return as NewFuture."""
return self.pool.submit(
self._request,
method=method,
url=url,
retry=r... |
Similar to `requests.get`, but return as NewFuture.
def get(self, url, params=None, callback=None, retry=0, **kwargs):
"""Similar to `requests.get`, but return as NewFuture."""
kwargs.setdefault("allow_redirects", True)
return self.request(
"get", url=url, params=params, callback=ca... |
Similar to `requests.post`, but return as NewFuture.
def post(self, url, data=None, json=None, callback=None, retry=0, **kwargs):
"""Similar to `requests.post`, but return as NewFuture."""
return self.request(
"post",
url=url,
data=data,
json=json,
... |
Similar to `requests.head`, but return as NewFuture.
def head(self, url, callback=None, retry=0, **kwargs):
"""Similar to `requests.head`, but return as NewFuture."""
kwargs.setdefault("allow_redirects", False)
return self.request("head", url=url, callback=callback, retry=retry, **kwargs) |
Similar to `requests.options`, but return as NewFuture.
def options(self, url, callback=None, retry=0, **kwargs):
"""Similar to `requests.options`, but return as NewFuture."""
kwargs.setdefault("allow_redirects", True)
return self.request(
"options", url=url, callback=callback, retr... |
Execute GetInfo action to get basic WAN link information's.
:param int wanInterfaceId: the id of the WAN device
:param float timeout: the timeout to wait for the action to be executed
:return: basic WAN link information's
:rtype: WanLinkInfo
def getLinkInfo(self, wanInterfaceId=1, time... |
Execute GetCommonLinkProperties action to get WAN link properties.
:param int wanInterfaceId: the id of the WAN device
:param float timeout: the timeout to wait for the action to be executed
:return: WAN link properties
:rtype: WanLinkProperties
def getLinkProperties(self, wanInterface... |
Execute GetInfo action to get basic ADSL information's.
:param int wanInterfaceId: the id of the WAN device
:param float timeout: the timeout to wait for the action to be executed
:return: ADSL informations.
:rtype: ADSLInfo
def getADSLInfo(self, wanInterfaceId=1, timeout=1):
"... |
Execute GetEthernetLinkStatus action to get the status of the ethernet link.
:param int wanInterfaceId: the id of the WAN device
:param float timeout: the timeout to wait for the action to be executed
:return: status of the ethernet link
:rtype: str
def getEthernetLinkStatus(self, wanI... |
Execute GetTotalBytesSent&GetTotalBytesReceived actions to get WAN statistics.
:param int wanInterfaceId: the id of the WAN device
:param float timeout: the timeout to wait for the action to be executed
:return: a tuple of two values, total bytes sent and total bytes received
:rtype: li... |
Execute GetInfo action to get WAN connection information's.
:param int wanInterfaceId: the id of the WAN device
:param float timeout: the timeout to wait for the action to be executed
:return: WAN connection information's.
:rtype: ConnectionInfo
def getConnectionInfo(self, wanInterface... |
Set enable status for a WAN interface, be careful you don't cut yourself off.
:param bool status: enable or disable the interface
:param int wanInterfaceId: the id of the WAN interface
:param float timeout: the timeout to wait for the action to be executed
def setEnable(self, status, wanInterf... |
Request the connection to be established
:param int wanInterfaceId: the id of the WAN interface
:param float timeout: the timeout to wait for the action to be executed
def requestConnection(self, wanInterfaceId=1, timeout=1):
"""Request the connection to be established
:param int wanI... |
use configparser to write a config object to filename
def write_config(filename, config, mode="w"):
'''use configparser to write a config object to filename
'''
with open(filename, mode) as filey:
config.write(filey)
return filename |
write a temporary file, in base directory with a particular extension.
Parameters
==========
folder: the base directory to write in.
prefix: the prefix to use
ext: the extension to use.
def generate_temporary_file(folder='/tmp', prefix='helpme', ext='json'):
'''write a te... |
copy a file from a source to its destination.
def copyfile(source, destination, force=True):
'''copy a file from a source to its destination.
'''
if os.path.exists(destination) and force is True:
os.remove(destination)
shutil.copyfile(source, destination)
return destination |
Returns a full inventory
Some additional work required to provide consistent and consumable
output.
Inventory output only contains values, no keys - Add the keys to
the output so that it can be consumed more easily.
def full_inventory(self):
"""
Returns a full inventory
... |
Inventory output will only contain the server name and the session ID
when a key is provided. Provide the same format as with the full
inventory instead for consistency.
def self_inventory(self):
"""
Inventory output will only contain the server name and the session ID
when a ke... |
Filters an inventory to only return servers matching ssid
def _ssid_inventory(self, inventory, ssid):
"""
Filters an inventory to only return servers matching ssid
"""
matching_hosts = {}
for host in inventory:
if inventory[host]['comment'] == ssid:
m... |
Returns a node inventory. If an API key is specified, only the nodes
provisioned by this key will be returned.
:return: { inventory }
def inventory(self, all=False, ssid=None):
"""
Returns a node inventory. If an API key is specified, only the nodes
provisioned by this key wi... |
Requests specified number of nodes with the provided parameters.
:param arch: Server architecture (ex: x86_64)
:param ver: CentOS version (ex: 7)
:param count: Number of servers (ex: 2)
:parma flavor: The flavor of machine to use (multi-arch only)
:param retry_count: Number of t... |
Release the servers for the specified ssid.
The API doesn't provide any kind of output, try to be helpful by
providing the list of servers to be released.
:param ssid: ssid of the server pool
:return: [ requested_hosts ]
def node_done(self, ssid=None):
"""
Release the s... |
Update redis state for a feature flag.
:param project: LaunchDarkly project key.
:param environment: LaunchDarkly environment key.
:param feature: LaunchDarkly feature key.
:param state: State for a feature flag.
def update_redis(project: str, environment: str, feature: str, state: str) \
-> N... |
Execute command against the LaunchDarkly API.
This command is generally not used directly, instead it is called as a
part of running the ``playback()`` function.
:param project: LaunchDarkly project key.
:param environment: LaunchDarkly environment key.
:param feature: LaunchDarkly feature key.
... |
Generate Relay Proxy Configuration.
Generate a ld-relay.conf file to quickly spin up a relay proxy.
Right now this is mostly used for integration testing.
:param project: LaunchDarkly project key
def generate_relay_config(project):
"""
Generate Relay Proxy Configuration.
Generate a ld-relay.... |
Get information about series in dir
def dicomdir_info(dirpath, *args, **kwargs):
""" Get information about series in dir"""
dr = DicomReader(dirpath=dirpath, *args, **kwargs)
info = dr.dicomdirectory.get_stats_of_series_in_dir()
return info |
Check if in dir is one or more dicom file. We use two methods.
First is based on dcm extension detection.
def is_dicom_dir(datapath):
"""
Check if in dir is one or more dicom file. We use two methods.
First is based on dcm extension detection.
"""
# Second tries open files
# with dicom modu... |
Function generates list of files from specific dir
files_in_dir(dirpath, wildcard="*.*", startpath=None)
dirpath: required directory
wilcard: mask for files
startpath: start for relative path
Example
files_in_dir('medical/jatra-kiv','*.dcm', '~/data/')
def files_in_dir(dirpath, wildcard="*",... |
get location of the slice
:param dcmdata: dicom data structure
:param teil: filename. Used when slice location doesnt exist
:return:
def get_slice_location(dcmdata, teil=None):
""" get location of the slice
:param dcmdata: dicom data structure
:param teil: filename. Used when slice location d... |
Add attribute to dict if it exists.
:param dct:
:param obj: object
:param attr: object attribute name
:return: dict
def attr_to_dict(obj, attr, dct):
"""
Add attribute to dict if it exists.
:param dct:
:param obj: object
:param attr: object attribute name
:return: dict
"""... |
Select the venous series from CT with around 200 images
:param dcmreader:
:param counts:
:param bins:
:param qt_app:
:return:
def get_series_number_by_guess_for_liver(dcmreader, counts, bins, qt_app=None):
"""
Select the venous series from CT with around 200 images
:param dcmreader:
... |
Function make 3D data from dicom file slices. There are usualy
more overlays in the data.
def get_overlay(self):
"""
Function make 3D data from dicom file slices. There are usualy
more overlays in the data.
"""
overlay = {}
dcmlist = self.files_in_serie
... |
Function make 3D data from dicom file slices
def get_3Ddata(self, start=0, stop=None, step=1):
"""
Function make 3D data from dicom file slices
"""
data3d = []
dcmlist = self.files_in_serie
# print('stsp ', start, stop, step)
# raw_max = None
# raw_min =... |
Read DICOMDIR, crate if necessary.
:return:
def get_standard_dicomdir_info(self):
"""
Read DICOMDIR, crate if necessary.
:return:
"""
dicomdir_filepath = os.path.join(self.dirpath, self.standard_dicomdir_filename)
if not os.path.exists(dicomdir_filepath):
... |
Return series metadata.
Output condatin information about voxelsize_mm, series_number and modality.
If it is possible, the ImageComment, AcquisitionDate and few other dicom tags are also in output dict.
:param series_number:
:return: metadata dict with voxelsize_mm, SeriesNumber and othe... |
Get metadata.
Voxel size is obtained from PixelSpacing and difference of
SliceLocation of two neighboorhoding slices (first have index ifile).
Files in are used.
def get_metaData(self, dcmlist, series_number):
"""
Get metadata.
Voxel size is obtained from PixelSpacing an... |
Dicom series staticstics, input is dcmdir, not dirpath
Information is generated from dicomdir.pkl and first files of series
def get_stats_of_series_in_dir(self, study_id=None):
""" Dicom series staticstics, input is dcmdir, not dirpath
Information is generated from dicomdir.pkl and first files ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.