repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
ajbosco/dag-factory | dagfactory/utils.py | merge_configs | def merge_configs(config: Dict[str, Any], default_config: Dict[str, Any]) -> Dict[str, Any]:
"""
Merges a `default` config with DAG config. Used to set default values
for a group of DAGs.
:param config: config to merge in default values
:type config: Dict[str, Any]
:param default_config: confi... | python | def merge_configs(config: Dict[str, Any], default_config: Dict[str, Any]) -> Dict[str, Any]:
"""
Merges a `default` config with DAG config. Used to set default values
for a group of DAGs.
:param config: config to merge in default values
:type config: Dict[str, Any]
:param default_config: confi... | [
"def",
"merge_configs",
"(",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"default_config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"for",
"key",
"in",
"default_config",
":",
"if",
... | Merges a `default` config with DAG config. Used to set default values
for a group of DAGs.
:param config: config to merge in default values
:type config: Dict[str, Any]
:param default_config: config to merge default values from
:type default_config: Dict[str, Any]
:returns: dict with merged co... | [
"Merges",
"a",
"default",
"config",
"with",
"DAG",
"config",
".",
"Used",
"to",
"set",
"default",
"values",
"for",
"a",
"group",
"of",
"DAGs",
"."
] | train | https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/utils.py#L68-L86 |
ajbosco/dag-factory | dagfactory/dagfactory.py | DagFactory._load_config | def _load_config(config_filepath: str) -> Dict[str, Any]:
"""
Loads YAML config file to dictionary
:returns: dict from YAML config file
"""
try:
config: Dict[str, Any] = yaml.load(stream=open(config_filepath, "r"))
except Exception as e:
raise Exc... | python | def _load_config(config_filepath: str) -> Dict[str, Any]:
"""
Loads YAML config file to dictionary
:returns: dict from YAML config file
"""
try:
config: Dict[str, Any] = yaml.load(stream=open(config_filepath, "r"))
except Exception as e:
raise Exc... | [
"def",
"_load_config",
"(",
"config_filepath",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"try",
":",
"config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"yaml",
".",
"load",
"(",
"stream",
"=",
"open",
"(",
"config_filep... | Loads YAML config file to dictionary
:returns: dict from YAML config file | [
"Loads",
"YAML",
"config",
"file",
"to",
"dictionary"
] | train | https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/dagfactory.py#L30-L40 |
ajbosco/dag-factory | dagfactory/dagfactory.py | DagFactory.get_dag_configs | def get_dag_configs(self) -> Dict[str, Dict[str, Any]]:
"""
Returns configuration for each the DAG in factory
:returns: dict with configuration for dags
"""
return {dag: self.config[dag] for dag in self.config.keys() if dag != "default"} | python | def get_dag_configs(self) -> Dict[str, Dict[str, Any]]:
"""
Returns configuration for each the DAG in factory
:returns: dict with configuration for dags
"""
return {dag: self.config[dag] for dag in self.config.keys() if dag != "default"} | [
"def",
"get_dag_configs",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"{",
"dag",
":",
"self",
".",
"config",
"[",
"dag",
"]",
"for",
"dag",
"in",
"self",
".",
"config",
".",
"keys",
... | Returns configuration for each the DAG in factory
:returns: dict with configuration for dags | [
"Returns",
"configuration",
"for",
"each",
"the",
"DAG",
"in",
"factory"
] | train | https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/dagfactory.py#L42-L48 |
ajbosco/dag-factory | dagfactory/dagfactory.py | DagFactory.generate_dags | def generate_dags(self, globals: Dict[str, Any]) -> None:
"""
Generates DAGs from YAML config
:param globals: The globals() from the file used to generate DAGs. The dag_id
must be passed into globals() for Airflow to import
"""
dag_configs: Dict[str, Dict[str, Any]] ... | python | def generate_dags(self, globals: Dict[str, Any]) -> None:
"""
Generates DAGs from YAML config
:param globals: The globals() from the file used to generate DAGs. The dag_id
must be passed into globals() for Airflow to import
"""
dag_configs: Dict[str, Dict[str, Any]] ... | [
"def",
"generate_dags",
"(",
"self",
",",
"globals",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"dag_configs",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"self",
".",
"get_dag_configs",
"(",
... | Generates DAGs from YAML config
:param globals: The globals() from the file used to generate DAGs. The dag_id
must be passed into globals() for Airflow to import | [
"Generates",
"DAGs",
"from",
"YAML",
"config"
] | train | https://github.com/ajbosco/dag-factory/blob/cc7cfe74e62f82859fe38d527e95311a2805723b/dagfactory/dagfactory.py#L58-L78 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.attributes | def attributes(self):
"""Return sync attributes."""
attr = {
'name': self.name,
'id': self.sync_id,
'network_id': self.network_id,
'serial': self.serial,
'status': self.status,
'region': self.region,
'region_id': self.re... | python | def attributes(self):
"""Return sync attributes."""
attr = {
'name': self.name,
'id': self.sync_id,
'network_id': self.network_id,
'serial': self.serial,
'status': self.status,
'region': self.region,
'region_id': self.re... | [
"def",
"attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'id'",
":",
"self",
".",
"sync_id",
",",
"'network_id'",
":",
"self",
".",
"network_id",
",",
"'serial'",
":",
"self",
".",
"serial",
",",
"'statu... | Return sync attributes. | [
"Return",
"sync",
"attributes",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L41-L52 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.arm | def arm(self, value):
"""Arm or disarm system."""
if value:
return api.request_system_arm(self.blink, self.network_id)
return api.request_system_disarm(self.blink, self.network_id) | python | def arm(self, value):
"""Arm or disarm system."""
if value:
return api.request_system_arm(self.blink, self.network_id)
return api.request_system_disarm(self.blink, self.network_id) | [
"def",
"arm",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"return",
"api",
".",
"request_system_arm",
"(",
"self",
".",
"blink",
",",
"self",
".",
"network_id",
")",
"return",
"api",
".",
"request_system_disarm",
"(",
"self",
".",
"blink",
... | Arm or disarm system. | [
"Arm",
"or",
"disarm",
"system",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L73-L78 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.start | def start(self):
"""Initialize the system."""
response = api.request_syncmodule(self.blink,
self.network_id,
force=True)
try:
self.summary = response['syncmodule']
self.network_id = self.s... | python | def start(self):
"""Initialize the system."""
response = api.request_syncmodule(self.blink,
self.network_id,
force=True)
try:
self.summary = response['syncmodule']
self.network_id = self.s... | [
"def",
"start",
"(",
"self",
")",
":",
"response",
"=",
"api",
".",
"request_syncmodule",
"(",
"self",
".",
"blink",
",",
"self",
".",
"network_id",
",",
"force",
"=",
"True",
")",
"try",
":",
"self",
".",
"summary",
"=",
"response",
"[",
"'syncmodule'... | Initialize the system. | [
"Initialize",
"the",
"system",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L80-L123 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.get_events | def get_events(self, **kwargs):
"""Retrieve events from server."""
force = kwargs.pop('force', False)
response = api.request_sync_events(self.blink,
self.network_id,
force=force)
try:
return... | python | def get_events(self, **kwargs):
"""Retrieve events from server."""
force = kwargs.pop('force', False)
response = api.request_sync_events(self.blink,
self.network_id,
force=force)
try:
return... | [
"def",
"get_events",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"force",
"=",
"kwargs",
".",
"pop",
"(",
"'force'",
",",
"False",
")",
"response",
"=",
"api",
".",
"request_sync_events",
"(",
"self",
".",
"blink",
",",
"self",
".",
"network_id",
... | Retrieve events from server. | [
"Retrieve",
"events",
"from",
"server",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L125-L137 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.get_camera_info | def get_camera_info(self, camera_id):
"""Retrieve camera information."""
response = api.request_camera_info(self.blink,
self.network_id,
camera_id)
try:
return response['camera'][0]
except (... | python | def get_camera_info(self, camera_id):
"""Retrieve camera information."""
response = api.request_camera_info(self.blink,
self.network_id,
camera_id)
try:
return response['camera'][0]
except (... | [
"def",
"get_camera_info",
"(",
"self",
",",
"camera_id",
")",
":",
"response",
"=",
"api",
".",
"request_camera_info",
"(",
"self",
".",
"blink",
",",
"self",
".",
"network_id",
",",
"camera_id",
")",
"try",
":",
"return",
"response",
"[",
"'camera'",
"]",... | Retrieve camera information. | [
"Retrieve",
"camera",
"information",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L139-L150 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.refresh | def refresh(self, force_cache=False):
"""Get all blink cameras and pulls their most recent status."""
self.network_info = api.request_network_status(self.blink,
self.network_id)
self.check_new_videos()
for camera_name in self.cameras... | python | def refresh(self, force_cache=False):
"""Get all blink cameras and pulls their most recent status."""
self.network_info = api.request_network_status(self.blink,
self.network_id)
self.check_new_videos()
for camera_name in self.cameras... | [
"def",
"refresh",
"(",
"self",
",",
"force_cache",
"=",
"False",
")",
":",
"self",
".",
"network_info",
"=",
"api",
".",
"request_network_status",
"(",
"self",
".",
"blink",
",",
"self",
".",
"network_id",
")",
"self",
".",
"check_new_videos",
"(",
")",
... | Get all blink cameras and pulls their most recent status. | [
"Get",
"all",
"blink",
"cameras",
"and",
"pulls",
"their",
"most",
"recent",
"status",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L152-L161 |
fronzbot/blinkpy | blinkpy/sync_module.py | BlinkSyncModule.check_new_videos | def check_new_videos(self):
"""Check if new videos since last refresh."""
resp = api.request_videos(self.blink,
time=self.blink.last_refresh,
page=0)
for camera in self.cameras.keys():
self.motion[camera] = False
... | python | def check_new_videos(self):
"""Check if new videos since last refresh."""
resp = api.request_videos(self.blink,
time=self.blink.last_refresh,
page=0)
for camera in self.cameras.keys():
self.motion[camera] = False
... | [
"def",
"check_new_videos",
"(",
"self",
")",
":",
"resp",
"=",
"api",
".",
"request_videos",
"(",
"self",
".",
"blink",
",",
"time",
"=",
"self",
".",
"blink",
".",
"last_refresh",
",",
"page",
"=",
"0",
")",
"for",
"camera",
"in",
"self",
".",
"came... | Check if new videos since last refresh. | [
"Check",
"if",
"new",
"videos",
"since",
"last",
"refresh",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L163-L188 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.attributes | def attributes(self):
"""Return dictionary of all camera attributes."""
attributes = {
'name': self.name,
'camera_id': self.camera_id,
'serial': self.serial,
'temperature': self.temperature,
'temperature_c': self.temperature_c,
'tem... | python | def attributes(self):
"""Return dictionary of all camera attributes."""
attributes = {
'name': self.name,
'camera_id': self.camera_id,
'serial': self.serial,
'temperature': self.temperature,
'temperature_c': self.temperature_c,
'tem... | [
"def",
"attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'camera_id'",
":",
"self",
".",
"camera_id",
",",
"'serial'",
":",
"self",
".",
"serial",
",",
"'temperature'",
":",
"self",
".",
"temperature",... | Return dictionary of all camera attributes. | [
"Return",
"dictionary",
"of",
"all",
"camera",
"attributes",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L34-L53 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.snap_picture | def snap_picture(self):
"""Take a picture with camera to create a new thumbnail."""
return api.request_new_image(self.sync.blink,
self.network_id,
self.camera_id) | python | def snap_picture(self):
"""Take a picture with camera to create a new thumbnail."""
return api.request_new_image(self.sync.blink,
self.network_id,
self.camera_id) | [
"def",
"snap_picture",
"(",
"self",
")",
":",
"return",
"api",
".",
"request_new_image",
"(",
"self",
".",
"sync",
".",
"blink",
",",
"self",
".",
"network_id",
",",
"self",
".",
"camera_id",
")"
] | Take a picture with camera to create a new thumbnail. | [
"Take",
"a",
"picture",
"with",
"camera",
"to",
"create",
"a",
"new",
"thumbnail",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L79-L83 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.set_motion_detect | def set_motion_detect(self, enable):
"""Set motion detection."""
if enable:
return api.request_motion_detection_enable(self.sync.blink,
self.network_id,
self.camera_id)
retur... | python | def set_motion_detect(self, enable):
"""Set motion detection."""
if enable:
return api.request_motion_detection_enable(self.sync.blink,
self.network_id,
self.camera_id)
retur... | [
"def",
"set_motion_detect",
"(",
"self",
",",
"enable",
")",
":",
"if",
"enable",
":",
"return",
"api",
".",
"request_motion_detection_enable",
"(",
"self",
".",
"sync",
".",
"blink",
",",
"self",
".",
"network_id",
",",
"self",
".",
"camera_id",
")",
"ret... | Set motion detection. | [
"Set",
"motion",
"detection",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L85-L93 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.update | def update(self, config, force_cache=False, **kwargs):
"""Update camera info."""
# force = kwargs.pop('force', False)
self.name = config['name']
self.camera_id = str(config['id'])
self.network_id = str(config['network_id'])
self.serial = config['serial']
self.moti... | python | def update(self, config, force_cache=False, **kwargs):
"""Update camera info."""
# force = kwargs.pop('force', False)
self.name = config['name']
self.camera_id = str(config['id'])
self.network_id = str(config['network_id'])
self.serial = config['serial']
self.moti... | [
"def",
"update",
"(",
"self",
",",
"config",
",",
"force_cache",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# force = kwargs.pop('force', False)",
"self",
".",
"name",
"=",
"config",
"[",
"'name'",
"]",
"self",
".",
"camera_id",
"=",
"str",
"(",
"... | Update camera info. | [
"Update",
"camera",
"info",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L95-L162 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.image_to_file | def image_to_file(self, path):
"""
Write image to file.
:param path: Path to write file
"""
_LOGGER.debug("Writing image from %s to %s", self.name, path)
response = self._cached_image
if response.status_code == 200:
with open(path, 'wb') as imgfile:
... | python | def image_to_file(self, path):
"""
Write image to file.
:param path: Path to write file
"""
_LOGGER.debug("Writing image from %s to %s", self.name, path)
response = self._cached_image
if response.status_code == 200:
with open(path, 'wb') as imgfile:
... | [
"def",
"image_to_file",
"(",
"self",
",",
"path",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Writing image from %s to %s\"",
",",
"self",
".",
"name",
",",
"path",
")",
"response",
"=",
"self",
".",
"_cached_image",
"if",
"response",
".",
"status_code",
"=="... | Write image to file.
:param path: Path to write file | [
"Write",
"image",
"to",
"file",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L164-L178 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.video_to_file | def video_to_file(self, path):
"""Write video to file.
:param path: Path to write file
"""
_LOGGER.debug("Writing video from %s to %s", self.name, path)
response = self._cached_video
if response is None:
_LOGGER.error("No saved video exist for %s.",
... | python | def video_to_file(self, path):
"""Write video to file.
:param path: Path to write file
"""
_LOGGER.debug("Writing video from %s to %s", self.name, path)
response = self._cached_video
if response is None:
_LOGGER.error("No saved video exist for %s.",
... | [
"def",
"video_to_file",
"(",
"self",
",",
"path",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Writing video from %s to %s\"",
",",
"self",
".",
"name",
",",
"path",
")",
"response",
"=",
"self",
".",
"_cached_video",
"if",
"response",
"is",
"None",
":",
"_L... | Write video to file.
:param path: Path to write file | [
"Write",
"video",
"to",
"file",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L180-L193 |
fronzbot/blinkpy | blinkpy/camera.py | BlinkCamera.get_thumb_from_homescreen | def get_thumb_from_homescreen(self):
"""Retrieve thumbnail from homescreen."""
for device in self.sync.homescreen['devices']:
try:
device_type = device['device_type']
device_name = device['name']
device_thumb = device['thumbnail']
... | python | def get_thumb_from_homescreen(self):
"""Retrieve thumbnail from homescreen."""
for device in self.sync.homescreen['devices']:
try:
device_type = device['device_type']
device_name = device['name']
device_thumb = device['thumbnail']
... | [
"def",
"get_thumb_from_homescreen",
"(",
"self",
")",
":",
"for",
"device",
"in",
"self",
".",
"sync",
".",
"homescreen",
"[",
"'devices'",
"]",
":",
"try",
":",
"device_type",
"=",
"device",
"[",
"'device_type'",
"]",
"device_name",
"=",
"device",
"[",
"'... | Retrieve thumbnail from homescreen. | [
"Retrieve",
"thumbnail",
"from",
"homescreen",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L195-L209 |
fronzbot/blinkpy | blinkpy/helpers/util.py | get_time | def get_time(time_to_convert=None):
"""Create blink-compatible timestamp."""
if time_to_convert is None:
time_to_convert = time.time()
return time.strftime(TIMESTAMP_FORMAT, time.localtime(time_to_convert)) | python | def get_time(time_to_convert=None):
"""Create blink-compatible timestamp."""
if time_to_convert is None:
time_to_convert = time.time()
return time.strftime(TIMESTAMP_FORMAT, time.localtime(time_to_convert)) | [
"def",
"get_time",
"(",
"time_to_convert",
"=",
"None",
")",
":",
"if",
"time_to_convert",
"is",
"None",
":",
"time_to_convert",
"=",
"time",
".",
"time",
"(",
")",
"return",
"time",
".",
"strftime",
"(",
"TIMESTAMP_FORMAT",
",",
"time",
".",
"localtime",
... | Create blink-compatible timestamp. | [
"Create",
"blink",
"-",
"compatible",
"timestamp",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L14-L18 |
fronzbot/blinkpy | blinkpy/helpers/util.py | merge_dicts | def merge_dicts(dict_a, dict_b):
"""Merge two dictionaries into one."""
duplicates = [val for val in dict_a if val in dict_b]
if duplicates:
_LOGGER.warning(("Duplicates found during merge: %s. "
"Renaming is recommended."), duplicates)
return {**dict_a, **dict_b} | python | def merge_dicts(dict_a, dict_b):
"""Merge two dictionaries into one."""
duplicates = [val for val in dict_a if val in dict_b]
if duplicates:
_LOGGER.warning(("Duplicates found during merge: %s. "
"Renaming is recommended."), duplicates)
return {**dict_a, **dict_b} | [
"def",
"merge_dicts",
"(",
"dict_a",
",",
"dict_b",
")",
":",
"duplicates",
"=",
"[",
"val",
"for",
"val",
"in",
"dict_a",
"if",
"val",
"in",
"dict_b",
"]",
"if",
"duplicates",
":",
"_LOGGER",
".",
"warning",
"(",
"(",
"\"Duplicates found during merge: %s. \... | Merge two dictionaries into one. | [
"Merge",
"two",
"dictionaries",
"into",
"one",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L21-L27 |
fronzbot/blinkpy | blinkpy/helpers/util.py | attempt_reauthorization | def attempt_reauthorization(blink):
"""Attempt to refresh auth token and links."""
_LOGGER.info("Auth token expired, attempting reauthorization.")
headers = blink.get_auth_token(is_retry=True)
return headers | python | def attempt_reauthorization(blink):
"""Attempt to refresh auth token and links."""
_LOGGER.info("Auth token expired, attempting reauthorization.")
headers = blink.get_auth_token(is_retry=True)
return headers | [
"def",
"attempt_reauthorization",
"(",
"blink",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Auth token expired, attempting reauthorization.\"",
")",
"headers",
"=",
"blink",
".",
"get_auth_token",
"(",
"is_retry",
"=",
"True",
")",
"return",
"headers"
] | Attempt to refresh auth token and links. | [
"Attempt",
"to",
"refresh",
"auth",
"token",
"and",
"links",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L36-L40 |
fronzbot/blinkpy | blinkpy/helpers/util.py | http_req | def http_req(blink, url='http://example.com', data=None, headers=None,
reqtype='get', stream=False, json_resp=True, is_retry=False):
"""
Perform server requests and check if reauthorization neccessary.
:param blink: Blink instance
:param url: URL to perform request
:param data: Data to... | python | def http_req(blink, url='http://example.com', data=None, headers=None,
reqtype='get', stream=False, json_resp=True, is_retry=False):
"""
Perform server requests and check if reauthorization neccessary.
:param blink: Blink instance
:param url: URL to perform request
:param data: Data to... | [
"def",
"http_req",
"(",
"blink",
",",
"url",
"=",
"'http://example.com'",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"reqtype",
"=",
"'get'",
",",
"stream",
"=",
"False",
",",
"json_resp",
"=",
"True",
",",
"is_retry",
"=",
"False",
")... | Perform server requests and check if reauthorization neccessary.
:param blink: Blink instance
:param url: URL to perform request
:param data: Data to send (default: None)
:param headers: Headers to send (default: None)
:param reqtype: Can be 'get' or 'post' (default: 'get')
:param stream: Strea... | [
"Perform",
"server",
"requests",
"and",
"check",
"if",
"reauthorization",
"neccessary",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L43-L94 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.start | def start(self):
"""
Perform full system setup.
Method logs in and sets auth token, urls, and ids for future requests.
Essentially this is just a wrapper function for ease of use.
"""
if self._username is None or self._password is None:
if not self.login():
... | python | def start(self):
"""
Perform full system setup.
Method logs in and sets auth token, urls, and ids for future requests.
Essentially this is just a wrapper function for ease of use.
"""
if self._username is None or self._password is None:
if not self.login():
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"_username",
"is",
"None",
"or",
"self",
".",
"_password",
"is",
"None",
":",
"if",
"not",
"self",
".",
"login",
"(",
")",
":",
"return",
"elif",
"not",
"self",
".",
"get_auth_token",
"(",
"... | Perform full system setup.
Method logs in and sets auth token, urls, and ids for future requests.
Essentially this is just a wrapper function for ease of use. | [
"Perform",
"full",
"system",
"setup",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L82-L107 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.login | def login(self):
"""Prompt user for username and password."""
self._username = input("Username:")
self._password = getpass.getpass("Password:")
if self.get_auth_token():
_LOGGER.debug("Login successful!")
return True
_LOGGER.warning("Unable to login with %... | python | def login(self):
"""Prompt user for username and password."""
self._username = input("Username:")
self._password = getpass.getpass("Password:")
if self.get_auth_token():
_LOGGER.debug("Login successful!")
return True
_LOGGER.warning("Unable to login with %... | [
"def",
"login",
"(",
"self",
")",
":",
"self",
".",
"_username",
"=",
"input",
"(",
"\"Username:\"",
")",
"self",
".",
"_password",
"=",
"getpass",
".",
"getpass",
"(",
"\"Password:\"",
")",
"if",
"self",
".",
"get_auth_token",
"(",
")",
":",
"_LOGGER",
... | Prompt user for username and password. | [
"Prompt",
"user",
"for",
"username",
"and",
"password",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L109-L117 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.get_auth_token | def get_auth_token(self, is_retry=False):
"""Retrieve the authentication token from Blink."""
if not isinstance(self._username, str):
raise BlinkAuthenticationException(ERROR.USERNAME)
if not isinstance(self._password, str):
raise BlinkAuthenticationException(ERROR.PASSWO... | python | def get_auth_token(self, is_retry=False):
"""Retrieve the authentication token from Blink."""
if not isinstance(self._username, str):
raise BlinkAuthenticationException(ERROR.USERNAME)
if not isinstance(self._password, str):
raise BlinkAuthenticationException(ERROR.PASSWO... | [
"def",
"get_auth_token",
"(",
"self",
",",
"is_retry",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_username",
",",
"str",
")",
":",
"raise",
"BlinkAuthenticationException",
"(",
"ERROR",
".",
"USERNAME",
")",
"if",
"not",
"isinst... | Retrieve the authentication token from Blink. | [
"Retrieve",
"the",
"authentication",
"token",
"from",
"Blink",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L119-L141 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.login_request | def login_request(self, login_urls, is_retry=False):
"""Make a login request."""
try:
login_url = login_urls.pop(0)
except IndexError:
_LOGGER.error("Could not login to blink servers.")
return False
_LOGGER.info("Attempting login with %s", login_url)
... | python | def login_request(self, login_urls, is_retry=False):
"""Make a login request."""
try:
login_url = login_urls.pop(0)
except IndexError:
_LOGGER.error("Could not login to blink servers.")
return False
_LOGGER.info("Attempting login with %s", login_url)
... | [
"def",
"login_request",
"(",
"self",
",",
"login_urls",
",",
"is_retry",
"=",
"False",
")",
":",
"try",
":",
"login_url",
"=",
"login_urls",
".",
"pop",
"(",
"0",
")",
"except",
"IndexError",
":",
"_LOGGER",
".",
"error",
"(",
"\"Could not login to blink ser... | Make a login request. | [
"Make",
"a",
"login",
"request",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L143-L176 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.get_ids | def get_ids(self):
"""Set the network ID and Account ID."""
response = api.request_networks(self)
all_networks = []
network_dict = {}
for network, status in self.networks.items():
if status['onboarded']:
all_networks.append('{}'.format(network))
... | python | def get_ids(self):
"""Set the network ID and Account ID."""
response = api.request_networks(self)
all_networks = []
network_dict = {}
for network, status in self.networks.items():
if status['onboarded']:
all_networks.append('{}'.format(network))
... | [
"def",
"get_ids",
"(",
"self",
")",
":",
"response",
"=",
"api",
".",
"request_networks",
"(",
"self",
")",
"all_networks",
"=",
"[",
"]",
"network_dict",
"=",
"{",
"}",
"for",
"network",
",",
"status",
"in",
"self",
".",
"networks",
".",
"items",
"(",... | Set the network ID and Account ID. | [
"Set",
"the",
"network",
"ID",
"and",
"Account",
"ID",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L178-L195 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.get_cameras | def get_cameras(self):
"""Retrieve a camera list for each onboarded network."""
response = api.request_homescreen(self)
try:
all_cameras = {}
for camera in response['cameras']:
camera_network = str(camera['network_id'])
camera_name = camera... | python | def get_cameras(self):
"""Retrieve a camera list for each onboarded network."""
response = api.request_homescreen(self)
try:
all_cameras = {}
for camera in response['cameras']:
camera_network = str(camera['network_id'])
camera_name = camera... | [
"def",
"get_cameras",
"(",
"self",
")",
":",
"response",
"=",
"api",
".",
"request_homescreen",
"(",
"self",
")",
"try",
":",
"all_cameras",
"=",
"{",
"}",
"for",
"camera",
"in",
"response",
"[",
"'cameras'",
"]",
":",
"camera_network",
"=",
"str",
"(",
... | Retrieve a camera list for each onboarded network. | [
"Retrieve",
"a",
"camera",
"list",
"for",
"each",
"onboarded",
"network",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L197-L214 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.refresh | def refresh(self, force_cache=False):
"""
Perform a system refresh.
:param force_cache: Force an update of the camera cache
"""
if self.check_if_ok_to_update() or force_cache:
for sync_name, sync_module in self.sync.items():
_LOGGER.debug("Attempting ... | python | def refresh(self, force_cache=False):
"""
Perform a system refresh.
:param force_cache: Force an update of the camera cache
"""
if self.check_if_ok_to_update() or force_cache:
for sync_name, sync_module in self.sync.items():
_LOGGER.debug("Attempting ... | [
"def",
"refresh",
"(",
"self",
",",
"force_cache",
"=",
"False",
")",
":",
"if",
"self",
".",
"check_if_ok_to_update",
"(",
")",
"or",
"force_cache",
":",
"for",
"sync_name",
",",
"sync_module",
"in",
"self",
".",
"sync",
".",
"items",
"(",
")",
":",
"... | Perform a system refresh.
:param force_cache: Force an update of the camera cache | [
"Perform",
"a",
"system",
"refresh",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L217-L231 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.check_if_ok_to_update | def check_if_ok_to_update(self):
"""Check if it is ok to perform an http request."""
current_time = int(time.time())
last_refresh = self.last_refresh
if last_refresh is None:
last_refresh = 0
if current_time >= (last_refresh + self.refresh_rate):
return Tr... | python | def check_if_ok_to_update(self):
"""Check if it is ok to perform an http request."""
current_time = int(time.time())
last_refresh = self.last_refresh
if last_refresh is None:
last_refresh = 0
if current_time >= (last_refresh + self.refresh_rate):
return Tr... | [
"def",
"check_if_ok_to_update",
"(",
"self",
")",
":",
"current_time",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"last_refresh",
"=",
"self",
".",
"last_refresh",
"if",
"last_refresh",
"is",
"None",
":",
"last_refresh",
"=",
"0",
"if",
"current_... | Check if it is ok to perform an http request. | [
"Check",
"if",
"it",
"is",
"ok",
"to",
"perform",
"an",
"http",
"request",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L233-L241 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.merge_cameras | def merge_cameras(self):
"""Merge all sync camera dicts into one."""
combined = CaseInsensitiveDict({})
for sync in self.sync:
combined = merge_dicts(combined, self.sync[sync].cameras)
return combined | python | def merge_cameras(self):
"""Merge all sync camera dicts into one."""
combined = CaseInsensitiveDict({})
for sync in self.sync:
combined = merge_dicts(combined, self.sync[sync].cameras)
return combined | [
"def",
"merge_cameras",
"(",
"self",
")",
":",
"combined",
"=",
"CaseInsensitiveDict",
"(",
"{",
"}",
")",
"for",
"sync",
"in",
"self",
".",
"sync",
":",
"combined",
"=",
"merge_dicts",
"(",
"combined",
",",
"self",
".",
"sync",
"[",
"sync",
"]",
".",
... | Merge all sync camera dicts into one. | [
"Merge",
"all",
"sync",
"camera",
"dicts",
"into",
"one",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L243-L248 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink.download_videos | def download_videos(self, path, since=None, camera='all', stop=10):
"""
Download all videos from server since specified time.
:param path: Path to write files. /path/<cameraname>_<recorddate>.mp4
:param since: Date and time to get videos from.
Ex: "2018/07/28 12:3... | python | def download_videos(self, path, since=None, camera='all', stop=10):
"""
Download all videos from server since specified time.
:param path: Path to write files. /path/<cameraname>_<recorddate>.mp4
:param since: Date and time to get videos from.
Ex: "2018/07/28 12:3... | [
"def",
"download_videos",
"(",
"self",
",",
"path",
",",
"since",
"=",
"None",
",",
"camera",
"=",
"'all'",
",",
"stop",
"=",
"10",
")",
":",
"if",
"since",
"is",
"None",
":",
"since_epochs",
"=",
"self",
".",
"last_refresh",
"else",
":",
"parsed_datet... | Download all videos from server since specified time.
:param path: Path to write files. /path/<cameraname>_<recorddate>.mp4
:param since: Date and time to get videos from.
Ex: "2018/07/28 12:33:00" to retrieve videos since
July 28th 2018 at 12:33:00
... | [
"Download",
"all",
"videos",
"from",
"server",
"since",
"specified",
"time",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L250-L285 |
fronzbot/blinkpy | blinkpy/blinkpy.py | Blink._parse_downloaded_items | def _parse_downloaded_items(self, result, camera, path):
"""Parse downloaded videos."""
for item in result:
try:
created_at = item['created_at']
camera_name = item['camera_name']
is_deleted = item['deleted']
address = item['addr... | python | def _parse_downloaded_items(self, result, camera, path):
"""Parse downloaded videos."""
for item in result:
try:
created_at = item['created_at']
camera_name = item['camera_name']
is_deleted = item['deleted']
address = item['addr... | [
"def",
"_parse_downloaded_items",
"(",
"self",
",",
"result",
",",
"camera",
",",
"path",
")",
":",
"for",
"item",
"in",
"result",
":",
"try",
":",
"created_at",
"=",
"item",
"[",
"'created_at'",
"]",
"camera_name",
"=",
"item",
"[",
"'camera_name'",
"]",
... | Parse downloaded videos. | [
"Parse",
"downloaded",
"videos",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L287-L322 |
fronzbot/blinkpy | blinkpy/api.py | request_login | def request_login(blink, url, username, password, is_retry=False):
"""
Login request.
:param blink: Blink instance.
:param url: Login url.
:param username: Blink username.
:param password: Blink password.
:param is_retry: Is this part of a re-authorization attempt?
"""
headers = {
... | python | def request_login(blink, url, username, password, is_retry=False):
"""
Login request.
:param blink: Blink instance.
:param url: Login url.
:param username: Blink username.
:param password: Blink password.
:param is_retry: Is this part of a re-authorization attempt?
"""
headers = {
... | [
"def",
"request_login",
"(",
"blink",
",",
"url",
",",
"username",
",",
"password",
",",
"is_retry",
"=",
"False",
")",
":",
"headers",
"=",
"{",
"'Host'",
":",
"DEFAULT_URL",
",",
"'Content-Type'",
":",
"'application/json'",
"}",
"data",
"=",
"dumps",
"("... | Login request.
:param blink: Blink instance.
:param url: Login url.
:param username: Blink username.
:param password: Blink password.
:param is_retry: Is this part of a re-authorization attempt? | [
"Login",
"request",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L14-L34 |
fronzbot/blinkpy | blinkpy/api.py | request_networks | def request_networks(blink):
"""Request all networks information."""
url = "{}/networks".format(blink.urls.base_url)
return http_get(blink, url) | python | def request_networks(blink):
"""Request all networks information."""
url = "{}/networks".format(blink.urls.base_url)
return http_get(blink, url) | [
"def",
"request_networks",
"(",
"blink",
")",
":",
"url",
"=",
"\"{}/networks\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request all networks information. | [
"Request",
"all",
"networks",
"information",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L37-L40 |
fronzbot/blinkpy | blinkpy/api.py | request_network_status | def request_network_status(blink, network):
"""
Request network information.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}".format(blink.urls.base_url, network)
return http_get(blink, url) | python | def request_network_status(blink, network):
"""
Request network information.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}".format(blink.urls.base_url, network)
return http_get(blink, url) | [
"def",
"request_network_status",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/network/{}\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request network information.
:param blink: Blink instance.
:param network: Sync module network id. | [
"Request",
"network",
"information",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L44-L52 |
fronzbot/blinkpy | blinkpy/api.py | request_syncmodule | def request_syncmodule(blink, network):
"""
Request sync module info.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/syncmodules".format(blink.urls.base_url, network)
return http_get(blink, url) | python | def request_syncmodule(blink, network):
"""
Request sync module info.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/syncmodules".format(blink.urls.base_url, network)
return http_get(blink, url) | [
"def",
"request_syncmodule",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/network/{}/syncmodules\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request sync module info.
:param blink: Blink instance.
:param network: Sync module network id. | [
"Request",
"sync",
"module",
"info",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L56-L64 |
fronzbot/blinkpy | blinkpy/api.py | request_system_arm | def request_system_arm(blink, network):
"""
Arm system.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/arm".format(blink.urls.base_url, network)
return http_post(blink, url) | python | def request_system_arm(blink, network):
"""
Arm system.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/arm".format(blink.urls.base_url, network)
return http_post(blink, url) | [
"def",
"request_system_arm",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/network/{}/arm\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_post",
"(",
"blink",
",",
"url",
")"
] | Arm system.
:param blink: Blink instance.
:param network: Sync module network id. | [
"Arm",
"system",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L68-L76 |
fronzbot/blinkpy | blinkpy/api.py | request_system_disarm | def request_system_disarm(blink, network):
"""
Disarm system.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/disarm".format(blink.urls.base_url, network)
return http_post(blink, url) | python | def request_system_disarm(blink, network):
"""
Disarm system.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/disarm".format(blink.urls.base_url, network)
return http_post(blink, url) | [
"def",
"request_system_disarm",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/network/{}/disarm\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_post",
"(",
"blink",
",",
"url",
")"
] | Disarm system.
:param blink: Blink instance.
:param network: Sync module network id. | [
"Disarm",
"system",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L80-L88 |
fronzbot/blinkpy | blinkpy/api.py | request_command_status | def request_command_status(blink, network, command_id):
"""
Request command status.
:param blink: Blink instance.
:param network: Sync module network id.
:param command_id: Command id to check.
"""
url = "{}/network/{}/command/{}".format(blink.urls.base_url,
... | python | def request_command_status(blink, network, command_id):
"""
Request command status.
:param blink: Blink instance.
:param network: Sync module network id.
:param command_id: Command id to check.
"""
url = "{}/network/{}/command/{}".format(blink.urls.base_url,
... | [
"def",
"request_command_status",
"(",
"blink",
",",
"network",
",",
"command_id",
")",
":",
"url",
"=",
"\"{}/network/{}/command/{}\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
",",
"command_id",
")",
"return",
"http_get",
"("... | Request command status.
:param blink: Blink instance.
:param network: Sync module network id.
:param command_id: Command id to check. | [
"Request",
"command",
"status",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L91-L102 |
fronzbot/blinkpy | blinkpy/api.py | request_homescreen | def request_homescreen(blink):
"""Request homescreen info."""
url = "{}/api/v3/accounts/{}/homescreen".format(blink.urls.base_url,
blink.account_id)
return http_get(blink, url) | python | def request_homescreen(blink):
"""Request homescreen info."""
url = "{}/api/v3/accounts/{}/homescreen".format(blink.urls.base_url,
blink.account_id)
return http_get(blink, url) | [
"def",
"request_homescreen",
"(",
"blink",
")",
":",
"url",
"=",
"\"{}/api/v3/accounts/{}/homescreen\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"blink",
".",
"account_id",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request homescreen info. | [
"Request",
"homescreen",
"info",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L106-L110 |
fronzbot/blinkpy | blinkpy/api.py | request_sync_events | def request_sync_events(blink, network):
"""
Request events from sync module.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/events/network/{}".format(blink.urls.base_url, network)
return http_get(blink, url) | python | def request_sync_events(blink, network):
"""
Request events from sync module.
:param blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/events/network/{}".format(blink.urls.base_url, network)
return http_get(blink, url) | [
"def",
"request_sync_events",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/events/network/{}\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request events from sync module.
:param blink: Blink instance.
:param network: Sync module network id. | [
"Request",
"events",
"from",
"sync",
"module",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L114-L122 |
fronzbot/blinkpy | blinkpy/api.py | request_video_count | def request_video_count(blink):
"""Request total video count."""
url = "{}/api/v2/videos/count".format(blink.urls.base_url)
return http_get(blink, url) | python | def request_video_count(blink):
"""Request total video count."""
url = "{}/api/v2/videos/count".format(blink.urls.base_url)
return http_get(blink, url) | [
"def",
"request_video_count",
"(",
"blink",
")",
":",
"url",
"=",
"\"{}/api/v2/videos/count\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request total video count. | [
"Request",
"total",
"video",
"count",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L156-L159 |
fronzbot/blinkpy | blinkpy/api.py | request_videos | def request_videos(blink, time=None, page=0):
"""
Perform a request for videos.
:param blink: Blink instance.
:param time: Get videos since this time. In epoch seconds.
:param page: Page number to get videos from.
"""
timestamp = get_time(time)
url = "{}/api/v2/videos/changed?since={}&... | python | def request_videos(blink, time=None, page=0):
"""
Perform a request for videos.
:param blink: Blink instance.
:param time: Get videos since this time. In epoch seconds.
:param page: Page number to get videos from.
"""
timestamp = get_time(time)
url = "{}/api/v2/videos/changed?since={}&... | [
"def",
"request_videos",
"(",
"blink",
",",
"time",
"=",
"None",
",",
"page",
"=",
"0",
")",
":",
"timestamp",
"=",
"get_time",
"(",
"time",
")",
"url",
"=",
"\"{}/api/v2/videos/changed?since={}&page={}\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"b... | Perform a request for videos.
:param blink: Blink instance.
:param time: Get videos since this time. In epoch seconds.
:param page: Page number to get videos from. | [
"Perform",
"a",
"request",
"for",
"videos",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L162-L173 |
fronzbot/blinkpy | blinkpy/api.py | request_cameras | def request_cameras(blink, network):
"""
Request all camera information.
:param Blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/cameras".format(blink.urls.base_url, network)
return http_get(blink, url) | python | def request_cameras(blink, network):
"""
Request all camera information.
:param Blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/cameras".format(blink.urls.base_url, network)
return http_get(blink, url) | [
"def",
"request_cameras",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/network/{}/cameras\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request all camera information.
:param Blink: Blink instance.
:param network: Sync module network id. | [
"Request",
"all",
"camera",
"information",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L177-L185 |
fronzbot/blinkpy | blinkpy/api.py | request_camera_sensors | def request_camera_sensors(blink, network, camera_id):
"""
Request camera sensor info for one camera.
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to request sesnor info from.
"""
url = "{}/network/{}/camera/{}/signals".format(b... | python | def request_camera_sensors(blink, network, camera_id):
"""
Request camera sensor info for one camera.
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to request sesnor info from.
"""
url = "{}/network/{}/camera/{}/signals".format(b... | [
"def",
"request_camera_sensors",
"(",
"blink",
",",
"network",
",",
"camera_id",
")",
":",
"url",
"=",
"\"{}/network/{}/camera/{}/signals\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
",",
"camera_id",
")",
"return",
"http_get",
... | Request camera sensor info for one camera.
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to request sesnor info from. | [
"Request",
"camera",
"sensor",
"info",
"for",
"one",
"camera",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L202-L213 |
fronzbot/blinkpy | blinkpy/api.py | request_motion_detection_enable | def request_motion_detection_enable(blink, network, camera_id):
"""
Enable motion detection for a camera.
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to enable.
"""
url = "{}/network/{}/camera/{}/enable".format(blink.urls.base_... | python | def request_motion_detection_enable(blink, network, camera_id):
"""
Enable motion detection for a camera.
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to enable.
"""
url = "{}/network/{}/camera/{}/enable".format(blink.urls.base_... | [
"def",
"request_motion_detection_enable",
"(",
"blink",
",",
"network",
",",
"camera_id",
")",
":",
"url",
"=",
"\"{}/network/{}/camera/{}/enable\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
",",
"camera_id",
")",
"return",
"htt... | Enable motion detection for a camera.
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to enable. | [
"Enable",
"motion",
"detection",
"for",
"a",
"camera",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L217-L228 |
fronzbot/blinkpy | blinkpy/api.py | http_get | def http_get(blink, url, stream=False, json=True, is_retry=False):
"""
Perform an http get request.
:param url: URL to perform get request.
:param stream: Stream response? True/FALSE
:param json: Return json response? TRUE/False
:param is_retry: Is this part of a re-auth attempt?
"""
if... | python | def http_get(blink, url, stream=False, json=True, is_retry=False):
"""
Perform an http get request.
:param url: URL to perform get request.
:param stream: Stream response? True/FALSE
:param json: Return json response? TRUE/False
:param is_retry: Is this part of a re-auth attempt?
"""
if... | [
"def",
"http_get",
"(",
"blink",
",",
"url",
",",
"stream",
"=",
"False",
",",
"json",
"=",
"True",
",",
"is_retry",
"=",
"False",
")",
":",
"if",
"blink",
".",
"auth_header",
"is",
"None",
":",
"raise",
"BlinkException",
"(",
"ERROR",
".",
"AUTH_TOKEN... | Perform an http get request.
:param url: URL to perform get request.
:param stream: Stream response? True/FALSE
:param json: Return json response? TRUE/False
:param is_retry: Is this part of a re-auth attempt? | [
"Perform",
"an",
"http",
"get",
"request",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L245-L259 |
fronzbot/blinkpy | blinkpy/api.py | http_post | def http_post(blink, url, is_retry=False):
"""
Perform an http post request.
:param url: URL to perfom post request.
:param is_retry: Is this part of a re-auth attempt?
"""
if blink.auth_header is None:
raise BlinkException(ERROR.AUTH_TOKEN)
_LOGGER.debug("Making POST request to %s"... | python | def http_post(blink, url, is_retry=False):
"""
Perform an http post request.
:param url: URL to perfom post request.
:param is_retry: Is this part of a re-auth attempt?
"""
if blink.auth_header is None:
raise BlinkException(ERROR.AUTH_TOKEN)
_LOGGER.debug("Making POST request to %s"... | [
"def",
"http_post",
"(",
"blink",
",",
"url",
",",
"is_retry",
"=",
"False",
")",
":",
"if",
"blink",
".",
"auth_header",
"is",
"None",
":",
"raise",
"BlinkException",
"(",
"ERROR",
".",
"AUTH_TOKEN",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Making POST reque... | Perform an http post request.
:param url: URL to perfom post request.
:param is_retry: Is this part of a re-auth attempt? | [
"Perform",
"an",
"http",
"post",
"request",
"."
] | train | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L262-L273 |
loli/medpy | medpy/filter/image.py | sls | def sls(minuend, subtrahend, metric = "ssd", noise = "global", signed = True,
sn_size = None, sn_footprint = None, sn_mode = "reflect", sn_cval = 0.0,
pn_size = None, pn_footprint = None, pn_mode = "reflect", pn_cval = 0.0):
r"""
Computes the signed local similarity between two images.
Comp... | python | def sls(minuend, subtrahend, metric = "ssd", noise = "global", signed = True,
sn_size = None, sn_footprint = None, sn_mode = "reflect", sn_cval = 0.0,
pn_size = None, pn_footprint = None, pn_mode = "reflect", pn_cval = 0.0):
r"""
Computes the signed local similarity between two images.
Comp... | [
"def",
"sls",
"(",
"minuend",
",",
"subtrahend",
",",
"metric",
"=",
"\"ssd\"",
",",
"noise",
"=",
"\"global\"",
",",
"signed",
"=",
"True",
",",
"sn_size",
"=",
"None",
",",
"sn_footprint",
"=",
"None",
",",
"sn_mode",
"=",
"\"reflect\"",
",",
"sn_cval"... | r"""
Computes the signed local similarity between two images.
Compares a patch around each voxel of the minuend array to a number of patches
centered at the points of a search neighbourhood in the subtrahend. Thus, creates
a multi-dimensional measure of patch similarity between the minuend and a
co... | [
"r",
"Computes",
"the",
"signed",
"local",
"similarity",
"between",
"two",
"images",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L37-L170 |
loli/medpy | medpy/filter/image.py | ssd | def ssd(minuend, subtrahend, normalized=True, signed=False, size=None, footprint=None, mode="reflect", cval=0.0, origin=0):
r"""
Computes the sum of squared difference (SSD) between patches of minuend and subtrahend.
Parameters
----------
minuend : array_like
Input array from which to s... | python | def ssd(minuend, subtrahend, normalized=True, signed=False, size=None, footprint=None, mode="reflect", cval=0.0, origin=0):
r"""
Computes the sum of squared difference (SSD) between patches of minuend and subtrahend.
Parameters
----------
minuend : array_like
Input array from which to s... | [
"def",
"ssd",
"(",
"minuend",
",",
"subtrahend",
",",
"normalized",
"=",
"True",
",",
"signed",
"=",
"False",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
",",
"origin",
"=",
"0",
... | r"""
Computes the sum of squared difference (SSD) between patches of minuend and subtrahend.
Parameters
----------
minuend : array_like
Input array from which to subtract the subtrahend.
subtrahend : array_like
Input array to subtract from the minuend.
normalized : bool,... | [
"r",
"Computes",
"the",
"sum",
"of",
"squared",
"difference",
"(",
"SSD",
")",
"between",
"patches",
"of",
"minuend",
"and",
"subtrahend",
".",
"Parameters",
"----------",
"minuend",
":",
"array_like",
"Input",
"array",
"from",
"which",
"to",
"subtract",
"the"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L172-L228 |
loli/medpy | medpy/filter/image.py | average_filter | def average_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculates a multi-dimensional average filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
foo... | python | def average_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculates a multi-dimensional average filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
foo... | [
"def",
"average_filter",
"(",
"input",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
"None",
",",
"output",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
",",
"origin",
"=",
"0",
")",
":",
"footprint",
"=",
"__make_footprint... | r"""
Calculates a multi-dimensional average filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
footprint : array, optional
Either `size` or `footprint` must be defined. `size` gives
the sha... | [
"r",
"Calculates",
"a",
"multi",
"-",
"dimensional",
"average",
"filter",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L230-L284 |
loli/medpy | medpy/filter/image.py | sum_filter | def sum_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculates a multi-dimensional sum filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
footprint :... | python | def sum_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculates a multi-dimensional sum filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
footprint :... | [
"def",
"sum_filter",
"(",
"input",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
"None",
",",
"output",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
",",
"origin",
"=",
"0",
")",
":",
"footprint",
"=",
"__make_footprint",
... | r"""
Calculates a multi-dimensional sum filter.
Parameters
----------
input : array-like
input array to filter
size : scalar or tuple, optional
See footprint, below
footprint : array, optional
Either `size` or `footprint` must be defined. `size` gives
the shape t... | [
"r",
"Calculates",
"a",
"multi",
"-",
"dimensional",
"sum",
"filter",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L287-L337 |
loli/medpy | medpy/filter/image.py | otsu | def otsu (img, bins=64):
r"""
Otsu's method to find the optimal threshold separating an image into fore- and background.
This rather expensive method iterates over a number of thresholds to separate the
images histogram into two parts with a minimal intra-class variance.
An increase in the... | python | def otsu (img, bins=64):
r"""
Otsu's method to find the optimal threshold separating an image into fore- and background.
This rather expensive method iterates over a number of thresholds to separate the
images histogram into two parts with a minimal intra-class variance.
An increase in the... | [
"def",
"otsu",
"(",
"img",
",",
"bins",
"=",
"64",
")",
":",
"# cast bins parameter to int",
"bins",
"=",
"int",
"(",
"bins",
")",
"# cast img parameter to scipy arrax",
"img",
"=",
"numpy",
".",
"asarray",
"(",
"img",
")",
"# check supplied parameters",
"if",
... | r"""
Otsu's method to find the optimal threshold separating an image into fore- and background.
This rather expensive method iterates over a number of thresholds to separate the
images histogram into two parts with a minimal intra-class variance.
An increase in the number of bins increases the... | [
"r",
"Otsu",
"s",
"method",
"to",
"find",
"the",
"optimal",
"threshold",
"separating",
"an",
"image",
"into",
"fore",
"-",
"and",
"background",
".",
"This",
"rather",
"expensive",
"method",
"iterates",
"over",
"a",
"number",
"of",
"thresholds",
"to",
"separa... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L339-L398 |
loli/medpy | medpy/filter/image.py | local_minima | def local_minima(img, min_distance = 4):
r"""
Returns all local minima from an image.
Parameters
----------
img : array_like
The image.
min_distance : integer
The minimal distance between the minimas in voxels. If it is less, only the lower minima is returned.
Retur... | python | def local_minima(img, min_distance = 4):
r"""
Returns all local minima from an image.
Parameters
----------
img : array_like
The image.
min_distance : integer
The minimal distance between the minimas in voxels. If it is less, only the lower minima is returned.
Retur... | [
"def",
"local_minima",
"(",
"img",
",",
"min_distance",
"=",
"4",
")",
":",
"# @TODO: Write a unittest for this.",
"fits",
"=",
"numpy",
".",
"asarray",
"(",
"img",
")",
"minfits",
"=",
"minimum_filter",
"(",
"fits",
",",
"size",
"=",
"min_distance",
")",
"#... | r"""
Returns all local minima from an image.
Parameters
----------
img : array_like
The image.
min_distance : integer
The minimal distance between the minimas in voxels. If it is less, only the lower minima is returned.
Returns
-------
indices : sequence
... | [
"r",
"Returns",
"all",
"local",
"minima",
"from",
"an",
"image",
".",
"Parameters",
"----------",
"img",
":",
"array_like",
"The",
"image",
".",
"min_distance",
":",
"integer",
"The",
"minimal",
"distance",
"between",
"the",
"minimas",
"in",
"voxels",
".",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L400-L425 |
loli/medpy | medpy/filter/image.py | resample | def resample(img, hdr, target_spacing, bspline_order=3, mode='constant'):
"""
Re-sample an image to a new voxel-spacing.
Parameters
----------
img : array_like
The image.
hdr : object
The image header.
target_spacing : number or se... | python | def resample(img, hdr, target_spacing, bspline_order=3, mode='constant'):
"""
Re-sample an image to a new voxel-spacing.
Parameters
----------
img : array_like
The image.
hdr : object
The image header.
target_spacing : number or se... | [
"def",
"resample",
"(",
"img",
",",
"hdr",
",",
"target_spacing",
",",
"bspline_order",
"=",
"3",
",",
"mode",
"=",
"'constant'",
")",
":",
"if",
"isinstance",
"(",
"target_spacing",
",",
"numbers",
".",
"Number",
")",
":",
"target_spacing",
"=",
"[",
"t... | Re-sample an image to a new voxel-spacing.
Parameters
----------
img : array_like
The image.
hdr : object
The image header.
target_spacing : number or sequence of numbers
The target voxel spacing to achieve. If a single number, isotrop... | [
"Re",
"-",
"sample",
"an",
"image",
"to",
"a",
"new",
"voxel",
"-",
"spacing",
".",
"Parameters",
"----------",
"img",
":",
"array_like",
"The",
"image",
".",
"hdr",
":",
"object",
"The",
"image",
"header",
".",
"target_spacing",
":",
"number",
"or",
"se... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L427-L467 |
loli/medpy | medpy/features/histogram.py | fuzzy_histogram | def fuzzy_histogram(a, bins=10, range=None, normed=False, membership='triangular', smoothness=None, guarantee=False):
r"""Compute a fuzzy histogram.
The percentage of a value's membership in a bin is computed using the selected
membership function. This functions stays as near as possible to the `numpy.hist... | python | def fuzzy_histogram(a, bins=10, range=None, normed=False, membership='triangular', smoothness=None, guarantee=False):
r"""Compute a fuzzy histogram.
The percentage of a value's membership in a bin is computed using the selected
membership function. This functions stays as near as possible to the `numpy.hist... | [
"def",
"fuzzy_histogram",
"(",
"a",
",",
"bins",
"=",
"10",
",",
"range",
"=",
"None",
",",
"normed",
"=",
"False",
",",
"membership",
"=",
"'triangular'",
",",
"smoothness",
"=",
"None",
",",
"guarantee",
"=",
"False",
")",
":",
"# check and prepare param... | r"""Compute a fuzzy histogram.
The percentage of a value's membership in a bin is computed using the selected
membership function. This functions stays as near as possible to the `numpy.histogram`
behaviour.
Parameters
----------
a : array_like
Input data; The histogram is computed ... | [
"r",
"Compute",
"a",
"fuzzy",
"histogram",
".",
"The",
"percentage",
"of",
"a",
"value",
"s",
"membership",
"in",
"a",
"bin",
"is",
"computed",
"using",
"the",
"selected",
"membership",
"function",
".",
"This",
"functions",
"stays",
"as",
"near",
"as",
"po... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/histogram.py#L34-L134 |
loli/medpy | medpy/features/histogram.py | triangular_membership | def triangular_membership(bin_center, bin_width, smoothness = 0.5):
r"""
Create a triangular membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The wid... | python | def triangular_membership(bin_center, bin_width, smoothness = 0.5):
r"""
Create a triangular membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The wid... | [
"def",
"triangular_membership",
"(",
"bin_center",
",",
"bin_width",
",",
"smoothness",
"=",
"0.5",
")",
":",
"if",
"smoothness",
">",
"0.5",
":",
"raise",
"AttributeError",
"(",
"'the triangular/trapezium membership functions supports only smoothnesses between 1/10 and 1/2.'... | r"""
Create a triangular membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The width of a single bin (all expected to be of equal width).
smoothness :... | [
"r",
"Create",
"a",
"triangular",
"membership",
"function",
"for",
"a",
"fuzzy",
"histogram",
"bin",
".",
"Parameters",
"----------",
"bin_center",
":",
"number",
"The",
"center",
"of",
"the",
"bin",
"of",
"which",
"to",
"compute",
"the",
"membership",
"functi... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/histogram.py#L141-L203 |
loli/medpy | medpy/features/histogram.py | gaussian_membership | def gaussian_membership(bin_center, bin_width, smoothness):
r"""Create a gaussian membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The width of a single ... | python | def gaussian_membership(bin_center, bin_width, smoothness):
r"""Create a gaussian membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The width of a single ... | [
"def",
"gaussian_membership",
"(",
"bin_center",
",",
"bin_width",
",",
"smoothness",
")",
":",
"if",
"smoothness",
">",
"10",
"or",
"smoothness",
"<",
"1.",
"/",
"10",
":",
"raise",
"AttributeError",
"(",
"'the gaussian membership function supports only smoothnesses ... | r"""Create a gaussian membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The width of a single bin (all expected to be of equal width).
smoothness : number... | [
"r",
"Create",
"a",
"gaussian",
"membership",
"function",
"for",
"a",
"fuzzy",
"histogram",
"bin",
".",
"Parameters",
"----------",
"bin_center",
":",
"number",
"The",
"center",
"of",
"the",
"bin",
"of",
"which",
"to",
"compute",
"the",
"membership",
"function... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/histogram.py#L289-L359 |
loli/medpy | medpy/features/histogram.py | _gaussian_membership_sigma | def _gaussian_membership_sigma(smoothness, eps = 0.0005): # 275us @ smothness=10
r"""Compute the sigma required for a gaussian, such that in a neighbourhood of
smoothness the maximum error is 'eps'.
The error is here the difference between the clipped integral and one.
"""
error = 0
deltas = [0.... | python | def _gaussian_membership_sigma(smoothness, eps = 0.0005): # 275us @ smothness=10
r"""Compute the sigma required for a gaussian, such that in a neighbourhood of
smoothness the maximum error is 'eps'.
The error is here the difference between the clipped integral and one.
"""
error = 0
deltas = [0.... | [
"def",
"_gaussian_membership_sigma",
"(",
"smoothness",
",",
"eps",
"=",
"0.0005",
")",
":",
"# 275us @ smothness=10",
"error",
"=",
"0",
"deltas",
"=",
"[",
"0.1",
",",
"0.01",
",",
"0.001",
",",
"0.0001",
"]",
"sigma",
"=",
"smoothness",
"*",
"0.3",
"poi... | r"""Compute the sigma required for a gaussian, such that in a neighbourhood of
smoothness the maximum error is 'eps'.
The error is here the difference between the clipped integral and one. | [
"r",
"Compute",
"the",
"sigma",
"required",
"for",
"a",
"gaussian",
"such",
"that",
"in",
"a",
"neighbourhood",
"of",
"smoothness",
"the",
"maximum",
"error",
"is",
"eps",
".",
"The",
"error",
"is",
"here",
"the",
"difference",
"between",
"the",
"clipped",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/histogram.py#L361-L375 |
loli/medpy | medpy/features/histogram.py | sigmoidal_difference_membership | def sigmoidal_difference_membership(bin_center, bin_width, smoothness):
r"""Create the difference of two sigmoids as membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : nu... | python | def sigmoidal_difference_membership(bin_center, bin_width, smoothness):
r"""Create the difference of two sigmoids as membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : nu... | [
"def",
"sigmoidal_difference_membership",
"(",
"bin_center",
",",
"bin_width",
",",
"smoothness",
")",
":",
"if",
"smoothness",
">",
"10",
"or",
"smoothness",
"<",
"1.",
"/",
"10",
":",
"raise",
"AttributeError",
"(",
"'the sigmoidal membership function supports only ... | r"""Create the difference of two sigmoids as membership function for a fuzzy histogram bin.
Parameters
----------
bin_center : number
The center of the bin of which to compute the membership function.
bin_width : number
The width of a single bin (all expected to be of equal width).
... | [
"r",
"Create",
"the",
"difference",
"of",
"two",
"sigmoids",
"as",
"membership",
"function",
"for",
"a",
"fuzzy",
"histogram",
"bin",
".",
"Parameters",
"----------",
"bin_center",
":",
"number",
"The",
"center",
"of",
"the",
"bin",
"of",
"which",
"to",
"com... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/histogram.py#L377-L447 |
loli/medpy | medpy/filter/noise.py | immerkaer_local | def immerkaer_local(input, size, output=None, mode="reflect", cval=0.0):
r"""
Estimate the local noise.
The input image is assumed to have additive zero mean Gaussian noise. The Immerkaer
noise estimation is applied to the image locally over a N-dimensional cube of
side-length size. The size of... | python | def immerkaer_local(input, size, output=None, mode="reflect", cval=0.0):
r"""
Estimate the local noise.
The input image is assumed to have additive zero mean Gaussian noise. The Immerkaer
noise estimation is applied to the image locally over a N-dimensional cube of
side-length size. The size of... | [
"def",
"immerkaer_local",
"(",
"input",
",",
"size",
",",
"output",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
")",
":",
"output",
"=",
"_ni_support",
".",
"_get_output",
"(",
"output",
",",
"input",
")",
"footprint",
"=",
"... | r"""
Estimate the local noise.
The input image is assumed to have additive zero mean Gaussian noise. The Immerkaer
noise estimation is applied to the image locally over a N-dimensional cube of
side-length size. The size of the region should be sufficiently high for a stable
noise estimation.
... | [
"r",
"Estimate",
"the",
"local",
"noise",
".",
"The",
"input",
"image",
"is",
"assumed",
"to",
"have",
"additive",
"zero",
"mean",
"Gaussian",
"noise",
".",
"The",
"Immerkaer",
"noise",
"estimation",
"is",
"applied",
"to",
"the",
"image",
"locally",
"over",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/noise.py#L31-L91 |
loli/medpy | medpy/filter/noise.py | immerkaer | def immerkaer(input, mode="reflect", cval=0.0):
r"""
Estimate the global noise.
The input image is assumed to have additive zero mean Gaussian noise. Using a
convolution with a Laplacian operator and a subsequent averaging the standard
deviation sigma of this noise is estimated. This estimation... | python | def immerkaer(input, mode="reflect", cval=0.0):
r"""
Estimate the global noise.
The input image is assumed to have additive zero mean Gaussian noise. Using a
convolution with a Laplacian operator and a subsequent averaging the standard
deviation sigma of this noise is estimated. This estimation... | [
"def",
"immerkaer",
"(",
"input",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
")",
":",
"# build nd-kernel to acquire square root of sum of squared elements",
"kernel",
"=",
"[",
"1",
",",
"-",
"2",
",",
"1",
"]",
"for",
"_",
"in",
"range",
"("... | r"""
Estimate the global noise.
The input image is assumed to have additive zero mean Gaussian noise. Using a
convolution with a Laplacian operator and a subsequent averaging the standard
deviation sigma of this noise is estimated. This estimation is global i.e. the
noise is assumed to be globa... | [
"r",
"Estimate",
"the",
"global",
"noise",
".",
"The",
"input",
"image",
"is",
"assumed",
"to",
"have",
"additive",
"zero",
"mean",
"Gaussian",
"noise",
".",
"Using",
"a",
"convolution",
"with",
"a",
"Laplacian",
"operator",
"and",
"a",
"subsequent",
"averag... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/noise.py#L93-L166 |
loli/medpy | medpy/filter/noise.py | separable_convolution | def separable_convolution(input, weights, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculate a n-dimensional convolution of a separable kernel to a n-dimensional input.
Achieved by calling convolution1d along the first axis, obtaining an intermediate
image, on which the next convoluti... | python | def separable_convolution(input, weights, output=None, mode="reflect", cval=0.0, origin=0):
r"""
Calculate a n-dimensional convolution of a separable kernel to a n-dimensional input.
Achieved by calling convolution1d along the first axis, obtaining an intermediate
image, on which the next convoluti... | [
"def",
"separable_convolution",
"(",
"input",
",",
"weights",
",",
"output",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
",",
"origin",
"=",
"0",
")",
":",
"input",
"=",
"numpy",
".",
"asarray",
"(",
"input",
")",
"output",
... | r"""
Calculate a n-dimensional convolution of a separable kernel to a n-dimensional input.
Achieved by calling convolution1d along the first axis, obtaining an intermediate
image, on which the next convolution1d along the second axis is called and so on.
Parameters
----------
input : a... | [
"r",
"Calculate",
"a",
"n",
"-",
"dimensional",
"convolution",
"of",
"a",
"separable",
"kernel",
"to",
"a",
"n",
"-",
"dimensional",
"input",
".",
"Achieved",
"by",
"calling",
"convolution1d",
"along",
"the",
"first",
"axis",
"obtaining",
"an",
"intermediate",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/noise.py#L168-L209 |
loli/medpy | doc/numpydoc/numpydoc/plot_directive.py | split_code_at_show | def split_code_at_show(text):
"""
Split code at plt.show()
"""
parts = []
is_doctest = contains_doctest(text)
part = []
for line in text.split("\n"):
if (not is_doctest and line.strip() == 'plt.show()') or \
(is_doctest and line.strip() == '>>> plt.show()'):
... | python | def split_code_at_show(text):
"""
Split code at plt.show()
"""
parts = []
is_doctest = contains_doctest(text)
part = []
for line in text.split("\n"):
if (not is_doctest and line.strip() == 'plt.show()') or \
(is_doctest and line.strip() == '>>> plt.show()'):
... | [
"def",
"split_code_at_show",
"(",
"text",
")",
":",
"parts",
"=",
"[",
"]",
"is_doctest",
"=",
"contains_doctest",
"(",
"text",
")",
"part",
"=",
"[",
"]",
"for",
"line",
"in",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"if",
"(",
"not",
"is_doc... | Split code at plt.show() | [
"Split",
"code",
"at",
"plt",
".",
"show",
"()"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/plot_directive.py#L416-L436 |
loli/medpy | doc/numpydoc/numpydoc/plot_directive.py | out_of_date | def out_of_date(original, derived):
"""
Returns True if derivative is out-of-date wrt original,
both of which are full file paths.
"""
return (not os.path.exists(derived)
or os.stat(derived).st_mtime < os.stat(original).st_mtime) | python | def out_of_date(original, derived):
"""
Returns True if derivative is out-of-date wrt original,
both of which are full file paths.
"""
return (not os.path.exists(derived)
or os.stat(derived).st_mtime < os.stat(original).st_mtime) | [
"def",
"out_of_date",
"(",
"original",
",",
"derived",
")",
":",
"return",
"(",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"derived",
")",
"or",
"os",
".",
"stat",
"(",
"derived",
")",
".",
"st_mtime",
"<",
"os",
".",
"stat",
"(",
"original",
")... | Returns True if derivative is out-of-date wrt original,
both of which are full file paths. | [
"Returns",
"True",
"if",
"derivative",
"is",
"out",
"-",
"of",
"-",
"date",
"wrt",
"original",
"both",
"of",
"which",
"are",
"full",
"file",
"paths",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/plot_directive.py#L481-L487 |
loli/medpy | doc/numpydoc/numpydoc/plot_directive.py | makefig | def makefig(code, code_path, output_dir, output_base, config):
"""
Run a pyplot script *code* and save the images under *output_dir*
with file names derived from *output_base*
"""
# -- Parse format list
default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 50}
formats = []
for fmt in conf... | python | def makefig(code, code_path, output_dir, output_base, config):
"""
Run a pyplot script *code* and save the images under *output_dir*
with file names derived from *output_base*
"""
# -- Parse format list
default_dpi = {'png': 80, 'hires.png': 200, 'pdf': 50}
formats = []
for fmt in conf... | [
"def",
"makefig",
"(",
"code",
",",
"code_path",
",",
"output_dir",
",",
"output_base",
",",
"config",
")",
":",
"# -- Parse format list",
"default_dpi",
"=",
"{",
"'png'",
":",
"80",
",",
"'hires.png'",
":",
"200",
",",
"'pdf'",
":",
"50",
"}",
"formats",... | Run a pyplot script *code* and save the images under *output_dir*
with file names derived from *output_base* | [
"Run",
"a",
"pyplot",
"script",
"*",
"code",
"*",
"and",
"save",
"the",
"images",
"under",
"*",
"output_dir",
"*",
"with",
"file",
"names",
"derived",
"from",
"*",
"output_base",
"*"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/plot_directive.py#L490-L581 |
loli/medpy | medpy/io/save.py | save | def save(arr, filename, hdr = False, force = True, use_compression = False):
r"""
Save the image ``arr`` as filename using information encoded in ``hdr``. The target image
format is determined by the ``filename`` suffix. If the ``force`` parameter is set to true,
an already existing image is overwritten... | python | def save(arr, filename, hdr = False, force = True, use_compression = False):
r"""
Save the image ``arr`` as filename using information encoded in ``hdr``. The target image
format is determined by the ``filename`` suffix. If the ``force`` parameter is set to true,
an already existing image is overwritten... | [
"def",
"save",
"(",
"arr",
",",
"filename",
",",
"hdr",
"=",
"False",
",",
"force",
"=",
"True",
",",
"use_compression",
"=",
"False",
")",
":",
"logger",
"=",
"Logger",
".",
"getInstance",
"(",
")",
"logger",
".",
"info",
"(",
"'Saving image as {}...'",... | r"""
Save the image ``arr`` as filename using information encoded in ``hdr``. The target image
format is determined by the ``filename`` suffix. If the ``force`` parameter is set to true,
an already existing image is overwritten silently. Otherwise an error is thrown.
The header (``hdr``) object is ... | [
"r",
"Save",
"the",
"image",
"arr",
"as",
"filename",
"using",
"information",
"encoded",
"in",
"hdr",
".",
"The",
"target",
"image",
"format",
"is",
"determined",
"by",
"the",
"filename",
"suffix",
".",
"If",
"the",
"force",
"parameter",
"is",
"set",
"to",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/save.py#L33-L120 |
loli/medpy | bin/medpy_extract_sub_volume.py | getArguments | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
# parse volume and adapt to zero-indexing
try:
def _to_int_or_none(string):
if 0 == len(string): return None
return int(string)
def _to_in... | python | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
# parse volume and adapt to zero-indexing
try:
def _to_int_or_none(string):
if 0 == len(string): return None
return int(string)
def _to_in... | [
"def",
"getArguments",
"(",
"parser",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"# parse volume and adapt to zero-indexing",
"try",
":",
"def",
"_to_int_or_none",
"(",
"string",
")",
":",
"if",
"0",
"==",
"len",
"(",
"string",
")",
":",
... | Provides additional validation of the arguments collected by argparse. | [
"Provides",
"additional",
"validation",
"of",
"the",
"arguments",
"collected",
"by",
"argparse",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_extract_sub_volume.py#L113-L129 |
loli/medpy | medpy/features/texture.py | coarseness | def coarseness(image, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the coarseness of the texture.
Step1 At each pixel, compute six averages for the windows of size 2**k x 2**k,
k=0,1,...,5, around the pixel.
Step2 At each pixel, co... | python | def coarseness(image, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the coarseness of the texture.
Step1 At each pixel, compute six averages for the windows of size 2**k x 2**k,
k=0,1,...,5, around the pixel.
Step2 At each pixel, co... | [
"def",
"coarseness",
"(",
"image",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"# Step1: At each pixel (x,y), compute six averages for the windows",
"# of size 2**k x 2**k, k=0,1,...,5, around the pixel.",
"image",
"=",
"numpy",... | r"""
Takes a simple or multi-spectral image and returns the coarseness of the texture.
Step1 At each pixel, compute six averages for the windows of size 2**k x 2**k,
k=0,1,...,5, around the pixel.
Step2 At each pixel, compute absolute differences E between the pairs of non
o... | [
"r",
"Takes",
"a",
"simple",
"or",
"multi",
"-",
"spectral",
"image",
"and",
"returns",
"the",
"coarseness",
"of",
"the",
"texture",
".",
"Step1",
"At",
"each",
"pixel",
"compute",
"six",
"averages",
"for",
"the",
"windows",
"of",
"size",
"2",
"**",
"k",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L33-L126 |
loli/medpy | medpy/features/texture.py | contrast | def contrast(image, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the contrast of the texture.
Fcon = standard_deviation(gray_value) / (kurtosis(gray_value)**0.25)
Parameters
----------
image : array_like or list/tuple of array_like
A single imag... | python | def contrast(image, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the contrast of the texture.
Fcon = standard_deviation(gray_value) / (kurtosis(gray_value)**0.25)
Parameters
----------
image : array_like or list/tuple of array_like
A single imag... | [
"def",
"contrast",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"image",
"=",
"numpy",
".",
"asarray",
"(",
"image",
")",
"# set default mask or apply given mask",
"if",
"not",
"type",
"(",
"mask",
")",
"is",
"slice",
":",
"if",
... | r"""
Takes a simple or multi-spectral image and returns the contrast of the texture.
Fcon = standard_deviation(gray_value) / (kurtosis(gray_value)**0.25)
Parameters
----------
image : array_like or list/tuple of array_like
A single image or a list/tuple of images (for multi-spectr... | [
"r",
"Takes",
"a",
"simple",
"or",
"multi",
"-",
"spectral",
"image",
"and",
"returns",
"the",
"contrast",
"of",
"the",
"texture",
".",
"Fcon",
"=",
"standard_deviation",
"(",
"gray_value",
")",
"/",
"(",
"kurtosis",
"(",
"gray_value",
")",
"**",
"0",
".... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L128-L164 |
loli/medpy | medpy/features/texture.py | directionality | def directionality(image, min_distance = 4, threshold = 0.1, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the directionality of the image texture.
It is just a value representing the strength of directionality, not the specific direction.
An edg... | python | def directionality(image, min_distance = 4, threshold = 0.1, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the directionality of the image texture.
It is just a value representing the strength of directionality, not the specific direction.
An edg... | [
"def",
"directionality",
"(",
"image",
",",
"min_distance",
"=",
"4",
",",
"threshold",
"=",
"0.1",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"image",
"=",
"numpy",
".",
"asarray",
"(",
"image",
")",
"nd... | r"""
Takes a simple or multi-spectral image and returns the directionality of the image texture.
It is just a value representing the strength of directionality, not the specific direction.
An edge detection is applied on the image. Then the edge strength and directional angle between
the image axi... | [
"r",
"Takes",
"a",
"simple",
"or",
"multi",
"-",
"spectral",
"image",
"and",
"returns",
"the",
"directionality",
"of",
"the",
"image",
"texture",
".",
"It",
"is",
"just",
"a",
"value",
"representing",
"the",
"strength",
"of",
"directionality",
"not",
"the",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L166-L265 |
loli/medpy | medpy/features/texture.py | local_maxima | def local_maxima(vector,min_distance = 4, brd_mode = "wrap"):
"""
Internal finder for local maxima .
Returns UNSORTED indices of maxima in input vector.
"""
fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode)
for ii in range(len(fits)):
if fits[ii] == fits... | python | def local_maxima(vector,min_distance = 4, brd_mode = "wrap"):
"""
Internal finder for local maxima .
Returns UNSORTED indices of maxima in input vector.
"""
fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode)
for ii in range(len(fits)):
if fits[ii] == fits... | [
"def",
"local_maxima",
"(",
"vector",
",",
"min_distance",
"=",
"4",
",",
"brd_mode",
"=",
"\"wrap\"",
")",
":",
"fits",
"=",
"gaussian_filter",
"(",
"numpy",
".",
"asarray",
"(",
"vector",
",",
"dtype",
"=",
"numpy",
".",
"float32",
")",
",",
"1.",
",... | Internal finder for local maxima .
Returns UNSORTED indices of maxima in input vector. | [
"Internal",
"finder",
"for",
"local",
"maxima",
".",
"Returns",
"UNSORTED",
"indices",
"of",
"maxima",
"in",
"input",
"vector",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L268-L280 |
loli/medpy | medpy/features/texture.py | local_minima | def local_minima(vector,min_distance = 4, brd_mode = "wrap"):
"""
Internal finder for local minima .
Returns UNSORTED indices of minima in input vector.
"""
fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode)
for ii in range(len(fits)):
if fits[ii] == fits... | python | def local_minima(vector,min_distance = 4, brd_mode = "wrap"):
"""
Internal finder for local minima .
Returns UNSORTED indices of minima in input vector.
"""
fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode)
for ii in range(len(fits)):
if fits[ii] == fits... | [
"def",
"local_minima",
"(",
"vector",
",",
"min_distance",
"=",
"4",
",",
"brd_mode",
"=",
"\"wrap\"",
")",
":",
"fits",
"=",
"gaussian_filter",
"(",
"numpy",
".",
"asarray",
"(",
"vector",
",",
"dtype",
"=",
"numpy",
".",
"float32",
")",
",",
"1.",
",... | Internal finder for local minima .
Returns UNSORTED indices of minima in input vector. | [
"Internal",
"finder",
"for",
"local",
"minima",
".",
"Returns",
"UNSORTED",
"indices",
"of",
"minima",
"in",
"input",
"vector",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L282-L294 |
loli/medpy | medpy/features/texture.py | find_valley_range | def find_valley_range(vector, min_distance = 4):
"""
Internal finder peaks and valley ranges.
Returns UNSORTED indices of maxima in input vector.
Returns range of valleys before and after maximum
"""
# http://users.monash.edu.au/~dengs/resource/papers/icme08.pdf
# find min and max with ... | python | def find_valley_range(vector, min_distance = 4):
"""
Internal finder peaks and valley ranges.
Returns UNSORTED indices of maxima in input vector.
Returns range of valleys before and after maximum
"""
# http://users.monash.edu.au/~dengs/resource/papers/icme08.pdf
# find min and max with ... | [
"def",
"find_valley_range",
"(",
"vector",
",",
"min_distance",
"=",
"4",
")",
":",
"# http://users.monash.edu.au/~dengs/resource/papers/icme08.pdf",
"# find min and max with mode = wrap",
"mode",
"=",
"\"wrap\"",
"minima",
"=",
"local_minima",
"(",
"vector",
",",
"min_dist... | Internal finder peaks and valley ranges.
Returns UNSORTED indices of maxima in input vector.
Returns range of valleys before and after maximum | [
"Internal",
"finder",
"peaks",
"and",
"valley",
"ranges",
".",
"Returns",
"UNSORTED",
"indices",
"of",
"maxima",
"in",
"input",
"vector",
".",
"Returns",
"range",
"of",
"valleys",
"before",
"and",
"after",
"maximum"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L296-L324 |
loli/medpy | bin/medpy_fit_into_shape.py | getParser | def getParser():
"Creates and returns the argparse parser object."
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__description__)
parser.add_argument('input', help='the input image')
parser.add_argument('output', help='the output image')
parser.ad... | python | def getParser():
"Creates and returns the argparse parser object."
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__description__)
parser.add_argument('input', help='the input image')
parser.add_argument('output', help='the output image')
parser.ad... | [
"def",
"getParser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
",",
"description",
"=",
"__description__",
")",
"parser",
".",
"add_argument",
"(",
"'input'",
",",
... | Creates and returns the argparse parser object. | [
"Creates",
"and",
"returns",
"the",
"argparse",
"parser",
"object",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_fit_into_shape.py#L106-L116 |
loli/medpy | medpy/filter/smoothing.py | gauss_xminus1d | def gauss_xminus1d(img, sigma, dim=2):
r"""
Applies a X-1D gauss to a copy of a XD image, slicing it along dim.
Essentially uses `scipy.ndimage.filters.gaussian_filter`, but
applies it to a dimension less than the image has.
Parameters
----------
img : array_like
The image to smoot... | python | def gauss_xminus1d(img, sigma, dim=2):
r"""
Applies a X-1D gauss to a copy of a XD image, slicing it along dim.
Essentially uses `scipy.ndimage.filters.gaussian_filter`, but
applies it to a dimension less than the image has.
Parameters
----------
img : array_like
The image to smoot... | [
"def",
"gauss_xminus1d",
"(",
"img",
",",
"sigma",
",",
"dim",
"=",
"2",
")",
":",
"img",
"=",
"numpy",
".",
"array",
"(",
"img",
",",
"copy",
"=",
"False",
")",
"return",
"xminus1d",
"(",
"img",
",",
"gaussian_filter",
",",
"dim",
",",
"sigma",
"=... | r"""
Applies a X-1D gauss to a copy of a XD image, slicing it along dim.
Essentially uses `scipy.ndimage.filters.gaussian_filter`, but
applies it to a dimension less than the image has.
Parameters
----------
img : array_like
The image to smooth.
sigma : integer
The sigma i.... | [
"r",
"Applies",
"a",
"X",
"-",
"1D",
"gauss",
"to",
"a",
"copy",
"of",
"a",
"XD",
"image",
"slicing",
"it",
"along",
"dim",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/smoothing.py#L34-L56 |
loli/medpy | medpy/filter/smoothing.py | anisotropic_diffusion | def anisotropic_diffusion(img, niter=1, kappa=50, gamma=0.1, voxelspacing=None, option=1):
r"""
Edge-preserving, XD Anisotropic diffusion.
Parameters
----------
img : array_like
Input image (will be cast to numpy.float).
niter : integer
Number of iterations.
kappa : integer... | python | def anisotropic_diffusion(img, niter=1, kappa=50, gamma=0.1, voxelspacing=None, option=1):
r"""
Edge-preserving, XD Anisotropic diffusion.
Parameters
----------
img : array_like
Input image (will be cast to numpy.float).
niter : integer
Number of iterations.
kappa : integer... | [
"def",
"anisotropic_diffusion",
"(",
"img",
",",
"niter",
"=",
"1",
",",
"kappa",
"=",
"50",
",",
"gamma",
"=",
"0.1",
",",
"voxelspacing",
"=",
"None",
",",
"option",
"=",
"1",
")",
":",
"# define conduction gradients functions",
"if",
"option",
"==",
"1"... | r"""
Edge-preserving, XD Anisotropic diffusion.
Parameters
----------
img : array_like
Input image (will be cast to numpy.float).
niter : integer
Number of iterations.
kappa : integer
Conduction coefficient, e.g. 20-100. ``kappa`` controls conduction
as a functi... | [
"r",
"Edge",
"-",
"preserving",
"XD",
"Anisotropic",
"diffusion",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/smoothing.py#L58-L169 |
loli/medpy | medpy/features/utilities.py | normalize | def normalize(vector, cutoffp = (0, 100), model = False):
r"""
Returns a feature-wise normalized version of the supplied vector. Normalization is
achieved to [0,1] over the complete vector using shifting and scaling.
When cut-off percentile (cutoffp) values other than (0, 100) are supplied, the val... | python | def normalize(vector, cutoffp = (0, 100), model = False):
r"""
Returns a feature-wise normalized version of the supplied vector. Normalization is
achieved to [0,1] over the complete vector using shifting and scaling.
When cut-off percentile (cutoffp) values other than (0, 100) are supplied, the val... | [
"def",
"normalize",
"(",
"vector",
",",
"cutoffp",
"=",
"(",
"0",
",",
"100",
")",
",",
"model",
"=",
"False",
")",
":",
"vector",
"=",
"numpy",
".",
"array",
"(",
"vector",
",",
"dtype",
"=",
"numpy",
".",
"float",
")",
"# add a singleton dimension if... | r"""
Returns a feature-wise normalized version of the supplied vector. Normalization is
achieved to [0,1] over the complete vector using shifting and scaling.
When cut-off percentile (cutoffp) values other than (0, 100) are supplied, the values
lying before or behind the supplied percentiles are cu... | [
"r",
"Returns",
"a",
"feature",
"-",
"wise",
"normalized",
"version",
"of",
"the",
"supplied",
"vector",
".",
"Normalization",
"is",
"achieved",
"to",
"[",
"0",
"1",
"]",
"over",
"the",
"complete",
"vector",
"using",
"shifting",
"and",
"scaling",
".",
"Whe... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/utilities.py#L31-L103 |
loli/medpy | medpy/features/utilities.py | normalize_with_model | def normalize_with_model(vector, model):
r"""
Normalize as with `normalize`, but not based on the data of the passed feature
vector, but rather on a learned model created with `normalize`. Thus formerly
unseen query data can be normalized according to the training data.
Parameters
---------... | python | def normalize_with_model(vector, model):
r"""
Normalize as with `normalize`, but not based on the data of the passed feature
vector, but rather on a learned model created with `normalize`. Thus formerly
unseen query data can be normalized according to the training data.
Parameters
---------... | [
"def",
"normalize_with_model",
"(",
"vector",
",",
"model",
")",
":",
"vector",
"=",
"numpy",
".",
"array",
"(",
"vector",
",",
"dtype",
"=",
"numpy",
".",
"float",
")",
"# unpack model",
"minp",
",",
"maxp",
",",
"minv",
",",
"maxv",
"=",
"model",
"# ... | r"""
Normalize as with `normalize`, but not based on the data of the passed feature
vector, but rather on a learned model created with `normalize`. Thus formerly
unseen query data can be normalized according to the training data.
Parameters
----------
vector : sequence
A sequence of... | [
"r",
"Normalize",
"as",
"with",
"normalize",
"but",
"not",
"based",
"on",
"the",
"data",
"of",
"the",
"passed",
"feature",
"vector",
"but",
"rather",
"on",
"a",
"learned",
"model",
"created",
"with",
"normalize",
".",
"Thus",
"formerly",
"unseen",
"query",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/utilities.py#L105-L141 |
loli/medpy | medpy/features/utilities.py | append | def append(*vectors):
r"""
Takes an arbitrary number of vectors containing features and append them
(horizontally).
E.g. taking a 100 and a 200 sample vector with 7 features each, a 300x7
vector is returned.
The vectors are expected to have the form samples*features i.e.::
... | python | def append(*vectors):
r"""
Takes an arbitrary number of vectors containing features and append them
(horizontally).
E.g. taking a 100 and a 200 sample vector with 7 features each, a 300x7
vector is returned.
The vectors are expected to have the form samples*features i.e.::
... | [
"def",
"append",
"(",
"*",
"vectors",
")",
":",
"# check supplied arguments",
"if",
"len",
"(",
"vectors",
")",
"<",
"2",
":",
"return",
"vectors",
"[",
"0",
"]",
"# process supplied arguments",
"vectors",
"=",
"list",
"(",
"vectors",
")",
"for",
"i",
"in"... | r"""
Takes an arbitrary number of vectors containing features and append them
(horizontally).
E.g. taking a 100 and a 200 sample vector with 7 features each, a 300x7
vector is returned.
The vectors are expected to have the form samples*features i.e.::
s1 s2 s3 [..... | [
"r",
"Takes",
"an",
"arbitrary",
"number",
"of",
"vectors",
"containing",
"features",
"and",
"append",
"them",
"(",
"horizontally",
")",
".",
"E",
".",
"g",
".",
"taking",
"a",
"100",
"and",
"a",
"200",
"sample",
"vector",
"with",
"7",
"features",
"each"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/utilities.py#L143-L179 |
loli/medpy | medpy/features/utilities.py | join | def join(*vectors):
r"""
Takes an arbitrary number of aligned vectors of the same length and combines
them into a single vector (vertically).
E.g. taking two 100-sample feature vectors of once 5 and once 7 features, a 100x12
feature vector is created and returned.
The feature vectors ... | python | def join(*vectors):
r"""
Takes an arbitrary number of aligned vectors of the same length and combines
them into a single vector (vertically).
E.g. taking two 100-sample feature vectors of once 5 and once 7 features, a 100x12
feature vector is created and returned.
The feature vectors ... | [
"def",
"join",
"(",
"*",
"vectors",
")",
":",
"# check supplied arguments",
"if",
"len",
"(",
"vectors",
")",
"<",
"2",
":",
"return",
"vectors",
"[",
"0",
"]",
"# process supplied arguments",
"vectors",
"=",
"list",
"(",
"vectors",
")",
"for",
"i",
"in",
... | r"""
Takes an arbitrary number of aligned vectors of the same length and combines
them into a single vector (vertically).
E.g. taking two 100-sample feature vectors of once 5 and once 7 features, a 100x12
feature vector is created and returned.
The feature vectors are expected to have the... | [
"r",
"Takes",
"an",
"arbitrary",
"number",
"of",
"aligned",
"vectors",
"of",
"the",
"same",
"length",
"and",
"combines",
"them",
"into",
"a",
"single",
"vector",
"(",
"vertically",
")",
".",
"E",
".",
"g",
".",
"taking",
"two",
"100",
"-",
"sample",
"f... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/utilities.py#L181-L221 |
loli/medpy | medpy/graphcut/generate.py | graph_from_voxels | def graph_from_voxels(fg_markers,
bg_markers,
regional_term = False,
boundary_term = False,
regional_term_args = False,
boundary_term_args = False):
"""
Create a graph-cut ready graph to segme... | python | def graph_from_voxels(fg_markers,
bg_markers,
regional_term = False,
boundary_term = False,
regional_term_args = False,
boundary_term_args = False):
"""
Create a graph-cut ready graph to segme... | [
"def",
"graph_from_voxels",
"(",
"fg_markers",
",",
"bg_markers",
",",
"regional_term",
"=",
"False",
",",
"boundary_term",
"=",
"False",
",",
"regional_term_args",
"=",
"False",
",",
"boundary_term_args",
"=",
"False",
")",
":",
"# prepare logger",
"logger",
"=",... | Create a graph-cut ready graph to segment a nD image using the voxel neighbourhood.
Create a `~medpy.graphcut.maxflow.GraphDouble` object for all voxels of an image with a
:math:`ndim * 2` neighbourhood.
Every voxel of the image is regarded as a node. They are connected to their immediate
neig... | [
"Create",
"a",
"graph",
"-",
"cut",
"ready",
"graph",
"to",
"segment",
"a",
"nD",
"image",
"using",
"the",
"voxel",
"neighbourhood",
".",
"Create",
"a",
"~medpy",
".",
"graphcut",
".",
"maxflow",
".",
"GraphDouble",
"object",
"for",
"all",
"voxels",
"of",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/generate.py#L32-L153 |
loli/medpy | medpy/graphcut/generate.py | graph_from_labels | def graph_from_labels(label_image,
fg_markers,
bg_markers,
regional_term = False,
boundary_term = False,
regional_term_args = False,
boundary_term_args = False):
"""
Cr... | python | def graph_from_labels(label_image,
fg_markers,
bg_markers,
regional_term = False,
boundary_term = False,
regional_term_args = False,
boundary_term_args = False):
"""
Cr... | [
"def",
"graph_from_labels",
"(",
"label_image",
",",
"fg_markers",
",",
"bg_markers",
",",
"regional_term",
"=",
"False",
",",
"boundary_term",
"=",
"False",
",",
"regional_term_args",
"=",
"False",
",",
"boundary_term_args",
"=",
"False",
")",
":",
"# prepare log... | Create a graph-cut ready graph to segment a nD image using the region neighbourhood.
Create a `~medpy.graphcut.maxflow.GraphDouble` object for all regions of a nD label
image.
Every region of the label image is regarded as a node. They are connected to their
immediate neighbours by arcs. If to... | [
"Create",
"a",
"graph",
"-",
"cut",
"ready",
"graph",
"to",
"segment",
"a",
"nD",
"image",
"using",
"the",
"region",
"neighbourhood",
".",
"Create",
"a",
"~medpy",
".",
"graphcut",
".",
"maxflow",
".",
"GraphDouble",
"object",
"for",
"all",
"regions",
"of"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/generate.py#L155-L296 |
loli/medpy | medpy/graphcut/generate.py | __voxel_4conectedness | def __voxel_4conectedness(shape):
"""
Returns the number of edges for the supplied image shape assuming 4-connectedness.
The name of the function has historical reasons. Essentially it returns the number
of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness,
etc.
... | python | def __voxel_4conectedness(shape):
"""
Returns the number of edges for the supplied image shape assuming 4-connectedness.
The name of the function has historical reasons. Essentially it returns the number
of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness,
etc.
... | [
"def",
"__voxel_4conectedness",
"(",
"shape",
")",
":",
"shape",
"=",
"list",
"(",
"shape",
")",
"while",
"1",
"in",
"shape",
":",
"shape",
".",
"remove",
"(",
"1",
")",
"# empty resp. 1-sized dimensions have to be removed (equal to scipy.squeeze on the array)",
"retu... | Returns the number of edges for the supplied image shape assuming 4-connectedness.
The name of the function has historical reasons. Essentially it returns the number
of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness,
etc.
@param shape the shape of the image
@... | [
"Returns",
"the",
"number",
"of",
"edges",
"for",
"the",
"supplied",
"image",
"shape",
"assuming",
"4",
"-",
"connectedness",
".",
"The",
"name",
"of",
"the",
"function",
"has",
"historical",
"reasons",
".",
"Essentially",
"it",
"returns",
"the",
"number",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/generate.py#L316-L331 |
loli/medpy | bin/medpy_grid.py | getArguments | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
# get the number of dimensions in the image
if args.example:
args.example_image, args.example_header = load(args.example)
dimensions = args.example_image.ndim
... | python | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
# get the number of dimensions in the image
if args.example:
args.example_image, args.example_header = load(args.example)
dimensions = args.example_image.ndim
... | [
"def",
"getArguments",
"(",
"parser",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"# get the number of dimensions in the image",
"if",
"args",
".",
"example",
":",
"args",
".",
"example_image",
",",
"args",
".",
"example_header",
"=",
"load",
... | Provides additional validation of the arguments collected by argparse. | [
"Provides",
"additional",
"validation",
"of",
"the",
"arguments",
"collected",
"by",
"argparse",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_grid.py#L122-L144 |
loli/medpy | bin/medpy_grid.py | getParser | def getParser():
"Creates and returns the argparse parser object."
# text
epilog ="""
examples:
%(prog)s -e example.nii grid.nii 10
Generates an empty image with the same attributes as example.nii, overlays it
with a regular grid of width 10 voxels and saves it as grid.nii.
%(prog)s -e examp... | python | def getParser():
"Creates and returns the argparse parser object."
# text
epilog ="""
examples:
%(prog)s -e example.nii grid.nii 10
Generates an empty image with the same attributes as example.nii, overlays it
with a regular grid of width 10 voxels and saves it as grid.nii.
%(prog)s -e examp... | [
"def",
"getParser",
"(",
")",
":",
"# text",
"epilog",
"=",
"\"\"\"\nexamples:\n %(prog)s -e example.nii grid.nii 10\n Generates an empty image with the same attributes as example.nii, overlays it\n with a regular grid of width 10 voxels and saves it as grid.nii.\n %(prog)s -e example.ni... | Creates and returns the argparse parser object. | [
"Creates",
"and",
"returns",
"the",
"argparse",
"parser",
"object",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_grid.py#L146-L182 |
loli/medpy | medpy/graphcut/wrapper.py | split_marker | def split_marker(marker, fg_id = 1, bg_id = 2):
"""
Splits an integer marker image into two binary image containing the foreground and
background markers respectively.
All encountered 1's are hereby treated as foreground, all 2's as background, all 0's
as neutral marker and all others are ignored.
... | python | def split_marker(marker, fg_id = 1, bg_id = 2):
"""
Splits an integer marker image into two binary image containing the foreground and
background markers respectively.
All encountered 1's are hereby treated as foreground, all 2's as background, all 0's
as neutral marker and all others are ignored.
... | [
"def",
"split_marker",
"(",
"marker",
",",
"fg_id",
"=",
"1",
",",
"bg_id",
"=",
"2",
")",
":",
"img_marker",
"=",
"scipy",
".",
"asarray",
"(",
"marker",
")",
"img_fgmarker",
"=",
"scipy",
".",
"zeros",
"(",
"img_marker",
".",
"shape",
",",
"scipy",
... | Splits an integer marker image into two binary image containing the foreground and
background markers respectively.
All encountered 1's are hereby treated as foreground, all 2's as background, all 0's
as neutral marker and all others are ignored.
This behaviour can be changed by supplying the fg_id and/... | [
"Splits",
"an",
"integer",
"marker",
"image",
"into",
"two",
"binary",
"image",
"containing",
"the",
"foreground",
"and",
"background",
"markers",
"respectively",
".",
"All",
"encountered",
"1",
"s",
"are",
"hereby",
"treated",
"as",
"foreground",
"all",
"2",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/wrapper.py#L42-L72 |
loli/medpy | medpy/graphcut/wrapper.py | graphcut_split | def graphcut_split(graphcut_function, regions, gradient, foreground, background, minimal_edge_length = 100, overlap = 10, processes = None):
"""
Executes a graph cut by splitting the original volume into a number of sub-volumes of
a minimal edge length. These are then processed in subprocesses.
Thi... | python | def graphcut_split(graphcut_function, regions, gradient, foreground, background, minimal_edge_length = 100, overlap = 10, processes = None):
"""
Executes a graph cut by splitting the original volume into a number of sub-volumes of
a minimal edge length. These are then processed in subprocesses.
Thi... | [
"def",
"graphcut_split",
"(",
"graphcut_function",
",",
"regions",
",",
"gradient",
",",
"foreground",
",",
"background",
",",
"minimal_edge_length",
"=",
"100",
",",
"overlap",
"=",
"10",
",",
"processes",
"=",
"None",
")",
":",
"# initialize logger",
"logger",... | Executes a graph cut by splitting the original volume into a number of sub-volumes of
a minimal edge length. These are then processed in subprocesses.
This can be significantly faster than the traditional graph cuts, but should be
used with, as it can lead to different results. To minimize this effect,... | [
"Executes",
"a",
"graph",
"cut",
"by",
"splitting",
"the",
"original",
"volume",
"into",
"a",
"number",
"of",
"sub",
"-",
"volumes",
"of",
"a",
"minimal",
"edge",
"length",
".",
"These",
"are",
"then",
"processed",
"in",
"subprocesses",
".",
"This",
"can",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/wrapper.py#L74-L164 |
loli/medpy | medpy/graphcut/wrapper.py | graphcut_subprocesses | def graphcut_subprocesses(graphcut_function, graphcut_arguments, processes = None):
"""
Executes multiple graph cuts in parallel.
This can result in a significant speed-up.
Parameters
----------
graphcut_function : function
The graph cut to use (e.g. `graphcut_stawiaski`).
graph... | python | def graphcut_subprocesses(graphcut_function, graphcut_arguments, processes = None):
"""
Executes multiple graph cuts in parallel.
This can result in a significant speed-up.
Parameters
----------
graphcut_function : function
The graph cut to use (e.g. `graphcut_stawiaski`).
graph... | [
"def",
"graphcut_subprocesses",
"(",
"graphcut_function",
",",
"graphcut_arguments",
",",
"processes",
"=",
"None",
")",
":",
"# initialize logger",
"logger",
"=",
"Logger",
".",
"getInstance",
"(",
")",
"# check and eventually enhance input parameters",
"if",
"not",
"p... | Executes multiple graph cuts in parallel.
This can result in a significant speed-up.
Parameters
----------
graphcut_function : function
The graph cut to use (e.g. `graphcut_stawiaski`).
graphcut_arguments : tuple
List of arguments to pass to the respective subprocesses resp. the... | [
"Executes",
"multiple",
"graph",
"cuts",
"in",
"parallel",
".",
"This",
"can",
"result",
"in",
"a",
"significant",
"speed",
"-",
"up",
".",
"Parameters",
"----------",
"graphcut_function",
":",
"function",
"The",
"graph",
"cut",
"to",
"use",
"(",
"e",
".",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/wrapper.py#L167-L200 |
loli/medpy | medpy/graphcut/wrapper.py | graphcut_stawiaski | def graphcut_stawiaski(regions, gradient = False, foreground = False, background = False):
"""
Executes a Stawiaski label graph cut.
Parameters
----------
regions : ndarray
The regions image / label map.
gradient : ndarray
The gradient image.
foreground : ndarray
... | python | def graphcut_stawiaski(regions, gradient = False, foreground = False, background = False):
"""
Executes a Stawiaski label graph cut.
Parameters
----------
regions : ndarray
The regions image / label map.
gradient : ndarray
The gradient image.
foreground : ndarray
... | [
"def",
"graphcut_stawiaski",
"(",
"regions",
",",
"gradient",
"=",
"False",
",",
"foreground",
"=",
"False",
",",
"background",
"=",
"False",
")",
":",
"# initialize logger",
"logger",
"=",
"Logger",
".",
"getInstance",
"(",
")",
"# unpack images if required",
"... | Executes a Stawiaski label graph cut.
Parameters
----------
regions : ndarray
The regions image / label map.
gradient : ndarray
The gradient image.
foreground : ndarray
The foreground markers.
background : ndarray
The background markers.
Returns
... | [
"Executes",
"a",
"Stawiaski",
"label",
"graph",
"cut",
".",
"Parameters",
"----------",
"regions",
":",
"ndarray",
"The",
"regions",
"image",
"/",
"label",
"map",
".",
"gradient",
":",
"ndarray",
"The",
"gradient",
"image",
".",
"foreground",
":",
"ndarray",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/wrapper.py#L203-L262 |
loli/medpy | bin/medpy_zoom_image.py | zoom | def zoom(image, factor, dimension, hdr = False, order = 3):
"""
Zooms the provided image by the supplied factor in the supplied dimension.
The factor is an integer determining how many slices should be put between each
existing pair.
If an image header (hdr) is supplied, its voxel spacing gets updat... | python | def zoom(image, factor, dimension, hdr = False, order = 3):
"""
Zooms the provided image by the supplied factor in the supplied dimension.
The factor is an integer determining how many slices should be put between each
existing pair.
If an image header (hdr) is supplied, its voxel spacing gets updat... | [
"def",
"zoom",
"(",
"image",
",",
"factor",
",",
"dimension",
",",
"hdr",
"=",
"False",
",",
"order",
"=",
"3",
")",
":",
"# check if supplied dimension is valid",
"if",
"dimension",
">=",
"image",
".",
"ndim",
":",
"raise",
"argparse",
".",
"ArgumentError",... | Zooms the provided image by the supplied factor in the supplied dimension.
The factor is an integer determining how many slices should be put between each
existing pair.
If an image header (hdr) is supplied, its voxel spacing gets updated.
Returns the image and the updated header or false. | [
"Zooms",
"the",
"provided",
"image",
"by",
"the",
"supplied",
"factor",
"in",
"the",
"supplied",
"dimension",
".",
"The",
"factor",
"is",
"an",
"integer",
"determining",
"how",
"many",
"slices",
"should",
"be",
"put",
"between",
"each",
"existing",
"pair",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_zoom_image.py#L80-L111 |
loli/medpy | doc/numpydoc/numpydoc/phantom_import.py | import_phantom_module | def import_phantom_module(xml_file):
"""
Insert a fake Python module to sys.modules, based on a XML file.
The XML file is expected to conform to Pydocweb DTD. The fake
module will contain dummy objects, which guarantee the following:
- Docstrings are correct.
- Class inheritance relationships ... | python | def import_phantom_module(xml_file):
"""
Insert a fake Python module to sys.modules, based on a XML file.
The XML file is expected to conform to Pydocweb DTD. The fake
module will contain dummy objects, which guarantee the following:
- Docstrings are correct.
- Class inheritance relationships ... | [
"def",
"import_phantom_module",
"(",
"xml_file",
")",
":",
"import",
"lxml",
".",
"etree",
"as",
"etree",
"object_cache",
"=",
"{",
"}",
"tree",
"=",
"etree",
".",
"parse",
"(",
"xml_file",
")",
"root",
"=",
"tree",
".",
"getroot",
"(",
")",
"# Sort item... | Insert a fake Python module to sys.modules, based on a XML file.
The XML file is expected to conform to Pydocweb DTD. The fake
module will contain dummy objects, which guarantee the following:
- Docstrings are correct.
- Class inheritance relationships are correct (if present in XML).
- Function a... | [
"Insert",
"a",
"fake",
"Python",
"module",
"to",
"sys",
".",
"modules",
"based",
"on",
"a",
"XML",
"file",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/phantom_import.py#L34-L167 |
loli/medpy | medpy/graphcut/energy_voxel.py | regional_probability_map | def regional_probability_map(graph, xxx_todo_changeme):
r"""
Regional term based on a probability atlas.
An implementation of a regional term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Takes an image/graph/map as input where each entry contains a p... | python | def regional_probability_map(graph, xxx_todo_changeme):
r"""
Regional term based on a probability atlas.
An implementation of a regional term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Takes an image/graph/map as input where each entry contains a p... | [
"def",
"regional_probability_map",
"(",
"graph",
",",
"xxx_todo_changeme",
")",
":",
"(",
"probability_map",
",",
"alpha",
")",
"=",
"xxx_todo_changeme",
"probability_map",
"=",
"scipy",
".",
"asarray",
"(",
"probability_map",
")",
"probabilities",
"=",
"numpy",
"... | r"""
Regional term based on a probability atlas.
An implementation of a regional term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Takes an image/graph/map as input where each entry contains a probability value for
the corresponding GC graph node to ... | [
"r",
"Regional",
"term",
"based",
"on",
"a",
"probability",
"atlas",
".",
"An",
"implementation",
"of",
"a",
"regional",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
".",
"generate",
".",
"graph_from_voxels",
"function",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L32-L63 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_maximum_linear | def boundary_maximum_linear(graph, xxx_todo_changeme1):
r"""
Boundary term processing adjacent voxels maximum value using a linear relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_... | python | def boundary_maximum_linear(graph, xxx_todo_changeme1):
r"""
Boundary term processing adjacent voxels maximum value using a linear relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_... | [
"def",
"boundary_maximum_linear",
"(",
"graph",
",",
"xxx_todo_changeme1",
")",
":",
"(",
"gradient_image",
",",
"spacing",
")",
"=",
"xxx_todo_changeme1",
"gradient_image",
"=",
"scipy",
".",
"asarray",
"(",
"gradient_image",
")",
"# compute maximum intensity to encoun... | r"""
Boundary term processing adjacent voxels maximum value using a linear relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_difference_linear`, but working on the gradient image instea... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"maximum",
"value",
"using",
"a",
"linear",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
".",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L65-L109 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_difference_linear | def boundary_difference_linear(graph, xxx_todo_changeme2):
r"""
Boundary term processing adjacent voxels difference value using a linear relationship.
An implementation of a regional term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges ... | python | def boundary_difference_linear(graph, xxx_todo_changeme2):
r"""
Boundary term processing adjacent voxels difference value using a linear relationship.
An implementation of a regional term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges ... | [
"def",
"boundary_difference_linear",
"(",
"graph",
",",
"xxx_todo_changeme2",
")",
":",
"(",
"original_image",
",",
"spacing",
")",
"=",
"xxx_todo_changeme2",
"original_image",
"=",
"scipy",
".",
"asarray",
"(",
"original_image",
")",
"# compute maximum (possible) inten... | r"""
Boundary term processing adjacent voxels difference value using a linear relationship.
An implementation of a regional term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges between all neighbours of the image and uses their normalized
... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"difference",
"value",
"using",
"a",
"linear",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"regional",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
".... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L111-L179 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_maximum_exponential | def boundary_maximum_exponential(graph, xxx_todo_changeme3):
r"""
Boundary term processing adjacent voxels maximum value using an exponential relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as... | python | def boundary_maximum_exponential(graph, xxx_todo_changeme3):
r"""
Boundary term processing adjacent voxels maximum value using an exponential relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as... | [
"def",
"boundary_maximum_exponential",
"(",
"graph",
",",
"xxx_todo_changeme3",
")",
":",
"(",
"gradient_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme3",
"gradient_image",
"=",
"scipy",
".",
"asarray",
"(",
"gradient_image",
")",
"def",
"bound... | r"""
Boundary term processing adjacent voxels maximum value using an exponential relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_difference_exponential`, but working on the gradient i... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"maximum",
"value",
"using",
"an",
"exponential",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L181-L225 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_difference_exponential | def boundary_difference_exponential(graph, xxx_todo_changeme4):
r"""
Boundary term processing adjacent voxels difference value using an exponential relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds ... | python | def boundary_difference_exponential(graph, xxx_todo_changeme4):
r"""
Boundary term processing adjacent voxels difference value using an exponential relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds ... | [
"def",
"boundary_difference_exponential",
"(",
"graph",
",",
"xxx_todo_changeme4",
")",
":",
"(",
"original_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme4",
"original_image",
"=",
"scipy",
".",
"asarray",
"(",
"original_image",
")",
"def",
"bo... | r"""
Boundary term processing adjacent voxels difference value using an exponential relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges between all neighbours of the image and uses their differe... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"difference",
"value",
"using",
"an",
"exponential",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L227-L288 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_maximum_division | def boundary_maximum_division(graph, xxx_todo_changeme5):
r"""
Boundary term processing adjacent voxels maximum value using a division relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `bound... | python | def boundary_maximum_division(graph, xxx_todo_changeme5):
r"""
Boundary term processing adjacent voxels maximum value using a division relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `bound... | [
"def",
"boundary_maximum_division",
"(",
"graph",
",",
"xxx_todo_changeme5",
")",
":",
"(",
"gradient_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme5",
"gradient_image",
"=",
"scipy",
".",
"asarray",
"(",
"gradient_image",
")",
"def",
"boundary... | r"""
Boundary term processing adjacent voxels maximum value using a division relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_difference_division`, but working on the gradient image in... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"maximum",
"value",
"using",
"a",
"division",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
"."... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L290-L332 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_difference_division | def boundary_difference_division(graph, xxx_todo_changeme6):
r"""
Boundary term processing adjacent voxels difference value using a division relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all ed... | python | def boundary_difference_division(graph, xxx_todo_changeme6):
r"""
Boundary term processing adjacent voxels difference value using a division relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all ed... | [
"def",
"boundary_difference_division",
"(",
"graph",
",",
"xxx_todo_changeme6",
")",
":",
"(",
"original_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme6",
"original_image",
"=",
"scipy",
".",
"asarray",
"(",
"original_image",
")",
"def",
"bound... | r"""
Boundary term processing adjacent voxels difference value using a division relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges between all neighbours of the image and uses their difference... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"difference",
"value",
"using",
"a",
"division",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L334-L393 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.