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 |
|---|---|---|---|---|---|---|---|---|---|---|
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_maximum_power | def boundary_maximum_power(graph, xxx_todo_changeme7):
"""
Boundary term processing adjacent voxels maximum value using a power relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_dif... | python | def boundary_maximum_power(graph, xxx_todo_changeme7):
"""
Boundary term processing adjacent voxels maximum value using a power relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_dif... | [
"def",
"boundary_maximum_power",
"(",
"graph",
",",
"xxx_todo_changeme7",
")",
":",
"(",
"gradient_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme7",
"gradient_image",
"=",
"scipy",
".",
"asarray",
"(",
"gradient_image",
")",
"def",
"boundary_te... | Boundary term processing adjacent voxels maximum value using a power 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_power`, but working on the gradient image instead
of th... | [
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"maximum",
"value",
"using",
"a",
"power",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
".",
"gener... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L395-L437 |
loli/medpy | medpy/graphcut/energy_voxel.py | boundary_difference_power | def boundary_difference_power(graph, xxx_todo_changeme8):
r"""
Boundary term processing adjacent voxels difference value using a power relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges be... | python | def boundary_difference_power(graph, xxx_todo_changeme8):
r"""
Boundary term processing adjacent voxels difference value using a power relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
Finds all edges be... | [
"def",
"boundary_difference_power",
"(",
"graph",
",",
"xxx_todo_changeme8",
")",
":",
"(",
"original_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme8",
"original_image",
"=",
"scipy",
".",
"asarray",
"(",
"original_image",
")",
"def",
"boundary... | r"""
Boundary term processing adjacent voxels difference value using a power 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 in... | [
"r",
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"difference",
"value",
"using",
"a",
"power",
"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#L440-L499 |
loli/medpy | medpy/graphcut/energy_voxel.py | __skeleton_maximum | def __skeleton_maximum(graph, image, boundary_term, spacing):
"""
A skeleton for the calculation of maximum intensity based boundary terms.
This function is equivalent to energy_voxel.__skeleton_difference(), but uses the
maximum intensity rather than the intensity difference of neighbouring voxels... | python | def __skeleton_maximum(graph, image, boundary_term, spacing):
"""
A skeleton for the calculation of maximum intensity based boundary terms.
This function is equivalent to energy_voxel.__skeleton_difference(), but uses the
maximum intensity rather than the intensity difference of neighbouring voxels... | [
"def",
"__skeleton_maximum",
"(",
"graph",
",",
"image",
",",
"boundary_term",
",",
"spacing",
")",
":",
"def",
"intensity_maximum",
"(",
"neighbour_one",
",",
"neighbour_two",
")",
":",
"\"\"\"\n Takes two voxel arrays constituting neighbours and computes the maximum ... | A skeleton for the calculation of maximum intensity based boundary terms.
This function is equivalent to energy_voxel.__skeleton_difference(), but uses the
maximum intensity rather than the intensity difference of neighbouring voxels. It is
therefore suitable to be used with the gradient image, rather ... | [
"A",
"skeleton",
"for",
"the",
"calculation",
"of",
"maximum",
"intensity",
"based",
"boundary",
"terms",
".",
"This",
"function",
"is",
"equivalent",
"to",
"energy_voxel",
".",
"__skeleton_difference",
"()",
"but",
"uses",
"the",
"maximum",
"intensity",
"rather",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L501-L539 |
loli/medpy | medpy/graphcut/energy_voxel.py | __skeleton_difference | def __skeleton_difference(graph, image, boundary_term, spacing):
"""
A skeleton for the calculation of intensity difference based boundary terms.
Iterates over the images dimensions and generates for each an array of absolute
neighbouring voxel :math:`(p, q)` intensity differences :math:`|I_p, I_q|... | python | def __skeleton_difference(graph, image, boundary_term, spacing):
"""
A skeleton for the calculation of intensity difference based boundary terms.
Iterates over the images dimensions and generates for each an array of absolute
neighbouring voxel :math:`(p, q)` intensity differences :math:`|I_p, I_q|... | [
"def",
"__skeleton_difference",
"(",
"graph",
",",
"image",
",",
"boundary_term",
",",
"spacing",
")",
":",
"def",
"intensity_difference",
"(",
"neighbour_one",
",",
"neighbour_two",
")",
":",
"\"\"\"\n Takes two voxel arrays constituting neighbours and computes the ab... | A skeleton for the calculation of intensity difference based boundary terms.
Iterates over the images dimensions and generates for each an array of absolute
neighbouring voxel :math:`(p, q)` intensity differences :math:`|I_p, I_q|`. These are
then passed to the supplied function :math:`g(\cdot)` for fo... | [
"A",
"skeleton",
"for",
"the",
"calculation",
"of",
"intensity",
"difference",
"based",
"boundary",
"terms",
".",
"Iterates",
"over",
"the",
"images",
"dimensions",
"and",
"generates",
"for",
"each",
"an",
"array",
"of",
"absolute",
"neighbouring",
"voxel",
":",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L542-L588 |
loli/medpy | medpy/graphcut/energy_voxel.py | __skeleton_base | def __skeleton_base(graph, image, boundary_term, neighbourhood_function, spacing):
"""
Base of the skeleton for voxel based boundary term calculation.
This function holds the low level procedures shared by nearly all boundary terms.
@param graph An initialized graph.GCGraph object
@type gr... | python | def __skeleton_base(graph, image, boundary_term, neighbourhood_function, spacing):
"""
Base of the skeleton for voxel based boundary term calculation.
This function holds the low level procedures shared by nearly all boundary terms.
@param graph An initialized graph.GCGraph object
@type gr... | [
"def",
"__skeleton_base",
"(",
"graph",
",",
"image",
",",
"boundary_term",
",",
"neighbourhood_function",
",",
"spacing",
")",
":",
"image",
"=",
"scipy",
".",
"asarray",
"(",
"image",
")",
"image",
"=",
"image",
".",
"astype",
"(",
"scipy",
".",
"float_"... | Base of the skeleton for voxel based boundary term calculation.
This function holds the low level procedures shared by nearly all boundary terms.
@param graph An initialized graph.GCGraph object
@type graph.GCGraph
@param image The image containing the voxel intensity values
@type image nu... | [
"Base",
"of",
"the",
"skeleton",
"for",
"voxel",
"based",
"boundary",
"term",
"calculation",
".",
"This",
"function",
"holds",
"the",
"low",
"level",
"procedures",
"shared",
"by",
"nearly",
"all",
"boundary",
"terms",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L590-L640 |
loli/medpy | medpy/graphcut/energy_voxel.py | __flatten_index | def __flatten_index(pos, shape):
"""
Takes a three dimensional index (x,y,z) and computes the index required to access the
same element in the flattened version of the array.
"""
res = 0
acc = 1
for pi, si in zip(reversed(pos), reversed(shape)):
res += pi * acc
acc *= si
... | python | def __flatten_index(pos, shape):
"""
Takes a three dimensional index (x,y,z) and computes the index required to access the
same element in the flattened version of the array.
"""
res = 0
acc = 1
for pi, si in zip(reversed(pos), reversed(shape)):
res += pi * acc
acc *= si
... | [
"def",
"__flatten_index",
"(",
"pos",
",",
"shape",
")",
":",
"res",
"=",
"0",
"acc",
"=",
"1",
"for",
"pi",
",",
"si",
"in",
"zip",
"(",
"reversed",
"(",
"pos",
")",
",",
"reversed",
"(",
"shape",
")",
")",
":",
"res",
"+=",
"pi",
"*",
"acc",
... | Takes a three dimensional index (x,y,z) and computes the index required to access the
same element in the flattened version of the array. | [
"Takes",
"a",
"three",
"dimensional",
"index",
"(",
"x",
"y",
"z",
")",
"and",
"computes",
"the",
"index",
"required",
"to",
"access",
"the",
"same",
"element",
"in",
"the",
"flattened",
"version",
"of",
"the",
"array",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L642-L652 |
loli/medpy | medpy/metric/image.py | mutual_information | def mutual_information(i1, i2, bins=256):
r"""
Computes the mutual information (MI) (a measure of entropy) between two images.
MI is not real metric, but a symmetric and nonnegative similarity measures that
takes high values for similar images. Negative values are also possible.
Intuitively, m... | python | def mutual_information(i1, i2, bins=256):
r"""
Computes the mutual information (MI) (a measure of entropy) between two images.
MI is not real metric, but a symmetric and nonnegative similarity measures that
takes high values for similar images. Negative values are also possible.
Intuitively, m... | [
"def",
"mutual_information",
"(",
"i1",
",",
"i2",
",",
"bins",
"=",
"256",
")",
":",
"# pre-process function arguments",
"i1",
"=",
"numpy",
".",
"asarray",
"(",
"i1",
")",
"i2",
"=",
"numpy",
".",
"asarray",
"(",
"i2",
")",
"# validate function arguments",... | r"""
Computes the mutual information (MI) (a measure of entropy) between two images.
MI is not real metric, but a symmetric and nonnegative similarity measures that
takes high values for similar images. Negative values are also possible.
Intuitively, mutual information measures the information tha... | [
"r",
"Computes",
"the",
"mutual",
"information",
"(",
"MI",
")",
"(",
"a",
"measure",
"of",
"entropy",
")",
"between",
"two",
"images",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/image.py#L30-L101 |
loli/medpy | medpy/metric/image.py | __range | def __range(a, bins):
'''Compute the histogram range of the values in the array a according to
scipy.stats.histogram.'''
a = numpy.asarray(a)
a_max = a.max()
a_min = a.min()
s = 0.5 * (a_max - a_min) / float(bins - 1)
return (a_min - s, a_max + s) | python | def __range(a, bins):
'''Compute the histogram range of the values in the array a according to
scipy.stats.histogram.'''
a = numpy.asarray(a)
a_max = a.max()
a_min = a.min()
s = 0.5 * (a_max - a_min) / float(bins - 1)
return (a_min - s, a_max + s) | [
"def",
"__range",
"(",
"a",
",",
"bins",
")",
":",
"a",
"=",
"numpy",
".",
"asarray",
"(",
"a",
")",
"a_max",
"=",
"a",
".",
"max",
"(",
")",
"a_min",
"=",
"a",
".",
"min",
"(",
")",
"s",
"=",
"0.5",
"*",
"(",
"a_max",
"-",
"a_min",
")",
... | Compute the histogram range of the values in the array a according to
scipy.stats.histogram. | [
"Compute",
"the",
"histogram",
"range",
"of",
"the",
"values",
"in",
"the",
"array",
"a",
"according",
"to",
"scipy",
".",
"stats",
".",
"histogram",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/image.py#L103-L110 |
loli/medpy | medpy/metric/image.py | __entropy | def __entropy(data):
'''Compute entropy of the flattened data set (e.g. a density distribution).'''
# normalize and convert to float
data = data/float(numpy.sum(data))
# for each grey-value g with a probability p(g) = 0, the entropy is defined as 0, therefore we remove these values and also flatten the ... | python | def __entropy(data):
'''Compute entropy of the flattened data set (e.g. a density distribution).'''
# normalize and convert to float
data = data/float(numpy.sum(data))
# for each grey-value g with a probability p(g) = 0, the entropy is defined as 0, therefore we remove these values and also flatten the ... | [
"def",
"__entropy",
"(",
"data",
")",
":",
"# normalize and convert to float",
"data",
"=",
"data",
"/",
"float",
"(",
"numpy",
".",
"sum",
"(",
"data",
")",
")",
"# for each grey-value g with a probability p(g) = 0, the entropy is defined as 0, therefore we remove these valu... | Compute entropy of the flattened data set (e.g. a density distribution). | [
"Compute",
"entropy",
"of",
"the",
"flattened",
"data",
"set",
"(",
"e",
".",
"g",
".",
"a",
"density",
"distribution",
")",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/image.py#L112-L119 |
loli/medpy | bin/medpy_split_xd_to_xminus1d.py | getArguments | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
if not '{}' in args.output:
raise argparse.ArgumentError(args.output, 'The output argument string must contain the sequence "{}".')
return args | python | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
if not '{}' in args.output:
raise argparse.ArgumentError(args.output, 'The output argument string must contain the sequence "{}".')
return args | [
"def",
"getArguments",
"(",
"parser",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"if",
"not",
"'{}'",
"in",
"args",
".",
"output",
":",
"raise",
"argparse",
".",
"ArgumentError",
"(",
"args",
".",
"output",
",",
"'The output argument str... | 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_split_xd_to_xminus1d.py#L95-L100 |
loli/medpy | medpy/features/intensity.py | centerdistance | def centerdistance(image, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns its voxel-wise center distance in
mm. A multi-spectral image must be supplied as a list or tuple of its spectra.
Optionally a binary mask can be supplied to select the voxels ... | python | def centerdistance(image, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns its voxel-wise center distance in
mm. A multi-spectral image must be supplied as a list or tuple of its spectra.
Optionally a binary mask can be supplied to select the voxels ... | [
"def",
"centerdistance",
"(",
"image",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"if",
"type",
"(",
"image",
")",
"==",
"tuple",
"or",
"type",
"(",
"image",
")",
"==",
"list",
":",
"image",
"=",
"image... | r"""
Takes a simple or multi-spectral image and returns its voxel-wise center distance in
mm. A multi-spectral image must be supplied as a list or tuple of its spectra.
Optionally a binary mask can be supplied to select the voxels for which the feature
should be extracted.
The center dista... | [
"r",
"Takes",
"a",
"simple",
"or",
"multi",
"-",
"spectral",
"image",
"and",
"returns",
"its",
"voxel",
"-",
"wise",
"center",
"distance",
"in",
"mm",
".",
"A",
"multi",
"-",
"spectral",
"image",
"must",
"be",
"supplied",
"as",
"a",
"list",
"or",
"tupl... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L59-L96 |
loli/medpy | medpy/features/intensity.py | centerdistance_xdminus1 | def centerdistance_xdminus1(image, dim, voxelspacing = None, mask = slice(None)):
r"""
Implementation of `centerdistance` that allows to compute sub-volume wise
centerdistances.
The same notes as for `centerdistance` apply.
Parameters
----------
image : array_like or list/tuple of ... | python | def centerdistance_xdminus1(image, dim, voxelspacing = None, mask = slice(None)):
r"""
Implementation of `centerdistance` that allows to compute sub-volume wise
centerdistances.
The same notes as for `centerdistance` apply.
Parameters
----------
image : array_like or list/tuple of ... | [
"def",
"centerdistance_xdminus1",
"(",
"image",
",",
"dim",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"# pre-process arguments",
"if",
"type",
"(",
"image",
")",
"==",
"tuple",
"or",
"type",
"(",
"image",
")... | r"""
Implementation of `centerdistance` that allows to compute sub-volume wise
centerdistances.
The same notes as for `centerdistance` apply.
Parameters
----------
image : array_like or list/tuple of array_like
A single image or a list/tuple of images (for multi-spectral case)... | [
"r",
"Implementation",
"of",
"centerdistance",
"that",
"allows",
"to",
"compute",
"sub",
"-",
"volume",
"wise",
"centerdistances",
".",
"The",
"same",
"notes",
"as",
"for",
"centerdistance",
"apply",
".",
"Parameters",
"----------",
"image",
":",
"array_like",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L98-L167 |
loli/medpy | medpy/features/intensity.py | indices | def indices(image, voxelspacing = None, mask = slice(None)):
r"""
Takes an image and returns the voxels ndim-indices as voxel-wise feature. The voxel
spacing is taken into account, i.e. the indices are not array indices, but millimeter
indices.
This is a multi-element feature where each element... | python | def indices(image, voxelspacing = None, mask = slice(None)):
r"""
Takes an image and returns the voxels ndim-indices as voxel-wise feature. The voxel
spacing is taken into account, i.e. the indices are not array indices, but millimeter
indices.
This is a multi-element feature where each element... | [
"def",
"indices",
"(",
"image",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"if",
"type",
"(",
"image",
")",
"==",
"tuple",
"or",
"type",
"(",
"image",
")",
"==",
"list",
":",
"image",
"=",
"image",
"[... | r"""
Takes an image and returns the voxels ndim-indices as voxel-wise feature. The voxel
spacing is taken into account, i.e. the indices are not array indices, but millimeter
indices.
This is a multi-element feature where each element corresponds to one of the images
axes, e.g. x, y, z, ...
... | [
"r",
"Takes",
"an",
"image",
"and",
"returns",
"the",
"voxels",
"ndim",
"-",
"indices",
"as",
"voxel",
"-",
"wise",
"feature",
".",
"The",
"voxel",
"spacing",
"is",
"taken",
"into",
"account",
"i",
".",
"e",
".",
"the",
"indices",
"are",
"not",
"array"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L169-L208 |
loli/medpy | medpy/features/intensity.py | shifted_mean_gauss | def shifted_mean_gauss(image, offset = None, sigma = 5, voxelspacing = None, mask = slice(None)):
r"""
The approximate mean over a small region at an offset from each voxel.
Functions like `local_mean_gauss`, but instead of computing the average over a small
patch around the current voxel, the regi... | python | def shifted_mean_gauss(image, offset = None, sigma = 5, voxelspacing = None, mask = slice(None)):
r"""
The approximate mean over a small region at an offset from each voxel.
Functions like `local_mean_gauss`, but instead of computing the average over a small
patch around the current voxel, the regi... | [
"def",
"shifted_mean_gauss",
"(",
"image",
",",
"offset",
"=",
"None",
",",
"sigma",
"=",
"5",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"_extract_feature",
"(",
"_extract_shifted_mean_gauss",
",",
"... | r"""
The approximate mean over a small region at an offset from each voxel.
Functions like `local_mean_gauss`, but instead of computing the average over a small
patch around the current voxel, the region is centered at an offset away. Can be used
to use a distant regions average as feature for a vo... | [
"r",
"The",
"approximate",
"mean",
"over",
"a",
"small",
"region",
"at",
"an",
"offset",
"from",
"each",
"voxel",
".",
"Functions",
"like",
"local_mean_gauss",
"but",
"instead",
"of",
"computing",
"the",
"average",
"over",
"a",
"small",
"patch",
"around",
"t... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L210-L244 |
loli/medpy | medpy/features/intensity.py | mask_distance | def mask_distance(image, voxelspacing = None, mask = slice(None)):
r"""
Computes the distance of each point under the mask to the mask border taking the
voxel-spacing into account.
Note that this feature is independent of the actual image content, but depends
solely the mask image. Therefore al... | python | def mask_distance(image, voxelspacing = None, mask = slice(None)):
r"""
Computes the distance of each point under the mask to the mask border taking the
voxel-spacing into account.
Note that this feature is independent of the actual image content, but depends
solely the mask image. Therefore al... | [
"def",
"mask_distance",
"(",
"image",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"if",
"type",
"(",
"image",
")",
"==",
"tuple",
"or",
"type",
"(",
"image",
")",
"==",
"list",
":",
"image",
"=",
"image"... | r"""
Computes the distance of each point under the mask to the mask border taking the
voxel-spacing into account.
Note that this feature is independent of the actual image content, but depends
solely the mask image. Therefore always a one-dimensional feature is returned,
even if a multi-spectra... | [
"r",
"Computes",
"the",
"distance",
"of",
"each",
"point",
"under",
"the",
"mask",
"to",
"the",
"mask",
"border",
"taking",
"the",
"voxel",
"-",
"spacing",
"into",
"account",
".",
"Note",
"that",
"this",
"feature",
"is",
"independent",
"of",
"the",
"actual... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L246-L275 |
loli/medpy | medpy/features/intensity.py | local_mean_gauss | def local_mean_gauss(image, sigma = 5, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the approximate mean over a small
region around each voxel. A multi-spectral image must be supplied as a list or tuple
of its spectra.
Optionally a binary mas... | python | def local_mean_gauss(image, sigma = 5, voxelspacing = None, mask = slice(None)):
r"""
Takes a simple or multi-spectral image and returns the approximate mean over a small
region around each voxel. A multi-spectral image must be supplied as a list or tuple
of its spectra.
Optionally a binary mas... | [
"def",
"local_mean_gauss",
"(",
"image",
",",
"sigma",
"=",
"5",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"_extract_feature",
"(",
"_extract_local_mean_gauss",
",",
"image",
",",
"mask",
",",
"sigma... | r"""
Takes a simple or multi-spectral image and returns the approximate mean over a small
region around each voxel. A multi-spectral image must be supplied as a list or tuple
of its spectra.
Optionally a binary mask can be supplied to select the voxels for which the feature
should be extracted.... | [
"r",
"Takes",
"a",
"simple",
"or",
"multi",
"-",
"spectral",
"image",
"and",
"returns",
"the",
"approximate",
"mean",
"over",
"a",
"small",
"region",
"around",
"each",
"voxel",
".",
"A",
"multi",
"-",
"spectral",
"image",
"must",
"be",
"supplied",
"as",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L277-L311 |
loli/medpy | medpy/features/intensity.py | gaussian_gradient_magnitude | def gaussian_gradient_magnitude(image, sigma = 5, voxelspacing = None, mask = slice(None)):
r"""
Computes the gradient magnitude (edge-detection) of the supplied image using gaussian
derivates and returns the intensity values.
Optionally a binary mask can be supplied to select the voxels for which ... | python | def gaussian_gradient_magnitude(image, sigma = 5, voxelspacing = None, mask = slice(None)):
r"""
Computes the gradient magnitude (edge-detection) of the supplied image using gaussian
derivates and returns the intensity values.
Optionally a binary mask can be supplied to select the voxels for which ... | [
"def",
"gaussian_gradient_magnitude",
"(",
"image",
",",
"sigma",
"=",
"5",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"_extract_feature",
"(",
"_extract_gaussian_gradient_magnitude",
",",
"image",
",",
"... | r"""
Computes the gradient magnitude (edge-detection) of the supplied image using gaussian
derivates and returns the intensity values.
Optionally a binary mask can be supplied to select the voxels for which the feature
should be extracted.
Parameters
----------
image : array_like o... | [
"r",
"Computes",
"the",
"gradient",
"magnitude",
"(",
"edge",
"-",
"detection",
")",
"of",
"the",
"supplied",
"image",
"using",
"gaussian",
"derivates",
"and",
"returns",
"the",
"intensity",
"values",
".",
"Optionally",
"a",
"binary",
"mask",
"can",
"be",
"s... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L313-L341 |
loli/medpy | medpy/features/intensity.py | median | def median(image, size = 5, voxelspacing = None, mask = slice(None)):
"""
Computes the multi-dimensional median filter and returns the resulting values per
voxel.
Optionally a binary mask can be supplied to select the voxels for which the feature
should be extracted.
Parameters
---... | python | def median(image, size = 5, voxelspacing = None, mask = slice(None)):
"""
Computes the multi-dimensional median filter and returns the resulting values per
voxel.
Optionally a binary mask can be supplied to select the voxels for which the feature
should be extracted.
Parameters
---... | [
"def",
"median",
"(",
"image",
",",
"size",
"=",
"5",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"_extract_feature",
"(",
"_extract_median",
",",
"image",
",",
"mask",
",",
"size",
"=",
"size",
... | Computes the multi-dimensional median filter and returns the resulting values per
voxel.
Optionally a binary mask can be supplied to select the voxels for which the feature
should be extracted.
Parameters
----------
image : array_like or list/tuple of array_like
A single image... | [
"Computes",
"the",
"multi",
"-",
"dimensional",
"median",
"filter",
"and",
"returns",
"the",
"resulting",
"values",
"per",
"voxel",
".",
"Optionally",
"a",
"binary",
"mask",
"can",
"be",
"supplied",
"to",
"select",
"the",
"voxels",
"for",
"which",
"the",
"fe... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L343-L371 |
loli/medpy | medpy/features/intensity.py | local_histogram | def local_histogram(image, bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0, mask=slice(None)):
r"""
Computes multi-dimensional histograms over a region around each voxel.
Supply an image and (optionally) a mask and get the local histogram of ... | python | def local_histogram(image, bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0, mask=slice(None)):
r"""
Computes multi-dimensional histograms over a region around each voxel.
Supply an image and (optionally) a mask and get the local histogram of ... | [
"def",
"local_histogram",
"(",
"image",
",",
"bins",
"=",
"19",
",",
"rang",
"=",
"\"image\"",
",",
"cutoffp",
"=",
"(",
"0.0",
",",
"100.0",
")",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
"None",
",",
"output",
"=",
"None",
",",
"mode",
"="... | r"""
Computes multi-dimensional histograms over a region around each voxel.
Supply an image and (optionally) a mask and get the local histogram of local
neighbourhoods around each voxel. These neighbourhoods are cubic with a sidelength of
size in voxels or, when a shape instead of an integer is pas... | [
"r",
"Computes",
"multi",
"-",
"dimensional",
"histograms",
"over",
"a",
"region",
"around",
"each",
"voxel",
".",
"Supply",
"an",
"image",
"and",
"(",
"optionally",
")",
"a",
"mask",
"and",
"get",
"the",
"local",
"histogram",
"of",
"local",
"neighbourhoods"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L373-L452 |
loli/medpy | medpy/features/intensity.py | hemispheric_difference | def hemispheric_difference(image, sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None, mask = slice(None)):
r"""
Computes the hemispheric intensity difference between the brain hemispheres of an brain image.
Cuts the image along the middle of the supplied cut-plane. This results i... | python | def hemispheric_difference(image, sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None, mask = slice(None)):
r"""
Computes the hemispheric intensity difference between the brain hemispheres of an brain image.
Cuts the image along the middle of the supplied cut-plane. This results i... | [
"def",
"hemispheric_difference",
"(",
"image",
",",
"sigma_active",
"=",
"7",
",",
"sigma_reference",
"=",
"7",
",",
"cut_plane",
"=",
"0",
",",
"voxelspacing",
"=",
"None",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"_extract_feature... | r"""
Computes the hemispheric intensity difference between the brain hemispheres of an brain image.
Cuts the image along the middle of the supplied cut-plane. This results in two
images, each containing one of the brains hemispheres.
For each of these two, the following steps are applied:
... | [
"r",
"Computes",
"the",
"hemispheric",
"intensity",
"difference",
"between",
"the",
"brain",
"hemispheres",
"of",
"an",
"brain",
"image",
".",
"Cuts",
"the",
"image",
"along",
"the",
"middle",
"of",
"the",
"supplied",
"cut",
"-",
"plane",
".",
"This",
"resul... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L455-L519 |
loli/medpy | medpy/features/intensity.py | _extract_hemispheric_difference | def _extract_hemispheric_difference(image, mask = slice(None), sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None):
"""
Internal, single-image version of `hemispheric_difference`.
"""
# constants
INTERPOLATION_RANGE = int(10) # how many neighbouring values to take into account... | python | def _extract_hemispheric_difference(image, mask = slice(None), sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None):
"""
Internal, single-image version of `hemispheric_difference`.
"""
# constants
INTERPOLATION_RANGE = int(10) # how many neighbouring values to take into account... | [
"def",
"_extract_hemispheric_difference",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"sigma_active",
"=",
"7",
",",
"sigma_reference",
"=",
"7",
",",
"cut_plane",
"=",
"0",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# constants",
"IN... | Internal, single-image version of `hemispheric_difference`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"hemispheric_difference",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L522-L585 |
loli/medpy | medpy/features/intensity.py | _extract_local_histogram | def _extract_local_histogram(image, mask=slice(None), bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0):
"""
Internal, single-image version of @see local_histogram
Note: Values outside of the histograms range are not considered.
Note: Mode... | python | def _extract_local_histogram(image, mask=slice(None), bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0):
"""
Internal, single-image version of @see local_histogram
Note: Values outside of the histograms range are not considered.
Note: Mode... | [
"def",
"_extract_local_histogram",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"bins",
"=",
"19",
",",
"rang",
"=",
"\"image\"",
",",
"cutoffp",
"=",
"(",
"0.0",
",",
"100.0",
")",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
... | Internal, single-image version of @see local_histogram
Note: Values outside of the histograms range are not considered.
Note: Mode constant is not available, instead a mode "ignore" is provided.
Note: Default dtype of returned values is float. | [
"Internal",
"single",
"-",
"image",
"version",
"of"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L587-L625 |
loli/medpy | medpy/features/intensity.py | _extract_median | def _extract_median(image, mask = slice(None), size = 1, voxelspacing = None):
"""
Internal, single-image version of `median`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine structure element size in voxel units
size = _create_s... | python | def _extract_median(image, mask = slice(None), size = 1, voxelspacing = None):
"""
Internal, single-image version of `median`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine structure element size in voxel units
size = _create_s... | [
"def",
"_extract_median",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"size",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",
"voxelspacing",
"=",
"[",
"1.",
"]",
... | Internal, single-image version of `median`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"median",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L627-L638 |
loli/medpy | medpy/features/intensity.py | _extract_gaussian_gradient_magnitude | def _extract_gaussian_gradient_magnitude(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `gaussian_gradient_magnitude`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel... | python | def _extract_gaussian_gradient_magnitude(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `gaussian_gradient_magnitude`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel... | [
"def",
"_extract_gaussian_gradient_magnitude",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"sigma",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",
"voxelspacing",
"=",
... | Internal, single-image version of `gaussian_gradient_magnitude`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"gaussian_gradient_magnitude",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L640-L651 |
loli/medpy | medpy/features/intensity.py | _extract_shifted_mean_gauss | def _extract_shifted_mean_gauss(image, mask = slice(None), offset = None, sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `shifted_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# set offset
if offset is None:... | python | def _extract_shifted_mean_gauss(image, mask = slice(None), offset = None, sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `shifted_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# set offset
if offset is None:... | [
"def",
"_extract_shifted_mean_gauss",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"offset",
"=",
"None",
",",
"sigma",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",... | Internal, single-image version of `shifted_mean_gauss`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"shifted_mean_gauss",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L653-L678 |
loli/medpy | medpy/features/intensity.py | _extract_mask_distance | def _extract_mask_distance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `mask_distance`.
"""
if isinstance(mask, slice):
mask = numpy.ones(image.shape, numpy.bool)
distance_map = distance_transform_edt(mask, sampling=voxelspacing)
retur... | python | def _extract_mask_distance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `mask_distance`.
"""
if isinstance(mask, slice):
mask = numpy.ones(image.shape, numpy.bool)
distance_map = distance_transform_edt(mask, sampling=voxelspacing)
retur... | [
"def",
"_extract_mask_distance",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"voxelspacing",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"mask",
",",
"slice",
")",
":",
"mask",
"=",
"numpy",
".",
"ones",
"(",
"image",
".",
"sh... | Internal, single-image version of `mask_distance`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"mask_distance",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L680-L689 |
loli/medpy | medpy/features/intensity.py | _extract_local_mean_gauss | def _extract_local_mean_gauss(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `local_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel size in voxel units
... | python | def _extract_local_mean_gauss(image, mask = slice(None), sigma = 1, voxelspacing = None):
"""
Internal, single-image version of `local_mean_gauss`.
"""
# set voxel spacing
if voxelspacing is None:
voxelspacing = [1.] * image.ndim
# determine gaussian kernel size in voxel units
... | [
"def",
"_extract_local_mean_gauss",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"sigma",
"=",
"1",
",",
"voxelspacing",
"=",
"None",
")",
":",
"# set voxel spacing",
"if",
"voxelspacing",
"is",
"None",
":",
"voxelspacing",
"=",
"[",
"1.... | Internal, single-image version of `local_mean_gauss`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"local_mean_gauss",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L691-L702 |
loli/medpy | medpy/features/intensity.py | _extract_centerdistance | def _extract_centerdistance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `centerdistance`.
"""
image = numpy.array(image, copy=False)
if None == voxelspacing:
voxelspacing = [1.] * image.ndim
# get image center and an array holding ... | python | def _extract_centerdistance(image, mask = slice(None), voxelspacing = None):
"""
Internal, single-image version of `centerdistance`.
"""
image = numpy.array(image, copy=False)
if None == voxelspacing:
voxelspacing = [1.] * image.ndim
# get image center and an array holding ... | [
"def",
"_extract_centerdistance",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"voxelspacing",
"=",
"None",
")",
":",
"image",
"=",
"numpy",
".",
"array",
"(",
"image",
",",
"copy",
"=",
"False",
")",
"if",
"None",
"==",
"voxelspacin... | Internal, single-image version of `centerdistance`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"centerdistance",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L705-L724 |
loli/medpy | medpy/features/intensity.py | _extract_intensities | def _extract_intensities(image, mask = slice(None)):
"""
Internal, single-image version of `intensities`.
"""
return numpy.array(image, copy=True)[mask].ravel() | python | def _extract_intensities(image, mask = slice(None)):
"""
Internal, single-image version of `intensities`.
"""
return numpy.array(image, copy=True)[mask].ravel() | [
"def",
"_extract_intensities",
"(",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
")",
":",
"return",
"numpy",
".",
"array",
"(",
"image",
",",
"copy",
"=",
"True",
")",
"[",
"mask",
"]",
".",
"ravel",
"(",
")"
] | Internal, single-image version of `intensities`. | [
"Internal",
"single",
"-",
"image",
"version",
"of",
"intensities",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L727-L731 |
loli/medpy | medpy/features/intensity.py | _substract_hemispheres | def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing):
"""
Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image.
"""
active_kernel = _create_structure_array(active_sigma, voxel_spacin... | python | def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing):
"""
Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image.
"""
active_kernel = _create_structure_array(active_sigma, voxel_spacin... | [
"def",
"_substract_hemispheres",
"(",
"active",
",",
"reference",
",",
"active_sigma",
",",
"reference_sigma",
",",
"voxel_spacing",
")",
":",
"active_kernel",
"=",
"_create_structure_array",
"(",
"active_sigma",
",",
"voxel_spacing",
")",
"active_smoothed",
"=",
"gau... | Helper function for `_extract_hemispheric_difference`.
Smoothes both images and then substracts the reference from the active image. | [
"Helper",
"function",
"for",
"_extract_hemispheric_difference",
".",
"Smoothes",
"both",
"images",
"and",
"then",
"substracts",
"the",
"reference",
"from",
"the",
"active",
"image",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L733-L744 |
loli/medpy | medpy/features/intensity.py | _create_structure_array | def _create_structure_array(structure_array, voxelspacing):
"""
Convenient function to take a structure array (single number valid for all dimensions
or a sequence with a distinct number for each dimension) assumed to be in mm and
returns a structure array (a sequence) adapted to the image space using t... | python | def _create_structure_array(structure_array, voxelspacing):
"""
Convenient function to take a structure array (single number valid for all dimensions
or a sequence with a distinct number for each dimension) assumed to be in mm and
returns a structure array (a sequence) adapted to the image space using t... | [
"def",
"_create_structure_array",
"(",
"structure_array",
",",
"voxelspacing",
")",
":",
"try",
":",
"structure_array",
"=",
"[",
"s",
"/",
"float",
"(",
"vs",
")",
"for",
"s",
",",
"vs",
"in",
"zip",
"(",
"structure_array",
",",
"voxelspacing",
")",
"]",
... | Convenient function to take a structure array (single number valid for all dimensions
or a sequence with a distinct number for each dimension) assumed to be in mm and
returns a structure array (a sequence) adapted to the image space using the supplied
voxel spacing. | [
"Convenient",
"function",
"to",
"take",
"a",
"structure",
"array",
"(",
"single",
"number",
"valid",
"for",
"all",
"dimensions",
"or",
"a",
"sequence",
"with",
"a",
"distinct",
"number",
"for",
"each",
"dimension",
")",
"assumed",
"to",
"be",
"in",
"mm",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L746-L758 |
loli/medpy | medpy/features/intensity.py | _extract_feature | def _extract_feature(fun, image, mask = slice(None), **kwargs):
"""
Convenient function to cope with multi-spectral images and feature normalization.
Parameters
----------
fun : function
The feature extraction function to call
image : array_like or list/tuple of array_like
... | python | def _extract_feature(fun, image, mask = slice(None), **kwargs):
"""
Convenient function to cope with multi-spectral images and feature normalization.
Parameters
----------
fun : function
The feature extraction function to call
image : array_like or list/tuple of array_like
... | [
"def",
"_extract_feature",
"(",
"fun",
",",
"image",
",",
"mask",
"=",
"slice",
"(",
"None",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"type",
"(",
"mask",
")",
"is",
"slice",
":",
"mask",
"=",
"numpy",
".",
"array",
"(",
"mask",
",",
... | Convenient function to cope with multi-spectral images and feature normalization.
Parameters
----------
fun : function
The feature extraction function to call
image : array_like or list/tuple of array_like
A single image or a list/tuple of images (for multi-spectral case).
mask... | [
"Convenient",
"function",
"to",
"cope",
"with",
"multi",
"-",
"spectral",
"images",
"and",
"feature",
"normalization",
".",
"Parameters",
"----------",
"fun",
":",
"function",
"The",
"feature",
"extraction",
"function",
"to",
"call",
"image",
":",
"array_like",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L760-L781 |
loli/medpy | bin/medpy_extract_sub_volume_by_example.py | getArguments | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
# check output image exists if override not forced
if not args.force:
if os.path.exists(args.output + args.image[-4:]):
raise ArgumentError('The supplied ... | python | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
# check output image exists if override not forced
if not args.force:
if os.path.exists(args.output + args.image[-4:]):
raise ArgumentError('The supplied ... | [
"def",
"getArguments",
"(",
"parser",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"# check output image exists if override not forced",
"if",
"not",
"args",
".",
"force",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"args",
".",
"outpu... | 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_by_example.py#L132-L140 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._fill | def _fill(self, text = ""):
"Indent a piece of text, according to the current indentation level"
if self._do_indent:
self._write("\n"+" "*self._indent + text)
else:
self._write(text) | python | def _fill(self, text = ""):
"Indent a piece of text, according to the current indentation level"
if self._do_indent:
self._write("\n"+" "*self._indent + text)
else:
self._write(text) | [
"def",
"_fill",
"(",
"self",
",",
"text",
"=",
"\"\"",
")",
":",
"if",
"self",
".",
"_do_indent",
":",
"self",
".",
"_write",
"(",
"\"\\n\"",
"+",
"\" \"",
"*",
"self",
".",
"_indent",
"+",
"text",
")",
"else",
":",
"self",
".",
"_write",
"(",
... | Indent a piece of text, according to the current indentation level | [
"Indent",
"a",
"piece",
"of",
"text",
"according",
"to",
"the",
"current",
"indentation",
"level"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L60-L65 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._dispatch | def _dispatch(self, tree):
"_dispatcher function, _dispatching tree type T to method _T."
if isinstance(tree, list):
for t in tree:
self._dispatch(t)
return
meth = getattr(self, "_"+tree.__class__.__name__)
if tree.__class__.__name__ == 'NoneType' ... | python | def _dispatch(self, tree):
"_dispatcher function, _dispatching tree type T to method _T."
if isinstance(tree, list):
for t in tree:
self._dispatch(t)
return
meth = getattr(self, "_"+tree.__class__.__name__)
if tree.__class__.__name__ == 'NoneType' ... | [
"def",
"_dispatch",
"(",
"self",
",",
"tree",
")",
":",
"if",
"isinstance",
"(",
"tree",
",",
"list",
")",
":",
"for",
"t",
"in",
"tree",
":",
"self",
".",
"_dispatch",
"(",
"t",
")",
"return",
"meth",
"=",
"getattr",
"(",
"self",
",",
"\"_\"",
"... | _dispatcher function, _dispatching tree type T to method _T. | [
"_dispatcher",
"function",
"_dispatching",
"tree",
"type",
"T",
"to",
"method",
"_T",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L80-L89 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._AssAttr | def _AssAttr(self, t):
""" Handle assigning an attribute of an object
"""
self._dispatch(t.expr)
self._write('.'+t.attrname) | python | def _AssAttr(self, t):
""" Handle assigning an attribute of an object
"""
self._dispatch(t.expr)
self._write('.'+t.attrname) | [
"def",
"_AssAttr",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_dispatch",
"(",
"t",
".",
"expr",
")",
"self",
".",
"_write",
"(",
"'.'",
"+",
"t",
".",
"attrname",
")"
] | Handle assigning an attribute of an object | [
"Handle",
"assigning",
"an",
"attribute",
"of",
"an",
"object"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L110-L114 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Assign | def _Assign(self, t):
""" Expression Assignment such as "a = 1".
This only handles assignment in expressions. Keyword assignment
is handled separately.
"""
self._fill()
for target in t.nodes:
self._dispatch(target)
self._write(" = ")
... | python | def _Assign(self, t):
""" Expression Assignment such as "a = 1".
This only handles assignment in expressions. Keyword assignment
is handled separately.
"""
self._fill()
for target in t.nodes:
self._dispatch(target)
self._write(" = ")
... | [
"def",
"_Assign",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_fill",
"(",
")",
"for",
"target",
"in",
"t",
".",
"nodes",
":",
"self",
".",
"_dispatch",
"(",
"target",
")",
"self",
".",
"_write",
"(",
"\" = \"",
")",
"self",
".",
"_dispatch",
... | Expression Assignment such as "a = 1".
This only handles assignment in expressions. Keyword assignment
is handled separately. | [
"Expression",
"Assignment",
"such",
"as",
"a",
"=",
"1",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L116-L128 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._AssTuple | def _AssTuple(self, t):
""" Tuple on left hand side of an expression.
"""
# _write each elements, separated by a comma.
for element in t.nodes[:-1]:
self._dispatch(element)
self._write(", ")
# Handle the last one without writing comma
last_elemen... | python | def _AssTuple(self, t):
""" Tuple on left hand side of an expression.
"""
# _write each elements, separated by a comma.
for element in t.nodes[:-1]:
self._dispatch(element)
self._write(", ")
# Handle the last one without writing comma
last_elemen... | [
"def",
"_AssTuple",
"(",
"self",
",",
"t",
")",
":",
"# _write each elements, separated by a comma.",
"for",
"element",
"in",
"t",
".",
"nodes",
"[",
":",
"-",
"1",
"]",
":",
"self",
".",
"_dispatch",
"(",
"element",
")",
"self",
".",
"_write",
"(",
"\",... | Tuple on left hand side of an expression. | [
"Tuple",
"on",
"left",
"hand",
"side",
"of",
"an",
"expression",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L137-L148 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._AugAssign | def _AugAssign(self, t):
""" +=,-=,*=,/=,**=, etc. operations
"""
self._fill()
self._dispatch(t.node)
self._write(' '+t.op+' ')
self._dispatch(t.expr)
if not self._do_indent:
self._write(';') | python | def _AugAssign(self, t):
""" +=,-=,*=,/=,**=, etc. operations
"""
self._fill()
self._dispatch(t.node)
self._write(' '+t.op+' ')
self._dispatch(t.expr)
if not self._do_indent:
self._write(';') | [
"def",
"_AugAssign",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_fill",
"(",
")",
"self",
".",
"_dispatch",
"(",
"t",
".",
"node",
")",
"self",
".",
"_write",
"(",
"' '",
"+",
"t",
".",
"op",
"+",
"' '",
")",
"self",
".",
"_dispatch",
"(",
... | +=,-=,*=,/=,**=, etc. operations | [
"+",
"=",
"-",
"=",
"*",
"=",
"/",
"=",
"**",
"=",
"etc",
".",
"operations"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L150-L159 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._CallFunc | def _CallFunc(self, t):
""" Function call.
"""
self._dispatch(t.node)
self._write("(")
comma = False
for e in t.args:
if comma: self._write(", ")
else: comma = True
self._dispatch(e)
if t.star_args:
if comma: self._w... | python | def _CallFunc(self, t):
""" Function call.
"""
self._dispatch(t.node)
self._write("(")
comma = False
for e in t.args:
if comma: self._write(", ")
else: comma = True
self._dispatch(e)
if t.star_args:
if comma: self._w... | [
"def",
"_CallFunc",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_dispatch",
"(",
"t",
".",
"node",
")",
"self",
".",
"_write",
"(",
"\"(\"",
")",
"comma",
"=",
"False",
"for",
"e",
"in",
"t",
".",
"args",
":",
"if",
"comma",
":",
"self",
"."... | Function call. | [
"Function",
"call",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L183-L203 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._From | def _From(self, t):
""" Handle "from xyz import foo, bar as baz".
"""
# fixme: Are From and ImportFrom handled differently?
self._fill("from ")
self._write(t.modname)
self._write(" import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
... | python | def _From(self, t):
""" Handle "from xyz import foo, bar as baz".
"""
# fixme: Are From and ImportFrom handled differently?
self._fill("from ")
self._write(t.modname)
self._write(" import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
... | [
"def",
"_From",
"(",
"self",
",",
"t",
")",
":",
"# fixme: Are From and ImportFrom handled differently?",
"self",
".",
"_fill",
"(",
"\"from \"",
")",
"self",
".",
"_write",
"(",
"t",
".",
"modname",
")",
"self",
".",
"_write",
"(",
"\" import \"",
")",
"for... | Handle "from xyz import foo, bar as baz". | [
"Handle",
"from",
"xyz",
"import",
"foo",
"bar",
"as",
"baz",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L244-L256 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Function | def _Function(self, t):
""" Handle function definitions
"""
if t.decorators is not None:
self._fill("@")
self._dispatch(t.decorators)
self._fill("def "+t.name + "(")
defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
for i, ... | python | def _Function(self, t):
""" Handle function definitions
"""
if t.decorators is not None:
self._fill("@")
self._dispatch(t.decorators)
self._fill("def "+t.name + "(")
defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
for i, ... | [
"def",
"_Function",
"(",
"self",
",",
"t",
")",
":",
"if",
"t",
".",
"decorators",
"is",
"not",
"None",
":",
"self",
".",
"_fill",
"(",
"\"@\"",
")",
"self",
".",
"_dispatch",
"(",
"t",
".",
"decorators",
")",
"self",
".",
"_fill",
"(",
"\"def \"",... | Handle function definitions | [
"Handle",
"function",
"definitions"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L258-L279 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Getattr | def _Getattr(self, t):
""" Handle getting an attribute of an object
"""
if isinstance(t.expr, (Div, Mul, Sub, Add)):
self._write('(')
self._dispatch(t.expr)
self._write(')')
else:
self._dispatch(t.expr)
self._write('.'+... | python | def _Getattr(self, t):
""" Handle getting an attribute of an object
"""
if isinstance(t.expr, (Div, Mul, Sub, Add)):
self._write('(')
self._dispatch(t.expr)
self._write(')')
else:
self._dispatch(t.expr)
self._write('.'+... | [
"def",
"_Getattr",
"(",
"self",
",",
"t",
")",
":",
"if",
"isinstance",
"(",
"t",
".",
"expr",
",",
"(",
"Div",
",",
"Mul",
",",
"Sub",
",",
"Add",
")",
")",
":",
"self",
".",
"_write",
"(",
"'('",
")",
"self",
".",
"_dispatch",
"(",
"t",
"."... | Handle getting an attribute of an object | [
"Handle",
"getting",
"an",
"attribute",
"of",
"an",
"object"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L281-L291 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Import | def _Import(self, t):
""" Handle "import xyz.foo".
"""
self._fill("import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
self._write(", ")
self._write(name)
if asname is not None:
self._write(" as "+a... | python | def _Import(self, t):
""" Handle "import xyz.foo".
"""
self._fill("import ")
for i, (name,asname) in enumerate(t.names):
if i != 0:
self._write(", ")
self._write(name)
if asname is not None:
self._write(" as "+a... | [
"def",
"_Import",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_fill",
"(",
"\"import \"",
")",
"for",
"i",
",",
"(",
"name",
",",
"asname",
")",
"in",
"enumerate",
"(",
"t",
".",
"names",
")",
":",
"if",
"i",
"!=",
"0",
":",
"self",
".",
"... | Handle "import xyz.foo". | [
"Handle",
"import",
"xyz",
".",
"foo",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L326-L336 |
loli/medpy | doc/numpydoc/numpydoc/compiler_unparse.py | UnparseCompilerAst._Keyword | def _Keyword(self, t):
""" Keyword value assignment within function calls and definitions.
"""
self._write(t.name)
self._write("=")
self._dispatch(t.expr) | python | def _Keyword(self, t):
""" Keyword value assignment within function calls and definitions.
"""
self._write(t.name)
self._write("=")
self._dispatch(t.expr) | [
"def",
"_Keyword",
"(",
"self",
",",
"t",
")",
":",
"self",
".",
"_write",
"(",
"t",
".",
"name",
")",
"self",
".",
"_write",
"(",
"\"=\"",
")",
"self",
".",
"_dispatch",
"(",
"t",
".",
"expr",
")"
] | Keyword value assignment within function calls and definitions. | [
"Keyword",
"value",
"assignment",
"within",
"function",
"calls",
"and",
"definitions",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L338-L343 |
loli/medpy | medpy/utilities/argparseu.py | existingDirectory | def existingDirectory(string):
"""
A custom type for the argparse commandline parser.
Check whether the supplied string points to a valid directory.
Examples
--------
>>> parser.add_argument('argname', type=existingDirectory, help='help')
"""
if not os.path.isdir(string):
... | python | def existingDirectory(string):
"""
A custom type for the argparse commandline parser.
Check whether the supplied string points to a valid directory.
Examples
--------
>>> parser.add_argument('argname', type=existingDirectory, help='help')
"""
if not os.path.isdir(string):
... | [
"def",
"existingDirectory",
"(",
"string",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"string",
")",
":",
"argparse",
".",
"ArgumentTypeError",
"(",
"'{} is not a valid directory.'",
".",
"format",
"(",
"string",
")",
")",
"return",
"string... | A custom type for the argparse commandline parser.
Check whether the supplied string points to a valid directory.
Examples
--------
>>> parser.add_argument('argname', type=existingDirectory, help='help') | [
"A",
"custom",
"type",
"for",
"the",
"argparse",
"commandline",
"parser",
".",
"Check",
"whether",
"the",
"supplied",
"string",
"points",
"to",
"a",
"valid",
"directory",
".",
"Examples",
"--------",
">>>",
"parser",
".",
"add_argument",
"(",
"argname",
"type"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/utilities/argparseu.py#L31-L43 |
loli/medpy | medpy/utilities/argparseu.py | __sequenceAscendingStrict | def __sequenceAscendingStrict(l):
"Test a sequences values to be in strictly ascending order."
it = iter(l)
next(it)
if not all(b > a for a, b in zip(l, it)):
raise argparse.ArgumentTypeError('All values must be given in strictly ascending order.')
return l | python | def __sequenceAscendingStrict(l):
"Test a sequences values to be in strictly ascending order."
it = iter(l)
next(it)
if not all(b > a for a, b in zip(l, it)):
raise argparse.ArgumentTypeError('All values must be given in strictly ascending order.')
return l | [
"def",
"__sequenceAscendingStrict",
"(",
"l",
")",
":",
"it",
"=",
"iter",
"(",
"l",
")",
"next",
"(",
"it",
")",
"if",
"not",
"all",
"(",
"b",
">",
"a",
"for",
"a",
",",
"b",
"in",
"zip",
"(",
"l",
",",
"it",
")",
")",
":",
"raise",
"argpars... | Test a sequences values to be in strictly ascending order. | [
"Test",
"a",
"sequences",
"values",
"to",
"be",
"in",
"strictly",
"ascending",
"order",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/utilities/argparseu.py#L238-L244 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.train | def train(self, images):
r"""
Train a standard intensity space and an associated transformation model.
Note that the passed images should be masked to contain only the foreground.
Parameters
----------
images : sequence of array_likes
A numbe... | python | def train(self, images):
r"""
Train a standard intensity space and an associated transformation model.
Note that the passed images should be masked to contain only the foreground.
Parameters
----------
images : sequence of array_likes
A numbe... | [
"def",
"train",
"(",
"self",
",",
"images",
")",
":",
"self",
".",
"__stdrange",
"=",
"self",
".",
"__compute_stdrange",
"(",
"images",
")",
"lim",
"=",
"[",
"]",
"for",
"idx",
",",
"i",
"in",
"enumerate",
"(",
"images",
")",
":",
"ci",
"=",
"numpy... | r"""
Train a standard intensity space and an associated transformation model.
Note that the passed images should be masked to contain only the foreground.
Parameters
----------
images : sequence of array_likes
A number of images.
Ret... | [
"r",
"Train",
"a",
"standard",
"intensity",
"space",
"and",
"an",
"associated",
"transformation",
"model",
".",
"Note",
"that",
"the",
"passed",
"images",
"should",
"be",
"masked",
"to",
"contain",
"only",
"the",
"foreground",
".",
"Parameters",
"----------",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L244-L277 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.transform | def transform(self, image, surpress_mapping_check = False):
r"""
Transform an images intensity values to the learned standard intensity space.
Note that the passed image should be masked to contain only the foreground.
The transformation is guaranteed to be lossless i.e... | python | def transform(self, image, surpress_mapping_check = False):
r"""
Transform an images intensity values to the learned standard intensity space.
Note that the passed image should be masked to contain only the foreground.
The transformation is guaranteed to be lossless i.e... | [
"def",
"transform",
"(",
"self",
",",
"image",
",",
"surpress_mapping_check",
"=",
"False",
")",
":",
"if",
"None",
"==",
"self",
".",
"__model",
":",
"raise",
"UntrainedException",
"(",
"'Model not trained. Call train() first.'",
")",
"image",
"=",
"numpy",
"."... | r"""
Transform an images intensity values to the learned standard intensity space.
Note that the passed image should be masked to contain only the foreground.
The transformation is guaranteed to be lossless i.e. a one-to-one mapping between
old and new intensity values ... | [
"r",
"Transform",
"an",
"images",
"intensity",
"values",
"to",
"the",
"learned",
"standard",
"intensity",
"space",
".",
"Note",
"that",
"the",
"passed",
"image",
"should",
"be",
"masked",
"to",
"contain",
"only",
"the",
"foreground",
".",
"The",
"transformatio... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L279-L337 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.train_transform | def train_transform(self, images, surpress_mapping_check = False):
r"""
See also
--------
train, transform
"""
ret = self.train(images)
outputs = [self.transform(i, surpress_mapping_check) for i in images]
return ret, outputs | python | def train_transform(self, images, surpress_mapping_check = False):
r"""
See also
--------
train, transform
"""
ret = self.train(images)
outputs = [self.transform(i, surpress_mapping_check) for i in images]
return ret, outputs | [
"def",
"train_transform",
"(",
"self",
",",
"images",
",",
"surpress_mapping_check",
"=",
"False",
")",
":",
"ret",
"=",
"self",
".",
"train",
"(",
"images",
")",
"outputs",
"=",
"[",
"self",
".",
"transform",
"(",
"i",
",",
"surpress_mapping_check",
")",
... | r"""
See also
--------
train, transform | [
"r",
"See",
"also",
"--------",
"train",
"transform"
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L339-L347 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.__compute_stdrange | def __compute_stdrange(self, images):
r"""
Computes a common standard intensity range over a number of images.
Depending on the settings of the internal self.__stdrange variable,
either (1) the already fixed values are returned, (2) a complete standard
intensity range is... | python | def __compute_stdrange(self, images):
r"""
Computes a common standard intensity range over a number of images.
Depending on the settings of the internal self.__stdrange variable,
either (1) the already fixed values are returned, (2) a complete standard
intensity range is... | [
"def",
"__compute_stdrange",
"(",
"self",
",",
"images",
")",
":",
"if",
"not",
"'auto'",
"in",
"self",
".",
"__stdrange",
":",
"return",
"self",
".",
"__stdrange",
"copl",
",",
"copu",
"=",
"self",
".",
"__cutoffp",
"# collect cutoff + landmark percentile segme... | r"""
Computes a common standard intensity range over a number of images.
Depending on the settings of the internal self.__stdrange variable,
either (1) the already fixed values are returned, (2) a complete standard
intensity range is computed from the supplied images, (3) an int... | [
"r",
"Computes",
"a",
"common",
"standard",
"intensity",
"range",
"over",
"a",
"number",
"of",
"images",
".",
"Depending",
"on",
"the",
"settings",
"of",
"the",
"internal",
"self",
".",
"__stdrange",
"variable",
"either",
"(",
"1",
")",
"the",
"already",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L369-L457 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.__check_mapping | def __check_mapping(self, landmarks):
"""
Checks whether the image, from which the supplied landmarks were extracted, can
be transformed to the learned standard intensity space without loss of
information.
"""
sc_udiff = numpy.asarray(self.__sc_umaxs)[1:] - numpy.asarray(... | python | def __check_mapping(self, landmarks):
"""
Checks whether the image, from which the supplied landmarks were extracted, can
be transformed to the learned standard intensity space without loss of
information.
"""
sc_udiff = numpy.asarray(self.__sc_umaxs)[1:] - numpy.asarray(... | [
"def",
"__check_mapping",
"(",
"self",
",",
"landmarks",
")",
":",
"sc_udiff",
"=",
"numpy",
".",
"asarray",
"(",
"self",
".",
"__sc_umaxs",
")",
"[",
"1",
":",
"]",
"-",
"numpy",
".",
"asarray",
"(",
"self",
".",
"__sc_umins",
")",
"[",
":",
"-",
... | Checks whether the image, from which the supplied landmarks were extracted, can
be transformed to the learned standard intensity space without loss of
information. | [
"Checks",
"whether",
"the",
"image",
"from",
"which",
"the",
"supplied",
"landmarks",
"were",
"extracted",
"can",
"be",
"transformed",
"to",
"the",
"learned",
"standard",
"intensity",
"space",
"without",
"loss",
"of",
"information",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L459-L467 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.is_in_interval | def is_in_interval(n, l, r, border = 'included'):
"""
Checks whether a number is inside the interval l, r.
"""
if 'included' == border:
return (n >= l) and (n <= r)
elif 'excluded' == border:
return (n > l) and (n < r)
else:
raise Value... | python | def is_in_interval(n, l, r, border = 'included'):
"""
Checks whether a number is inside the interval l, r.
"""
if 'included' == border:
return (n >= l) and (n <= r)
elif 'excluded' == border:
return (n > l) and (n < r)
else:
raise Value... | [
"def",
"is_in_interval",
"(",
"n",
",",
"l",
",",
"r",
",",
"border",
"=",
"'included'",
")",
":",
"if",
"'included'",
"==",
"border",
":",
"return",
"(",
"n",
">=",
"l",
")",
"and",
"(",
"n",
"<=",
"r",
")",
"elif",
"'excluded'",
"==",
"border",
... | Checks whether a number is inside the interval l, r. | [
"Checks",
"whether",
"a",
"number",
"is",
"inside",
"the",
"interval",
"l",
"r",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L497-L506 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.are_in_interval | def are_in_interval(s, l, r, border = 'included'):
"""
Checks whether all number in the sequence s lie inside the interval formed by
l and r.
"""
return numpy.all([IntensityRangeStandardization.is_in_interval(x, l, r, border) for x in s]) | python | def are_in_interval(s, l, r, border = 'included'):
"""
Checks whether all number in the sequence s lie inside the interval formed by
l and r.
"""
return numpy.all([IntensityRangeStandardization.is_in_interval(x, l, r, border) for x in s]) | [
"def",
"are_in_interval",
"(",
"s",
",",
"l",
",",
"r",
",",
"border",
"=",
"'included'",
")",
":",
"return",
"numpy",
".",
"all",
"(",
"[",
"IntensityRangeStandardization",
".",
"is_in_interval",
"(",
"x",
",",
"l",
",",
"r",
",",
"border",
")",
"for"... | Checks whether all number in the sequence s lie inside the interval formed by
l and r. | [
"Checks",
"whether",
"all",
"number",
"in",
"the",
"sequence",
"s",
"lie",
"inside",
"the",
"interval",
"formed",
"by",
"l",
"and",
"r",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L509-L514 |
loli/medpy | medpy/filter/IntensityRangeStandardization.py | IntensityRangeStandardization.linear_model | def linear_model(x, y):
"""
Returns a linear model transformation function fitted on the two supplied points.
y = m*x + b
Note: Assumes that slope > 0, otherwise division through zero might occur.
"""
x1, x2 = x
y1, y2 = y
m = (y2 - y1) / (x2 - x1)
... | python | def linear_model(x, y):
"""
Returns a linear model transformation function fitted on the two supplied points.
y = m*x + b
Note: Assumes that slope > 0, otherwise division through zero might occur.
"""
x1, x2 = x
y1, y2 = y
m = (y2 - y1) / (x2 - x1)
... | [
"def",
"linear_model",
"(",
"x",
",",
"y",
")",
":",
"x1",
",",
"x2",
"=",
"x",
"y1",
",",
"y2",
"=",
"y",
"m",
"=",
"(",
"y2",
"-",
"y1",
")",
"/",
"(",
"x2",
"-",
"x1",
")",
"b",
"=",
"y1",
"-",
"(",
"m",
"*",
"x1",
")",
"return",
"... | Returns a linear model transformation function fitted on the two supplied points.
y = m*x + b
Note: Assumes that slope > 0, otherwise division through zero might occur. | [
"Returns",
"a",
"linear",
"model",
"transformation",
"function",
"fitted",
"on",
"the",
"two",
"supplied",
"points",
".",
"y",
"=",
"m",
"*",
"x",
"+",
"b",
"Note",
":",
"Assumes",
"that",
"slope",
">",
"0",
"otherwise",
"division",
"through",
"zero",
"m... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L524-L534 |
loli/medpy | medpy/filter/houghtransform.py | ght_alternative | def ght_alternative (img, template, indices):
"""
Alternative implementation of the general hough transform, which uses iteration over
indices rather than broadcasting rules like `ght`.
It is therefore considerably slower, especially for large, multi-dimensional arrays.
The only application are... | python | def ght_alternative (img, template, indices):
"""
Alternative implementation of the general hough transform, which uses iteration over
indices rather than broadcasting rules like `ght`.
It is therefore considerably slower, especially for large, multi-dimensional arrays.
The only application are... | [
"def",
"ght_alternative",
"(",
"img",
",",
"template",
",",
"indices",
")",
":",
"# cast template to bool and img to numpy array",
"img",
"=",
"numpy",
".",
"asarray",
"(",
"img",
")",
"template",
"=",
"numpy",
".",
"asarray",
"(",
"template",
")",
".",
"astyp... | Alternative implementation of the general hough transform, which uses iteration over
indices rather than broadcasting rules like `ght`.
It is therefore considerably slower, especially for large, multi-dimensional arrays.
The only application are cases, where the hough transform should only be computed ... | [
"Alternative",
"implementation",
"of",
"the",
"general",
"hough",
"transform",
"which",
"uses",
"iteration",
"over",
"indices",
"rather",
"than",
"broadcasting",
"rules",
"like",
"ght",
".",
"It",
"is",
"therefore",
"considerably",
"slower",
"especially",
"for",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/houghtransform.py#L31-L80 |
loli/medpy | medpy/filter/houghtransform.py | ght | def ght(img, template):
r"""
Implementation of the general hough transform for all dimensions.
Providing a template, this method searches in the image for structures similar to the
one depicted by the template. The returned hough image denotes how well the structure
fit in each index.
... | python | def ght(img, template):
r"""
Implementation of the general hough transform for all dimensions.
Providing a template, this method searches in the image for structures similar to the
one depicted by the template. The returned hough image denotes how well the structure
fit in each index.
... | [
"def",
"ght",
"(",
"img",
",",
"template",
")",
":",
"# cast template to bool and img to numpy array",
"img",
"=",
"numpy",
".",
"asarray",
"(",
"img",
")",
"template",
"=",
"numpy",
".",
"asarray",
"(",
"template",
")",
".",
"astype",
"(",
"numpy",
".",
"... | r"""
Implementation of the general hough transform for all dimensions.
Providing a template, this method searches in the image for structures similar to the
one depicted by the template. The returned hough image denotes how well the structure
fit in each index.
The indices of the returned ... | [
"r",
"Implementation",
"of",
"the",
"general",
"hough",
"transform",
"for",
"all",
"dimensions",
".",
"Providing",
"a",
"template",
"this",
"method",
"searches",
"in",
"the",
"image",
"for",
"structures",
"similar",
"to",
"the",
"one",
"depicted",
"by",
"the",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/houghtransform.py#L82-L154 |
loli/medpy | medpy/filter/houghtransform.py | template_sphere | def template_sphere (radius, dimensions):
r"""
Returns a spherical binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
radius : integer
The circles radius in voxels.
dimensions : integer
Th... | python | def template_sphere (radius, dimensions):
r"""
Returns a spherical binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
radius : integer
The circles radius in voxels.
dimensions : integer
Th... | [
"def",
"template_sphere",
"(",
"radius",
",",
"dimensions",
")",
":",
"if",
"int",
"(",
"dimensions",
")",
"!=",
"dimensions",
":",
"raise",
"TypeError",
"(",
"'The supplied dimension parameter must be of type integer.'",
")",
"dimensions",
"=",
"int",
"(",
"dimensi... | r"""
Returns a spherical binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
radius : integer
The circles radius in voxels.
dimensions : integer
The dimensionality of the circle
Returns
... | [
"r",
"Returns",
"a",
"spherical",
"binary",
"structure",
"of",
"a",
"of",
"the",
"supplied",
"radius",
"that",
"can",
"be",
"used",
"as",
"template",
"input",
"to",
"the",
"generalized",
"hough",
"transform",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/houghtransform.py#L156-L177 |
loli/medpy | medpy/filter/houghtransform.py | template_ellipsoid | def template_ellipsoid(shape):
r"""
Returns an ellipsoid binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
shape : tuple of integers
The main axes of the ellipsoid in voxel units.
Return... | python | def template_ellipsoid(shape):
r"""
Returns an ellipsoid binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
shape : tuple of integers
The main axes of the ellipsoid in voxel units.
Return... | [
"def",
"template_ellipsoid",
"(",
"shape",
")",
":",
"# prepare template array",
"template",
"=",
"numpy",
".",
"zeros",
"(",
"[",
"int",
"(",
"x",
"//",
"2",
"+",
"(",
"x",
"%",
"2",
")",
")",
"for",
"x",
"in",
"shape",
"]",
",",
"dtype",
"=",
"nu... | r"""
Returns an ellipsoid binary structure of a of the supplied radius that can be used as
template input to the generalized hough transform.
Parameters
----------
shape : tuple of integers
The main axes of the ellipsoid in voxel units.
Returns
-------
template_sphere :... | [
"r",
"Returns",
"an",
"ellipsoid",
"binary",
"structure",
"of",
"a",
"of",
"the",
"supplied",
"radius",
"that",
"can",
"be",
"used",
"as",
"template",
"input",
"to",
"the",
"generalized",
"hough",
"transform",
".",
"Parameters",
"----------",
"shape",
":",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/houghtransform.py#L180-L226 |
loli/medpy | medpy/graphcut/write.py | graph_to_dimacs | def graph_to_dimacs(g, f):
"""
Persists the supplied graph in valid dimacs format into the file.
Parameters
----------
g : `~medpy.graphcut.graph.Graph`
A graph object to persist.
f : file
A file-like object.
"""
# write comments
f.write('c Created by medpy\n')
... | python | def graph_to_dimacs(g, f):
"""
Persists the supplied graph in valid dimacs format into the file.
Parameters
----------
g : `~medpy.graphcut.graph.Graph`
A graph object to persist.
f : file
A file-like object.
"""
# write comments
f.write('c Created by medpy\n')
... | [
"def",
"graph_to_dimacs",
"(",
"g",
",",
"f",
")",
":",
"# write comments",
"f",
".",
"write",
"(",
"'c Created by medpy\\n'",
")",
"f",
".",
"write",
"(",
"'c Oskar Maier, oskar.maier@googlemail.com\\n'",
")",
"f",
".",
"write",
"(",
"'c\\n'",
")",
"# write pro... | Persists the supplied graph in valid dimacs format into the file.
Parameters
----------
g : `~medpy.graphcut.graph.Graph`
A graph object to persist.
f : file
A file-like object. | [
"Persists",
"the",
"supplied",
"graph",
"in",
"valid",
"dimacs",
"format",
"into",
"the",
"file",
".",
"Parameters",
"----------",
"g",
":",
"~medpy",
".",
"graphcut",
".",
"graph",
".",
"Graph",
"A",
"graph",
"object",
"to",
"persist",
".",
"f",
":",
"f... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/write.py#L28-L73 |
loli/medpy | doc/numpydoc/numpydoc/traitsdoc.py | looks_like_issubclass | def looks_like_issubclass(obj, classname):
""" Return True if the object has a class or superclass with the given class
name.
Ignores old-style classes.
"""
t = obj
if t.__name__ == classname:
return True
for klass in t.__mro__:
if klass.__name__ == classname:
re... | python | def looks_like_issubclass(obj, classname):
""" Return True if the object has a class or superclass with the given class
name.
Ignores old-style classes.
"""
t = obj
if t.__name__ == classname:
return True
for klass in t.__mro__:
if klass.__name__ == classname:
re... | [
"def",
"looks_like_issubclass",
"(",
"obj",
",",
"classname",
")",
":",
"t",
"=",
"obj",
"if",
"t",
".",
"__name__",
"==",
"classname",
":",
"return",
"True",
"for",
"klass",
"in",
"t",
".",
"__mro__",
":",
"if",
"klass",
".",
"__name__",
"==",
"classn... | Return True if the object has a class or superclass with the given class
name.
Ignores old-style classes. | [
"Return",
"True",
"if",
"the",
"object",
"has",
"a",
"class",
"or",
"superclass",
"with",
"the",
"given",
"class",
"name",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/traitsdoc.py#L102-L114 |
loli/medpy | medpy/neighbours/knn.py | mkneighbors_graph | def mkneighbors_graph(observations, n_neighbours, metric, mode='connectivity', metric_params = None):
"""
Computes the (weighted) graph of mutual k-Neighbors for observations.
Notes
-----
The distance between an observation and itself is never computed and instead set to
``numpy.inf``. I.e.... | python | def mkneighbors_graph(observations, n_neighbours, metric, mode='connectivity', metric_params = None):
"""
Computes the (weighted) graph of mutual k-Neighbors for observations.
Notes
-----
The distance between an observation and itself is never computed and instead set to
``numpy.inf``. I.e.... | [
"def",
"mkneighbors_graph",
"(",
"observations",
",",
"n_neighbours",
",",
"metric",
",",
"mode",
"=",
"'connectivity'",
",",
"metric_params",
"=",
"None",
")",
":",
"# compute their pairwise-distances",
"pdists",
"=",
"pdist",
"(",
"observations",
",",
"metric",
... | Computes the (weighted) graph of mutual k-Neighbors for observations.
Notes
-----
The distance between an observation and itself is never computed and instead set to
``numpy.inf``. I.e. only in the case of k>=n_observations or when the ``metric``
returns ``numpy.inf``, the returned graph can co... | [
"Computes",
"the",
"(",
"weighted",
")",
"graph",
"of",
"mutual",
"k",
"-",
"Neighbors",
"for",
"observations",
".",
"Notes",
"-----",
"The",
"distance",
"between",
"an",
"observation",
"and",
"itself",
"is",
"never",
"computed",
"and",
"instead",
"set",
"to... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/neighbours/knn.py#L34-L93 |
loli/medpy | medpy/neighbours/knn.py | pdist | def pdist(objects, dmeasure, diagval = numpy.inf):
"""
Compute the pair-wise distances between arbitrary objects.
Notes
-----
``dmeasure`` is assumed to be *symmetry* i.e. between object *a* and object *b* the
function will be called only ones.
Parameters
----------
objects... | python | def pdist(objects, dmeasure, diagval = numpy.inf):
"""
Compute the pair-wise distances between arbitrary objects.
Notes
-----
``dmeasure`` is assumed to be *symmetry* i.e. between object *a* and object *b* the
function will be called only ones.
Parameters
----------
objects... | [
"def",
"pdist",
"(",
"objects",
",",
"dmeasure",
",",
"diagval",
"=",
"numpy",
".",
"inf",
")",
":",
"out",
"=",
"numpy",
".",
"zeros",
"(",
"[",
"len",
"(",
"objects",
")",
"]",
"*",
"2",
",",
"numpy",
".",
"float",
")",
"numpy",
".",
"fill_diag... | Compute the pair-wise distances between arbitrary objects.
Notes
-----
``dmeasure`` is assumed to be *symmetry* i.e. between object *a* and object *b* the
function will be called only ones.
Parameters
----------
objects : sequence
A sequence of objects of length *n*.
dm... | [
"Compute",
"the",
"pair",
"-",
"wise",
"distances",
"between",
"arbitrary",
"objects",
".",
"Notes",
"-----",
"dmeasure",
"is",
"assumed",
"to",
"be",
"*",
"symmetry",
"*",
"i",
".",
"e",
".",
"between",
"object",
"*",
"a",
"*",
"and",
"object",
"*",
"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/neighbours/knn.py#L95-L122 |
loli/medpy | medpy/core/logger.py | Logger.setHandler | def setHandler(self, hdlr):
r"""Replace the current handler with a new one.
Parameters
----------
hdlr : logging.Handler
A subclass of Handler that should used to handle the logging output.
Notes
-----
If none should be replaces, but... | python | def setHandler(self, hdlr):
r"""Replace the current handler with a new one.
Parameters
----------
hdlr : logging.Handler
A subclass of Handler that should used to handle the logging output.
Notes
-----
If none should be replaces, but... | [
"def",
"setHandler",
"(",
"self",
",",
"hdlr",
")",
":",
"if",
"None",
"!=",
"self",
".",
"_handler",
":",
"self",
".",
"removeHandler",
"(",
"self",
".",
"_handler",
")",
"self",
".",
"_handler",
"=",
"hdlr",
"self",
".",
"addHandler",
"(",
"self",
... | r"""Replace the current handler with a new one.
Parameters
----------
hdlr : logging.Handler
A subclass of Handler that should used to handle the logging output.
Notes
-----
If none should be replaces, but just one added, use the parent clas... | [
"r",
"Replace",
"the",
"current",
"handler",
"with",
"a",
"new",
"one",
".",
"Parameters",
"----------",
"hdlr",
":",
"logging",
".",
"Handler",
"A",
"subclass",
"of",
"Handler",
"that",
"should",
"used",
"to",
"handle",
"the",
"logging",
"output",
".",
"N... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/core/logger.py#L103-L119 |
loli/medpy | medpy/core/logger.py | Logger.setLevel | def setLevel(self, level):
r"""Overrides the parent method to adapt the formatting string to the level.
Parameters
----------
level : int
The new log level to set. See the logging levels in the logging module for details.
Examples
-------... | python | def setLevel(self, level):
r"""Overrides the parent method to adapt the formatting string to the level.
Parameters
----------
level : int
The new log level to set. See the logging levels in the logging module for details.
Examples
-------... | [
"def",
"setLevel",
"(",
"self",
",",
"level",
")",
":",
"if",
"logging",
".",
"DEBUG",
">=",
"level",
":",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"\"%(asctime)s [%(levelname)-8s] %(message)s (in %(module)s.%(funcName)s:%(lineno)s)\"",
",",
"\"%d.%m.%Y %H:%M... | r"""Overrides the parent method to adapt the formatting string to the level.
Parameters
----------
level : int
The new log level to set. See the logging levels in the logging module for details.
Examples
--------
>>> import logging
... | [
"r",
"Overrides",
"the",
"parent",
"method",
"to",
"adapt",
"the",
"formatting",
"string",
"to",
"the",
"level",
".",
"Parameters",
"----------",
"level",
":",
"int",
"The",
"new",
"log",
"level",
"to",
"set",
".",
"See",
"the",
"logging",
"levels",
"in",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/core/logger.py#L121-L143 |
loli/medpy | medpy/filter/utilities.py | xminus1d | def xminus1d(img, fun, dim, *args, **kwargs):
r"""
Applies the function fun along all X-1D dimensional volumes of the images img
dimension dim.
E.g. you want to apply a gauss filter to each slice of a 3D MRI brain image,
simply supply the function as fun, the image as img and the dimension alon... | python | def xminus1d(img, fun, dim, *args, **kwargs):
r"""
Applies the function fun along all X-1D dimensional volumes of the images img
dimension dim.
E.g. you want to apply a gauss filter to each slice of a 3D MRI brain image,
simply supply the function as fun, the image as img and the dimension alon... | [
"def",
"xminus1d",
"(",
"img",
",",
"fun",
",",
"dim",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"slicer",
"=",
"[",
"slice",
"(",
"None",
")",
"]",
"*",
"img",
".",
"ndim",
"output",
"=",
"[",
"]",
"for",
"slid",
"in",
"range",
"(... | r"""
Applies the function fun along all X-1D dimensional volumes of the images img
dimension dim.
E.g. you want to apply a gauss filter to each slice of a 3D MRI brain image,
simply supply the function as fun, the image as img and the dimension along which
to iterate as dim.
Parameters... | [
"r",
"Applies",
"the",
"function",
"fun",
"along",
"all",
"X",
"-",
"1D",
"dimensional",
"volumes",
"of",
"the",
"images",
"img",
"dimension",
"dim",
".",
"E",
".",
"g",
".",
"you",
"want",
"to",
"apply",
"a",
"gauss",
"filter",
"to",
"each",
"slice",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/utilities.py#L31-L63 |
loli/medpy | medpy/filter/utilities.py | pad | def pad(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0):
r"""
Returns a copy of the input, padded by the supplied structuring element.
In the case of odd dimensionality, the structure element will be centered as
following on the currently processed position::
[... | python | def pad(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0):
r"""
Returns a copy of the input, padded by the supplied structuring element.
In the case of odd dimensionality, the structure element will be centered as
following on the currently processed position::
[... | [
"def",
"pad",
"(",
"input",
",",
"size",
"=",
"None",
",",
"footprint",
"=",
"None",
",",
"output",
"=",
"None",
",",
"mode",
"=",
"\"reflect\"",
",",
"cval",
"=",
"0.0",
")",
":",
"input",
"=",
"numpy",
".",
"asarray",
"(",
"input",
")",
"if",
"... | r"""
Returns a copy of the input, padded by the supplied structuring element.
In the case of odd dimensionality, the structure element will be centered as
following on the currently processed position::
[[T, Tx, T],
[T, T , T]]
, where Tx denotes the center of the st... | [
"r",
"Returns",
"a",
"copy",
"of",
"the",
"input",
"padded",
"by",
"the",
"supplied",
"structuring",
"element",
".",
"In",
"the",
"case",
"of",
"odd",
"dimensionality",
"the",
"structure",
"element",
"will",
"be",
"centered",
"as",
"following",
"on",
"the",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/utilities.py#L66-L179 |
loli/medpy | medpy/filter/utilities.py | intersection | def intersection(i1, h1, i2, h2):
r"""
Returns the intersecting parts of two images in real world coordinates.
Takes both, voxelspacing and image offset into account.
Note that the returned new offset might be inaccurate up to 1/2 voxel size for
each dimension due to ave... | python | def intersection(i1, h1, i2, h2):
r"""
Returns the intersecting parts of two images in real world coordinates.
Takes both, voxelspacing and image offset into account.
Note that the returned new offset might be inaccurate up to 1/2 voxel size for
each dimension due to ave... | [
"def",
"intersection",
"(",
"i1",
",",
"h1",
",",
"i2",
",",
"h2",
")",
":",
"# compute image bounding boxes in real-world coordinates",
"os1",
"=",
"numpy",
".",
"asarray",
"(",
"header",
".",
"get_offset",
"(",
"h1",
")",
")",
"ps1",
"=",
"numpy",
".",
"... | r"""
Returns the intersecting parts of two images in real world coordinates.
Takes both, voxelspacing and image offset into account.
Note that the returned new offset might be inaccurate up to 1/2 voxel size for
each dimension due to averaging.
Parameters
... | [
"r",
"Returns",
"the",
"intersecting",
"parts",
"of",
"two",
"images",
"in",
"real",
"world",
"coordinates",
".",
"Takes",
"both",
"voxelspacing",
"and",
"image",
"offset",
"into",
"account",
".",
"Note",
"that",
"the",
"returned",
"new",
"offset",
"might",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/utilities.py#L181-L244 |
loli/medpy | medpy/filter/utilities.py | __make_footprint | def __make_footprint(input, size, footprint):
"Creates a standard footprint element ala scipy.ndimage."
if footprint is None:
if size is None:
raise RuntimeError("no footprint or filter size provided")
sizes = _ni_support._normalize_sequence(size, input.ndim)
footprint = nump... | python | def __make_footprint(input, size, footprint):
"Creates a standard footprint element ala scipy.ndimage."
if footprint is None:
if size is None:
raise RuntimeError("no footprint or filter size provided")
sizes = _ni_support._normalize_sequence(size, input.ndim)
footprint = nump... | [
"def",
"__make_footprint",
"(",
"input",
",",
"size",
",",
"footprint",
")",
":",
"if",
"footprint",
"is",
"None",
":",
"if",
"size",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"no footprint or filter size provided\"",
")",
"sizes",
"=",
"_ni_support",
... | Creates a standard footprint element ala scipy.ndimage. | [
"Creates",
"a",
"standard",
"footprint",
"element",
"ala",
"scipy",
".",
"ndimage",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/utilities.py#L246-L255 |
loli/medpy | medpy/graphcut/energy_label.py | boundary_difference_of_means | def boundary_difference_of_means(graph, label_image, original_image): # label image is not required to hold continuous ids or to start from 1
r"""
Boundary term based on the difference of means between adjacent image regions.
An implementation of the boundary term, suitable to be used with the `~medpy.... | python | def boundary_difference_of_means(graph, label_image, original_image): # label image is not required to hold continuous ids or to start from 1
r"""
Boundary term based on the difference of means between adjacent image regions.
An implementation of the boundary term, suitable to be used with the `~medpy.... | [
"def",
"boundary_difference_of_means",
"(",
"graph",
",",
"label_image",
",",
"original_image",
")",
":",
"# label image is not required to hold continuous ids or to start from 1",
"# convert to arrays if necessary",
"label_image",
"=",
"scipy",
".",
"asarray",
"(",
"label_image"... | r"""
Boundary term based on the difference of means between adjacent image regions.
An implementation of the boundary term, suitable to be used with the `~medpy.graphcut.generate.graph_from_labels` function.
This simple energy function computes the mean values for all regions. The weights of
t... | [
"r",
"Boundary",
"term",
"based",
"on",
"the",
"difference",
"of",
"means",
"between",
"adjacent",
"image",
"regions",
".",
"An",
"implementation",
"of",
"the",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
"."... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L32-L108 |
loli/medpy | medpy/graphcut/energy_label.py | boundary_stawiaski | def boundary_stawiaski(graph, label_image, gradient_image): # label image is not required to hold continuous ids or to start from 1
r"""
Boundary term based on the sum of border voxel pairs differences.
An implementation of the boundary term in [1]_, suitable to be used with the `~medpy.graphcut.gener... | python | def boundary_stawiaski(graph, label_image, gradient_image): # label image is not required to hold continuous ids or to start from 1
r"""
Boundary term based on the sum of border voxel pairs differences.
An implementation of the boundary term in [1]_, suitable to be used with the `~medpy.graphcut.gener... | [
"def",
"boundary_stawiaski",
"(",
"graph",
",",
"label_image",
",",
"gradient_image",
")",
":",
"# label image is not required to hold continuous ids or to start from 1",
"# convert to arrays if necessary",
"label_image",
"=",
"scipy",
".",
"asarray",
"(",
"label_image",
")",
... | r"""
Boundary term based on the sum of border voxel pairs differences.
An implementation of the boundary term in [1]_, suitable to be used with the `~medpy.graphcut.generate.graph_from_labels` function.
Determines for each two supplied regions the voxels forming their border assuming
:math:`n... | [
"r",
"Boundary",
"term",
"based",
"on",
"the",
"sum",
"of",
"border",
"voxel",
"pairs",
"differences",
".",
"An",
"implementation",
"of",
"the",
"boundary",
"term",
"in",
"[",
"1",
"]",
"_",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L111-L193 |
loli/medpy | medpy/graphcut/energy_label.py | boundary_stawiaski_directed | def boundary_stawiaski_directed(graph, label_image, xxx_todo_changeme): # label image is not required to hold continuous ids or to start from 1
r"""
Boundary term based on the sum of border voxel pairs differences, directed version.
An implementation of the boundary term in [1]_, suitable to be used wi... | python | def boundary_stawiaski_directed(graph, label_image, xxx_todo_changeme): # label image is not required to hold continuous ids or to start from 1
r"""
Boundary term based on the sum of border voxel pairs differences, directed version.
An implementation of the boundary term in [1]_, suitable to be used wi... | [
"def",
"boundary_stawiaski_directed",
"(",
"graph",
",",
"label_image",
",",
"xxx_todo_changeme",
")",
":",
"# label image is not required to hold continuous ids or to start from 1",
"(",
"gradient_image",
",",
"directedness",
")",
"=",
"xxx_todo_changeme",
"label_image",
"=",
... | r"""
Boundary term based on the sum of border voxel pairs differences, directed version.
An implementation of the boundary term in [1]_, suitable to be used with the
`~medpy.graphcut.generate.graph_from_labels` function.
The basic definition of this term is the same as for `boundary_stawiaski`... | [
"r",
"Boundary",
"term",
"based",
"on",
"the",
"sum",
"of",
"border",
"voxel",
"pairs",
"differences",
"directed",
"version",
".",
"An",
"implementation",
"of",
"the",
"boundary",
"term",
"in",
"[",
"1",
"]",
"_",
"suitable",
"to",
"be",
"used",
"with",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L196-L317 |
loli/medpy | medpy/graphcut/energy_label.py | regional_atlas | def regional_atlas(graph, label_image, xxx_todo_changeme1): # label image is required to hold continuous ids starting from 1
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_labels` function.
... | python | def regional_atlas(graph, label_image, xxx_todo_changeme1): # label image is required to hold continuous ids starting from 1
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_labels` function.
... | [
"def",
"regional_atlas",
"(",
"graph",
",",
"label_image",
",",
"xxx_todo_changeme1",
")",
":",
"# label image is required to hold continuous ids starting from 1",
"(",
"probability_map",
",",
"alpha",
")",
"=",
"xxx_todo_changeme1",
"label_image",
"=",
"scipy",
".",
"asa... | 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_labels` function.
This regional term introduces statistical probability of a voxel to belong to the
object to segment. It computes the su... | [
"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_labels",
"function",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L319-L360 |
loli/medpy | medpy/graphcut/energy_label.py | __compute_edges_nd | def __compute_edges_nd(label_image):
"""
Computes the region neighbourhood defined by a star shaped n-dimensional structuring
element (as returned by scipy.ndimage.generate_binary_structure(ndim, 1)) for the
supplied region/label image.
Note The returned set contains neither duplicates, nor self-ref... | python | def __compute_edges_nd(label_image):
"""
Computes the region neighbourhood defined by a star shaped n-dimensional structuring
element (as returned by scipy.ndimage.generate_binary_structure(ndim, 1)) for the
supplied region/label image.
Note The returned set contains neither duplicates, nor self-ref... | [
"def",
"__compute_edges_nd",
"(",
"label_image",
")",
":",
"Er",
"=",
"set",
"(",
")",
"def",
"append",
"(",
"v1",
",",
"v2",
")",
":",
"if",
"v1",
"!=",
"v2",
":",
"Er",
".",
"update",
"(",
"[",
"(",
"min",
"(",
"v1",
",",
"v2",
")",
",",
"m... | Computes the region neighbourhood defined by a star shaped n-dimensional structuring
element (as returned by scipy.ndimage.generate_binary_structure(ndim, 1)) for the
supplied region/label image.
Note The returned set contains neither duplicates, nor self-references
(i.e. (id_1, id_1)), nor reversed ref... | [
"Computes",
"the",
"region",
"neighbourhood",
"defined",
"by",
"a",
"star",
"shaped",
"n",
"-",
"dimensional",
"structuring",
"element",
"(",
"as",
"returned",
"by",
"scipy",
".",
"ndimage",
".",
"generate_binary_structure",
"(",
"ndim",
"1",
"))",
"for",
"the... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L378-L405 |
loli/medpy | medpy/graphcut/energy_label.py | __check_label_image | def __check_label_image(label_image):
"""Check the label image for consistent labelling starting from 1."""
encountered_indices = scipy.unique(label_image)
expected_indices = scipy.arange(1, label_image.max() + 1)
if not encountered_indices.size == expected_indices.size or \
not (encountered_indi... | python | def __check_label_image(label_image):
"""Check the label image for consistent labelling starting from 1."""
encountered_indices = scipy.unique(label_image)
expected_indices = scipy.arange(1, label_image.max() + 1)
if not encountered_indices.size == expected_indices.size or \
not (encountered_indi... | [
"def",
"__check_label_image",
"(",
"label_image",
")",
":",
"encountered_indices",
"=",
"scipy",
".",
"unique",
"(",
"label_image",
")",
"expected_indices",
"=",
"scipy",
".",
"arange",
"(",
"1",
",",
"label_image",
".",
"max",
"(",
")",
"+",
"1",
")",
"if... | Check the label image for consistent labelling starting from 1. | [
"Check",
"the",
"label",
"image",
"for",
"consistent",
"labelling",
"starting",
"from",
"1",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L407-L413 |
loli/medpy | bin/medpy_join_masks.py | getParser | def getParser():
"Creates and returns the argparse parser object."
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
description=__description__)
parser.add_argument('output', help='Target volume.')
parser.add_argument('inputs', n... | python | def getParser():
"Creates and returns the argparse parser object."
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
description=__description__)
parser.add_argument('output', help='Target volume.')
parser.add_argument('inputs', n... | [
"def",
"getParser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
",",
"description",
"=",
"__description__",
")",
"parser",
".",
"add_argument",
"(",
"'output'",
",",
... | Creates and returns the argparse parser object. | [
"Creates",
"and",
"returns",
"the",
"argparse",
"parser",
"object",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_join_masks.py#L102-L112 |
loli/medpy | doc/numpydoc/numpydoc/docscrape_sphinx.py | SphinxDocString._str_member_list | def _str_member_list(self, name):
"""
Generate a member listing, autosummary:: table where possible,
and a table where not.
"""
out = []
if self[name]:
out += ['.. rubric:: %s' % name, '']
prefix = getattr(self, '_name', '')
if prefix... | python | def _str_member_list(self, name):
"""
Generate a member listing, autosummary:: table where possible,
and a table where not.
"""
out = []
if self[name]:
out += ['.. rubric:: %s' % name, '']
prefix = getattr(self, '_name', '')
if prefix... | [
"def",
"_str_member_list",
"(",
"self",
",",
"name",
")",
":",
"out",
"=",
"[",
"]",
"if",
"self",
"[",
"name",
"]",
":",
"out",
"+=",
"[",
"'.. rubric:: %s'",
"%",
"name",
",",
"''",
"]",
"prefix",
"=",
"getattr",
"(",
"self",
",",
"'_name'",
",",... | Generate a member listing, autosummary:: table where possible,
and a table where not. | [
"Generate",
"a",
"member",
"listing",
"autosummary",
"::",
"table",
"where",
"possible",
"and",
"a",
"table",
"where",
"not",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/docscrape_sphinx.py#L91-L141 |
loli/medpy | medpy/filter/label.py | relabel_map | def relabel_map(label_image, mapping, key=lambda x, y: x[y]):
r"""
Relabel an image using the supplied mapping.
The ``mapping`` can be any kind of subscriptable object. The respective region id is used
to access the new value from the ``mapping``. The ``key`` keyword parameter can be used to
su... | python | def relabel_map(label_image, mapping, key=lambda x, y: x[y]):
r"""
Relabel an image using the supplied mapping.
The ``mapping`` can be any kind of subscriptable object. The respective region id is used
to access the new value from the ``mapping``. The ``key`` keyword parameter can be used to
su... | [
"def",
"relabel_map",
"(",
"label_image",
",",
"mapping",
",",
"key",
"=",
"lambda",
"x",
",",
"y",
":",
"x",
"[",
"y",
"]",
")",
":",
"label_image",
"=",
"scipy",
".",
"array",
"(",
"label_image",
")",
"def",
"_map",
"(",
"x",
")",
":",
"try",
"... | r"""
Relabel an image using the supplied mapping.
The ``mapping`` can be any kind of subscriptable object. The respective region id is used
to access the new value from the ``mapping``. The ``key`` keyword parameter can be used to
supply another access function. The ``key`` function must have the s... | [
"r",
"Relabel",
"an",
"image",
"using",
"the",
"supplied",
"mapping",
".",
"The",
"mapping",
"can",
"be",
"any",
"kind",
"of",
"subscriptable",
"object",
".",
"The",
"respective",
"region",
"id",
"is",
"used",
"to",
"access",
"the",
"new",
"value",
"from",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/label.py#L30-L68 |
loli/medpy | medpy/filter/label.py | relabel | def relabel(label_image, start = 1):
r"""
Relabel the regions of a label image.
Re-processes the labels to make them consecutively and starting from start.
Parameters
----------
label_image : array_like
A nD label map.
start : integer
The id of the first label to assign
... | python | def relabel(label_image, start = 1):
r"""
Relabel the regions of a label image.
Re-processes the labels to make them consecutively and starting from start.
Parameters
----------
label_image : array_like
A nD label map.
start : integer
The id of the first label to assign
... | [
"def",
"relabel",
"(",
"label_image",
",",
"start",
"=",
"1",
")",
":",
"label_image",
"=",
"scipy",
".",
"asarray",
"(",
"label_image",
")",
"mapping",
"=",
"{",
"}",
"rav",
"=",
"label_image",
".",
"ravel",
"(",
")",
"for",
"i",
"in",
"range",
"(",... | r"""
Relabel the regions of a label image.
Re-processes the labels to make them consecutively and starting from start.
Parameters
----------
label_image : array_like
A nD label map.
start : integer
The id of the first label to assign
Returns
-------
relabel_... | [
"r",
"Relabel",
"the",
"regions",
"of",
"a",
"label",
"image",
".",
"Re",
"-",
"processes",
"the",
"labels",
"to",
"make",
"them",
"consecutively",
"and",
"starting",
"from",
"start",
".",
"Parameters",
"----------",
"label_image",
":",
"array_like",
"A",
"n... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/label.py#L70-L99 |
loli/medpy | medpy/filter/label.py | relabel_non_zero | def relabel_non_zero(label_image, start = 1):
r"""
Relabel the regions of a label image.
Re-processes the labels to make them consecutively and starting from start.
Keeps all zero (0) labels, as they are considered background.
Parameters
----------
label_image : array_like
A nD... | python | def relabel_non_zero(label_image, start = 1):
r"""
Relabel the regions of a label image.
Re-processes the labels to make them consecutively and starting from start.
Keeps all zero (0) labels, as they are considered background.
Parameters
----------
label_image : array_like
A nD... | [
"def",
"relabel_non_zero",
"(",
"label_image",
",",
"start",
"=",
"1",
")",
":",
"if",
"start",
"<=",
"0",
":",
"raise",
"ArgumentError",
"(",
"'The starting value can not be 0 or lower.'",
")",
"l",
"=",
"list",
"(",
"scipy",
".",
"unique",
"(",
"label_image"... | r"""
Relabel the regions of a label image.
Re-processes the labels to make them consecutively and starting from start.
Keeps all zero (0) labels, as they are considered background.
Parameters
----------
label_image : array_like
A nD label map.
start : integer
The id of ... | [
"r",
"Relabel",
"the",
"regions",
"of",
"a",
"label",
"image",
".",
"Re",
"-",
"processes",
"the",
"labels",
"to",
"make",
"them",
"consecutively",
"and",
"starting",
"from",
"start",
".",
"Keeps",
"all",
"zero",
"(",
"0",
")",
"labels",
"as",
"they",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/label.py#L101-L132 |
loli/medpy | medpy/filter/label.py | fit_labels_to_mask | def fit_labels_to_mask(label_image, mask):
r"""
Reduces a label images by overlaying it with a binary mask and assign the labels
either to the mask or to the background. The resulting binary mask is the nearest
expression the label image can form of the supplied binary mask.
Parameters
----... | python | def fit_labels_to_mask(label_image, mask):
r"""
Reduces a label images by overlaying it with a binary mask and assign the labels
either to the mask or to the background. The resulting binary mask is the nearest
expression the label image can form of the supplied binary mask.
Parameters
----... | [
"def",
"fit_labels_to_mask",
"(",
"label_image",
",",
"mask",
")",
":",
"label_image",
"=",
"scipy",
".",
"asarray",
"(",
"label_image",
")",
"mask",
"=",
"scipy",
".",
"asarray",
"(",
"mask",
",",
"dtype",
"=",
"scipy",
".",
"bool_",
")",
"if",
"label_i... | r"""
Reduces a label images by overlaying it with a binary mask and assign the labels
either to the mask or to the background. The resulting binary mask is the nearest
expression the label image can form of the supplied binary mask.
Parameters
----------
label_image : array_like
A n... | [
"r",
"Reduces",
"a",
"label",
"images",
"by",
"overlaying",
"it",
"with",
"a",
"binary",
"mask",
"and",
"assign",
"the",
"labels",
"either",
"to",
"the",
"mask",
"or",
"to",
"the",
"background",
".",
"The",
"resulting",
"binary",
"mask",
"is",
"the",
"ne... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/label.py#L135-L193 |
loli/medpy | bin/medpy_graphcut_label_bgreduced.py | __xd_iterator_pass_on | def __xd_iterator_pass_on(arr, view, fun):
"""
Like xd_iterator, but the fun return values are always passed on to the next and only the last returned.
"""
# create list of iterations
iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)]
# iterate... | python | def __xd_iterator_pass_on(arr, view, fun):
"""
Like xd_iterator, but the fun return values are always passed on to the next and only the last returned.
"""
# create list of iterations
iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)]
# iterate... | [
"def",
"__xd_iterator_pass_on",
"(",
"arr",
",",
"view",
",",
"fun",
")",
":",
"# create list of iterations",
"iterations",
"=",
"[",
"[",
"None",
"]",
"if",
"dim",
"in",
"view",
"else",
"list",
"(",
"range",
"(",
"arr",
".",
"shape",
"[",
"dim",
"]",
... | Like xd_iterator, but the fun return values are always passed on to the next and only the last returned. | [
"Like",
"xd_iterator",
"but",
"the",
"fun",
"return",
"values",
"are",
"always",
"passed",
"on",
"to",
"the",
"next",
"and",
"only",
"the",
"last",
"returned",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_graphcut_label_bgreduced.py#L176-L189 |
loli/medpy | bin/medpy_graphcut_label_bgreduced.py | __extract_bbox | def __extract_bbox(arr, bb_old):
"Extracts the bounding box of an binary objects hole (assuming only one in existence)."
hole = ndimage.binary_fill_holes(arr)- arr
bb_list = ndimage.find_objects(ndimage.binary_dilation(hole, iterations = 1))
if 0 == len(bb_list): return bb_old
else: bb = bb_list[0]
... | python | def __extract_bbox(arr, bb_old):
"Extracts the bounding box of an binary objects hole (assuming only one in existence)."
hole = ndimage.binary_fill_holes(arr)- arr
bb_list = ndimage.find_objects(ndimage.binary_dilation(hole, iterations = 1))
if 0 == len(bb_list): return bb_old
else: bb = bb_list[0]
... | [
"def",
"__extract_bbox",
"(",
"arr",
",",
"bb_old",
")",
":",
"hole",
"=",
"ndimage",
".",
"binary_fill_holes",
"(",
"arr",
")",
"-",
"arr",
"bb_list",
"=",
"ndimage",
".",
"find_objects",
"(",
"ndimage",
".",
"binary_dilation",
"(",
"hole",
",",
"iteratio... | Extracts the bounding box of an binary objects hole (assuming only one in existence). | [
"Extracts",
"the",
"bounding",
"box",
"of",
"an",
"binary",
"objects",
"hole",
"(",
"assuming",
"only",
"one",
"in",
"existence",
")",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_graphcut_label_bgreduced.py#L191-L203 |
loli/medpy | medpy/io/load.py | load | def load(image):
r"""
Loads the ``image`` and returns a ndarray with the image's pixel content as well as
a header object.
The header can, with restrictions, be used to extract additional meta-information
about the image (e.g. using the methods in `~medpy.io.Header`). Additionally
it serves... | python | def load(image):
r"""
Loads the ``image`` and returns a ndarray with the image's pixel content as well as
a header object.
The header can, with restrictions, be used to extract additional meta-information
about the image (e.g. using the methods in `~medpy.io.Header`). Additionally
it serves... | [
"def",
"load",
"(",
"image",
")",
":",
"logger",
"=",
"Logger",
".",
"getInstance",
"(",
")",
"logger",
".",
"info",
"(",
"'Loading image {}...'",
".",
"format",
"(",
"image",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"image",
")"... | r"""
Loads the ``image`` and returns a ndarray with the image's pixel content as well as
a header object.
The header can, with restrictions, be used to extract additional meta-information
about the image (e.g. using the methods in `~medpy.io.Header`). Additionally
it serves as meta-data contain... | [
"r",
"Loads",
"the",
"image",
"and",
"returns",
"a",
"ndarray",
"with",
"the",
"image",
"s",
"pixel",
"content",
"as",
"well",
"as",
"a",
"header",
"object",
".",
"The",
"header",
"can",
"with",
"restrictions",
"be",
"used",
"to",
"extract",
"additional",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/load.py#L34-L124 |
loli/medpy | medpy/graphcut/graph.py | Graph.set_source_nodes | def set_source_nodes(self, source_nodes):
r"""
Set the source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Notes
-----
It does not get che... | python | def set_source_nodes(self, source_nodes):
r"""
Set the source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Notes
-----
It does not get che... | [
"def",
"set_source_nodes",
"(",
"self",
",",
"source_nodes",
")",
":",
"self",
".",
"__snodes",
"=",
"list",
"(",
"source_nodes",
")",
"# set the source-to-node weights (t-weights)",
"for",
"snode",
"in",
"self",
".",
"__snodes",
":",
"self",
".",
"__tweights",
... | r"""
Set the source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Notes
-----
It does not get checked if one of the supplied source-nodes already h... | [
"r",
"Set",
"the",
"source",
"nodes",
"and",
"compute",
"their",
"t",
"-",
"weights",
".",
"Parameters",
"----------",
"source_nodes",
":",
"sequence",
"of",
"integers",
"Declare",
"the",
"source",
"nodes",
"via",
"their",
"ids",
".",
"Notes",
"-----",
"It",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L70-L91 |
loli/medpy | medpy/graphcut/graph.py | Graph.set_sink_nodes | def set_sink_nodes(self, sink_nodes):
r"""
Set the sink nodes and compute their t-weights.
Parameters
----------
sink_nodes : sequence of integers
Declare the sink nodes via their ids.
Notes
-----
It does not get checked if on... | python | def set_sink_nodes(self, sink_nodes):
r"""
Set the sink nodes and compute their t-weights.
Parameters
----------
sink_nodes : sequence of integers
Declare the sink nodes via their ids.
Notes
-----
It does not get checked if on... | [
"def",
"set_sink_nodes",
"(",
"self",
",",
"sink_nodes",
")",
":",
"self",
".",
"__tnodes",
"=",
"list",
"(",
"sink_nodes",
")",
"# set the source-to-node weights (t-weights)",
"for",
"tnode",
"in",
"self",
".",
"__tnodes",
":",
"self",
".",
"__tweights",
"[",
... | r"""
Set the sink nodes and compute their t-weights.
Parameters
----------
sink_nodes : sequence of integers
Declare the sink nodes via their ids.
Notes
-----
It does not get checked if one of the supplied sink-nodes already has
... | [
"r",
"Set",
"the",
"sink",
"nodes",
"and",
"compute",
"their",
"t",
"-",
"weights",
".",
"Parameters",
"----------",
"sink_nodes",
":",
"sequence",
"of",
"integers",
"Declare",
"the",
"sink",
"nodes",
"via",
"their",
"ids",
".",
"Notes",
"-----",
"It",
"do... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L93-L114 |
loli/medpy | medpy/graphcut/graph.py | Graph.inconsistent | def inconsistent(self):
r"""
Perform some consistency tests on the graph represented by this object
Returns
-------
consistent : bool or list
False if consistent, else a list of inconsistency messages.
Notes
-----
This check i... | python | def inconsistent(self):
r"""
Perform some consistency tests on the graph represented by this object
Returns
-------
consistent : bool or list
False if consistent, else a list of inconsistency messages.
Notes
-----
This check i... | [
"def",
"inconsistent",
"(",
"self",
")",
":",
"messages",
"=",
"[",
"]",
"for",
"node",
"in",
"list",
"(",
"self",
".",
"__tweights",
".",
"keys",
"(",
")",
")",
":",
"if",
"not",
"node",
"<=",
"self",
".",
"__nodes",
":",
"messages",
".",
"append"... | r"""
Perform some consistency tests on the graph represented by this object
Returns
-------
consistent : bool or list
False if consistent, else a list of inconsistency messages.
Notes
-----
This check is very time intensive and should... | [
"r",
"Perform",
"some",
"consistency",
"tests",
"on",
"the",
"graph",
"represented",
"by",
"this",
"object",
"Returns",
"-------",
"consistent",
":",
"bool",
"or",
"list",
"False",
"if",
"consistent",
"else",
"a",
"list",
"of",
"inconsistency",
"messages",
"."... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L226-L254 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_source_nodes | def set_source_nodes(self, source_nodes):
r"""
Set multiple source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Raises
------
ValueError
... | python | def set_source_nodes(self, source_nodes):
r"""
Set multiple source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Raises
------
ValueError
... | [
"def",
"set_source_nodes",
"(",
"self",
",",
"source_nodes",
")",
":",
"if",
"max",
"(",
"source_nodes",
")",
">=",
"self",
".",
"__nodes",
"or",
"min",
"(",
"source_nodes",
")",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid node id of {} or {}. Valid v... | r"""
Set multiple source nodes and compute their t-weights.
Parameters
----------
source_nodes : sequence of integers
Declare the source nodes via their ids.
Raises
------
ValueError
If a passed node id does not refer to ... | [
"r",
"Set",
"multiple",
"source",
"nodes",
"and",
"compute",
"their",
"t",
"-",
"weights",
".",
"Parameters",
"----------",
"source_nodes",
":",
"sequence",
"of",
"integers",
"Declare",
"the",
"source",
"nodes",
"via",
"their",
"ids",
".",
"Raises",
"------",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L299-L327 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_sink_nodes | def set_sink_nodes(self, sink_nodes):
r"""
Set multiple sink nodes and compute their t-weights.
Parameters
----------
sink_nodes : sequence of integers
Declare the sink nodes via their ids.
Raises
------
ValueError
... | python | def set_sink_nodes(self, sink_nodes):
r"""
Set multiple sink nodes and compute their t-weights.
Parameters
----------
sink_nodes : sequence of integers
Declare the sink nodes via their ids.
Raises
------
ValueError
... | [
"def",
"set_sink_nodes",
"(",
"self",
",",
"sink_nodes",
")",
":",
"if",
"max",
"(",
"sink_nodes",
")",
">=",
"self",
".",
"__nodes",
"or",
"min",
"(",
"sink_nodes",
")",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid node id of {} or {}. Valid values ar... | r"""
Set multiple sink nodes and compute their t-weights.
Parameters
----------
sink_nodes : sequence of integers
Declare the sink nodes via their ids.
Raises
------
ValueError
If a passed node id does not refer to an... | [
"r",
"Set",
"multiple",
"sink",
"nodes",
"and",
"compute",
"their",
"t",
"-",
"weights",
".",
"Parameters",
"----------",
"sink_nodes",
":",
"sequence",
"of",
"integers",
"Declare",
"the",
"sink",
"nodes",
"via",
"their",
"ids",
".",
"Raises",
"------",
"Val... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L329-L357 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_nweight | def set_nweight(self, node_from, node_to, weight_there, weight_back):
r"""
Set a single n-weight / edge-weight.
Parameters
----------
node_from : int
Node-id from the first node of the edge.
node_to : int
Node-id from the second node of th... | python | def set_nweight(self, node_from, node_to, weight_there, weight_back):
r"""
Set a single n-weight / edge-weight.
Parameters
----------
node_from : int
Node-id from the first node of the edge.
node_to : int
Node-id from the second node of th... | [
"def",
"set_nweight",
"(",
"self",
",",
"node_from",
",",
"node_to",
",",
"weight_there",
",",
"weight_back",
")",
":",
"if",
"node_from",
">=",
"self",
".",
"__nodes",
"or",
"node_from",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid node id (node_from)... | r"""
Set a single n-weight / edge-weight.
Parameters
----------
node_from : int
Node-id from the first node of the edge.
node_to : int
Node-id from the second node of the edge.
weight_there : float
Weight from first to second n... | [
"r",
"Set",
"a",
"single",
"n",
"-",
"weight",
"/",
"edge",
"-",
"weight",
".",
"Parameters",
"----------",
"node_from",
":",
"int",
"Node",
"-",
"id",
"from",
"the",
"first",
"node",
"of",
"the",
"edge",
".",
"node_to",
":",
"int",
"Node",
"-",
"id"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L359-L403 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_nweights | def set_nweights(self, nweights):
r"""
Set multiple n-weights / edge-weights.
Parameters
----------
nweights : dict
A dictionary with (node-id, node-id) tuples as keys and (weight-a-to-b, weight-b-to-a) as values.
Notes
-----
... | python | def set_nweights(self, nweights):
r"""
Set multiple n-weights / edge-weights.
Parameters
----------
nweights : dict
A dictionary with (node-id, node-id) tuples as keys and (weight-a-to-b, weight-b-to-a) as values.
Notes
-----
... | [
"def",
"set_nweights",
"(",
"self",
",",
"nweights",
")",
":",
"for",
"edge",
",",
"weight",
"in",
"list",
"(",
"nweights",
".",
"items",
"(",
")",
")",
":",
"self",
".",
"set_nweight",
"(",
"edge",
"[",
"0",
"]",
",",
"edge",
"[",
"1",
"]",
",",... | r"""
Set multiple n-weights / edge-weights.
Parameters
----------
nweights : dict
A dictionary with (node-id, node-id) tuples as keys and (weight-a-to-b, weight-b-to-a) as values.
Notes
-----
The object does not check if the number of... | [
"r",
"Set",
"multiple",
"n",
"-",
"weights",
"/",
"edge",
"-",
"weights",
".",
"Parameters",
"----------",
"nweights",
":",
"dict",
"A",
"dictionary",
"with",
"(",
"node",
"-",
"id",
"node",
"-",
"id",
")",
"tuples",
"as",
"keys",
"and",
"(",
"weight",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L405-L423 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_tweight | def set_tweight(self, node, weight_source, weight_sink):
r"""
Set a single t-weight / terminal-weight.
Parameters
----------
node : int
Node-id for which to set the terminal weights.
weight_source : float
Weight to source terminal.
... | python | def set_tweight(self, node, weight_source, weight_sink):
r"""
Set a single t-weight / terminal-weight.
Parameters
----------
node : int
Node-id for which to set the terminal weights.
weight_source : float
Weight to source terminal.
... | [
"def",
"set_tweight",
"(",
"self",
",",
"node",
",",
"weight_source",
",",
"weight_sink",
")",
":",
"if",
"node",
">=",
"self",
".",
"__nodes",
"or",
"node",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid node id of {}. Valid values are 0 to {}.'",
".",
... | r"""
Set a single t-weight / terminal-weight.
Parameters
----------
node : int
Node-id for which to set the terminal weights.
weight_source : float
Weight to source terminal.
weight_sink : float
Weight to sink terminal.
... | [
"r",
"Set",
"a",
"single",
"t",
"-",
"weight",
"/",
"terminal",
"-",
"weight",
".",
"Parameters",
"----------",
"node",
":",
"int",
"Node",
"-",
"id",
"for",
"which",
"to",
"set",
"the",
"terminal",
"weights",
".",
"weight_source",
":",
"float",
"Weight"... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L425-L455 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_tweights | def set_tweights(self, tweights):
r"""
Set multiple t-weights to the current collection of t-weights, overwriting
already existing ones.
Parameters
----------
tweights : dict
A dictionary with node_ids as keys and (weight-to-source, weight-to-sink) tu... | python | def set_tweights(self, tweights):
r"""
Set multiple t-weights to the current collection of t-weights, overwriting
already existing ones.
Parameters
----------
tweights : dict
A dictionary with node_ids as keys and (weight-to-source, weight-to-sink) tu... | [
"def",
"set_tweights",
"(",
"self",
",",
"tweights",
")",
":",
"for",
"node",
",",
"weight",
"in",
"list",
"(",
"tweights",
".",
"items",
"(",
")",
")",
":",
"self",
".",
"set_tweight",
"(",
"node",
",",
"weight",
"[",
"0",
"]",
",",
"weight",
"[",... | r"""
Set multiple t-weights to the current collection of t-weights, overwriting
already existing ones.
Parameters
----------
tweights : dict
A dictionary with node_ids as keys and (weight-to-source, weight-to-sink) tuples as values.
Raises
... | [
"r",
"Set",
"multiple",
"t",
"-",
"weights",
"to",
"the",
"current",
"collection",
"of",
"t",
"-",
"weights",
"overwriting",
"already",
"existing",
"ones",
".",
"Parameters",
"----------",
"tweights",
":",
"dict",
"A",
"dictionary",
"with",
"node_ids",
"as",
... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L457-L485 |
loli/medpy | medpy/graphcut/graph.py | GCGraph.set_tweights_all | def set_tweights_all(self, tweights):
r"""
Set all t-weights at once.
Parameters
----------
tweights : iterable
Containing a pair of numeric values for each of the graphs nodes.
Notes
-----
Since this method overrides already ... | python | def set_tweights_all(self, tweights):
r"""
Set all t-weights at once.
Parameters
----------
tweights : iterable
Containing a pair of numeric values for each of the graphs nodes.
Notes
-----
Since this method overrides already ... | [
"def",
"set_tweights_all",
"(",
"self",
",",
"tweights",
")",
":",
"for",
"node",
",",
"(",
"twsource",
",",
"twsink",
")",
"in",
"enumerate",
"(",
"tweights",
")",
":",
"self",
".",
"set_tweight",
"(",
"node",
",",
"twsource",
",",
"twsink",
")"
] | r"""
Set all t-weights at once.
Parameters
----------
tweights : iterable
Containing a pair of numeric values for each of the graphs nodes.
Notes
-----
Since this method overrides already existing t-weights, it is strongly
rec... | [
"r",
"Set",
"all",
"t",
"-",
"weights",
"at",
"once",
".",
"Parameters",
"----------",
"tweights",
":",
"iterable",
"Containing",
"a",
"pair",
"of",
"numeric",
"values",
"for",
"each",
"of",
"the",
"graphs",
"nodes",
".",
"Notes",
"-----",
"Since",
"this",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/graph.py#L487-L507 |
loli/medpy | bin/medpy_extract_contour.py | getArguments | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
if args.width <= 0:
raise argparse.ArgumentError(args.width, 'The contour width must be a positive number.')
return args | python | def getArguments(parser):
"Provides additional validation of the arguments collected by argparse."
args = parser.parse_args()
if args.width <= 0:
raise argparse.ArgumentError(args.width, 'The contour width must be a positive number.')
return args | [
"def",
"getArguments",
"(",
"parser",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"if",
"args",
".",
"width",
"<=",
"0",
":",
"raise",
"argparse",
".",
"ArgumentError",
"(",
"args",
".",
"width",
",",
"'The contour width must be a positive ... | 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_contour.py#L109-L114 |
loli/medpy | medpy/io/header.py | set_pixel_spacing | def set_pixel_spacing(hdr, spacing):
r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`."""
warnings.warn('get_pixel_spacing() is depreciated, use set_voxel_spacing() instead', category=DeprecationWarning)
set_voxel_spacing(hdr, spacing) | python | def set_pixel_spacing(hdr, spacing):
r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`."""
warnings.warn('get_pixel_spacing() is depreciated, use set_voxel_spacing() instead', category=DeprecationWarning)
set_voxel_spacing(hdr, spacing) | [
"def",
"set_pixel_spacing",
"(",
"hdr",
",",
"spacing",
")",
":",
"warnings",
".",
"warn",
"(",
"'get_pixel_spacing() is depreciated, use set_voxel_spacing() instead'",
",",
"category",
"=",
"DeprecationWarning",
")",
"set_voxel_spacing",
"(",
"hdr",
",",
"spacing",
")"... | r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`. | [
"r",
"Depreciated",
"synonym",
"of",
"~medpy",
".",
"io",
".",
"header",
".",
"set_voxel_spacing",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L100-L103 |
loli/medpy | medpy/io/header.py | copy_meta_data | def copy_meta_data(hdr_to, hdr_from):
r"""
Copy image meta data (voxel spacing and offset) from one header to another.
Parameters
----------
hdr_to : object
An image header as returned by `load`.
hdr_from : object
An image header as returned by `load`.
"""
warnings.w... | python | def copy_meta_data(hdr_to, hdr_from):
r"""
Copy image meta data (voxel spacing and offset) from one header to another.
Parameters
----------
hdr_to : object
An image header as returned by `load`.
hdr_from : object
An image header as returned by `load`.
"""
warnings.w... | [
"def",
"copy_meta_data",
"(",
"hdr_to",
",",
"hdr_from",
")",
":",
"warnings",
".",
"warn",
"(",
"'copy_meta_data() is depreciated and may be removed in future versions'",
",",
"category",
"=",
"DeprecationWarning",
")",
"logger",
"=",
"Logger",
".",
"getInstance",
"(",... | r"""
Copy image meta data (voxel spacing and offset) from one header to another.
Parameters
----------
hdr_to : object
An image header as returned by `load`.
hdr_from : object
An image header as returned by `load`. | [
"r",
"Copy",
"image",
"meta",
"data",
"(",
"voxel",
"spacing",
"and",
"offset",
")",
"from",
"one",
"header",
"to",
"another",
".",
"Parameters",
"----------",
"hdr_to",
":",
"object",
"An",
"image",
"header",
"as",
"returned",
"by",
"load",
".",
"hdr_from... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L126-L146 |
loli/medpy | medpy/io/header.py | Header.copy_to | def copy_to(self, sitkimage):
"""
Copy all stored meta information info to an sitk Image.
Note that only the spacing and the offset/origin information
are guaranteed to be preserved, although the method also
tries to copy other meta information such as DICOM tags.
Param... | python | def copy_to(self, sitkimage):
"""
Copy all stored meta information info to an sitk Image.
Note that only the spacing and the offset/origin information
are guaranteed to be preserved, although the method also
tries to copy other meta information such as DICOM tags.
Param... | [
"def",
"copy_to",
"(",
"self",
",",
"sitkimage",
")",
":",
"if",
"self",
".",
"sitkimage",
"is",
"not",
"None",
":",
"for",
"k",
"in",
"self",
".",
"sitkimage",
".",
"GetMetaDataKeys",
"(",
")",
":",
"sitkimage",
".",
"SetMetaData",
"(",
"k",
",",
"s... | Copy all stored meta information info to an sitk Image.
Note that only the spacing and the offset/origin information
are guaranteed to be preserved, although the method also
tries to copy other meta information such as DICOM tags.
Parameters
----------
sitkimage : sitk.... | [
"Copy",
"all",
"stored",
"meta",
"information",
"info",
"to",
"an",
"sitk",
"Image",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L213-L242 |
loli/medpy | medpy/io/header.py | Header.get_info_consistent | def get_info_consistent(self, ndim):
"""
Returns the main meta-data information adapted to the supplied
image dimensionality.
It will try to resolve inconsistencies and other conflicts,
altering the information avilable int he most plausible way.
Parameters
----... | python | def get_info_consistent(self, ndim):
"""
Returns the main meta-data information adapted to the supplied
image dimensionality.
It will try to resolve inconsistencies and other conflicts,
altering the information avilable int he most plausible way.
Parameters
----... | [
"def",
"get_info_consistent",
"(",
"self",
",",
"ndim",
")",
":",
"if",
"ndim",
">",
"len",
"(",
"self",
".",
"spacing",
")",
":",
"spacing",
"=",
"self",
".",
"spacing",
"+",
"(",
"1.0",
",",
")",
"*",
"(",
"ndim",
"-",
"len",
"(",
"self",
".",
... | Returns the main meta-data information adapted to the supplied
image dimensionality.
It will try to resolve inconsistencies and other conflicts,
altering the information avilable int he most plausible way.
Parameters
----------
ndim : int
image's dimensional... | [
"Returns",
"the",
"main",
"meta",
"-",
"data",
"information",
"adapted",
"to",
"the",
"supplied",
"image",
"dimensionality",
"."
] | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L244-L279 |
loli/medpy | medpy/metric/binary.py | dc | def dc(result, reference):
r"""
Dice coefficient
Computes the Dice coefficient (also known as Sorensen index) between the binary
objects in two images.
The metric is defined as
.. math::
DC=\frac{2|A\cap B|}{|A|+|B|}
, where :math:`A` is the first and... | python | def dc(result, reference):
r"""
Dice coefficient
Computes the Dice coefficient (also known as Sorensen index) between the binary
objects in two images.
The metric is defined as
.. math::
DC=\frac{2|A\cap B|}{|A|+|B|}
, where :math:`A` is the first and... | [
"def",
"dc",
"(",
"result",
",",
"reference",
")",
":",
"result",
"=",
"numpy",
".",
"atleast_1d",
"(",
"result",
".",
"astype",
"(",
"numpy",
".",
"bool",
")",
")",
"reference",
"=",
"numpy",
".",
"atleast_1d",
"(",
"reference",
".",
"astype",
"(",
... | r"""
Dice coefficient
Computes the Dice coefficient (also known as Sorensen index) between the binary
objects in two images.
The metric is defined as
.. math::
DC=\frac{2|A\cap B|}{|A|+|B|}
, where :math:`A` is the first and :math:`B` the second set of sa... | [
"r",
"Dice",
"coefficient",
"Computes",
"the",
"Dice",
"coefficient",
"(",
"also",
"known",
"as",
"Sorensen",
"index",
")",
"between",
"the",
"binary",
"objects",
"in",
"two",
"images",
".",
"The",
"metric",
"is",
"defined",
"as",
"..",
"math",
"::",
"DC",... | train | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/binary.py#L34-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.