本文整理汇总了Python中medpy.core.Logger类的典型用法代码示例。如果您正苦于以下问题:Python Logger类的具体用法?Python Logger怎么用?Python Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input image using nibabel
logger.info('Loading image {}...'.format(args.input))
image_labels_data, _ = load(args.image)
# load mask image
logger.info('Loading mask {}...'.format(args.mask))
image_mask_data, image_mask_data_header = load(args.mask)
# check if output image exists
if not args.force:
if os.path.exists(args.output):
logger.warning('The output image {} already exists. Skipping this image.'.format(args.output))
# create a mask from the label image
logger.info('Reducing the label image...')
image_reduced_data = fit_labels_to_mask(image_labels_data, image_mask_data)
# save resulting mask
logger.info('Saving resulting mask as {} in the same format as input mask, only with data-type int8...'.format(args.output))
image_reduced_data = image_reduced_data.astype(numpy.bool, copy=False) # bool sadly not recognized
save(image_reduced_data, args.output, image_mask_data_header, args.force)
logger.info('Successfully terminated.')
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:34,代码来源:medpy_reduce.py
示例2: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug:
logger.setLevel(logging.DEBUG)
elif args.verbose:
logger.setLevel(logging.INFO)
# check if output image exists
if not args.force:
if os.path.exists(args.output):
logger.warning("The output image {} already exists. Exiting.".format(args.output))
exit(-1)
# load input image
input_data, input_header = load(args.input)
logger.debug("Old number of regions={}.".format(len(scipy.unique(input_data))))
# cut and relabel along the required dimension
logger.info("Cutting and relabeling...")
dimensions = range(input_data.ndim)
del dimensions[args.dimension]
__split_along(input_data, dimensions)
logger.debug("New number of regions={}.".format(len(scipy.unique(input_data))))
# save result contour volume
save(input_data, args.output, input_header, args.force)
logger.info("Successfully terminated.")
开发者ID:tatafarewell,项目名称:medpy,代码行数:33,代码来源:discontinue_dimension.py
示例3: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input image
data_input, header_input = load(args.input)
# transform to uin8
data_input = data_input.astype(scipy.uint8)
# reduce to 3D, if larger dimensionality
if data_input.ndim > 3:
for _ in range(data_input.ndim - 3): data_input = data_input[...,0]
# iter over slices (2D) until first with content is detected
for plane in data_input:
if scipy.any(plane):
# set pixel spacing
spacing = list(header.get_pixel_spacing(header_input))
spacing = spacing[1:3]
__update_header_from_array_nibabel(header_input, plane)
header.set_pixel_spacing(header_input, spacing)
# save image
save(plane, args.output, header_input, args.force)
break
logger.info("Successfully terminated.")
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:31,代码来源:extract_first_basal_slice.py
示例4: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input images
input_data, input_header = load(args.input)
original_data, _ = load(args.original)
logger.debug('Old shape={}.'.format(input_data.shape))
# compute position
logger.info('Computing positon and pad volume...')
position = __parse_contour_list(args.contours, input_data)
# pad volume
output_data = scipy.zeros(original_data.shape, input_data.dtype)
output_data[position] = input_data
logger.debug('New shape={}.'.format(input_data.shape))
# save result contour volume
save(output_data, args.output, input_header, args.force)
logger.info("Successfully terminated.")
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:29,代码来源:pad_cut_by_contourfile.py
示例5: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# check if output image exists (will also be performed before saving, but as the smoothing might be very time intensity, a initial check can save frustration)
if not args.force:
if os.path.exists(args.output):
raise parser.error('The output image {} already exists.'.format(args.output))
# loading image
data_input, header_input = load(args.input)
# apply the watershed
logger.info('Applying anisotropic diffusion with settings: niter={} / kappa={} / gamma={}...'.format(args.iterations, args.kappa, args.gamma))
data_output = anisotropic_diffusion(data_input, args.iterations, args.kappa, args.gamma, get_pixel_spacing(header_input))
# save file
save(data_output, args.output, header_input, args.force)
logger.info('Successfully terminated.')
开发者ID:loli,项目名称:medpy,代码行数:27,代码来源:medpy_anisotropic_diffusion.py
示例6: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# constants
colours = {'i': 10, 'o': 11}
# load volumes
marker_data, _ = load(args.marker)
contour_data, _ = load(args.contour)
# perform check
contour_data = contour_data == colours[args.type]
marker_data_fg = marker_data == 1
marker_data_bg = marker_data == 2
if scipy.logical_and(contour_data, marker_data_fg).any():
logger.warning('Intersection between {} and {} (type {}) in foreground.'.format(args.marker, args.contour, args.type))
elif scipy.logical_and(contour_data, marker_data_bg).any():
logger.warning('Intersection between {} and {} (type {}) in background.'.format(args.marker, args.contour, args.type))
else:
print "No intersection."
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:25,代码来源:medpy_check_marker_intersection.py
示例7: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# check if output image exists (will also be performed before saving, but as the gradient might be time intensity, a initial check can save frustration)
if not args.force:
if os.path.exists(args.output):
raise ArgumentError('The output image {} already exists.'.format(args.output))
# loading image
data_input, header_input = load(args.input)
logger.debug('Input array: dtype={}, shape={}'.format(data_input.dtype, data_input.shape))
# execute the gradient map filter
logger.info('Applying gradient map filter...')
data_output = filter.gradient_magnitude(data_input, header.get_pixel_spacing(header_input))
logger.debug('Resulting array: dtype={}, shape={}'.format(data_output.dtype, data_output.shape))
# save image
save(data_output, args.output, header_input, args.force)
logger.info('Successfully terminated.')
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:31,代码来源:medpy_itk_gradient.py
示例8: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug:
logger.setLevel(logging.DEBUG)
elif args.verbose:
logger.setLevel(logging.INFO)
# collect slice-wise results and compute average
results_i, results_o = parseImageResults(args.score)
results_i = splitResults(results_i)
results_o = splitResults(results_o)
# print results
if args.csv:
print "Inner contours"
csvPrintResults(results_i)
print "Outer contours"
csvPrintResults(results_o)
else:
print "########## Inner contours ##########"
prettyPrintResults(results_i)
print "####################################"
print
print "########## Outer contours ##########"
prettyPrintResults(results_o)
print "####################################"
开发者ID:tatafarewell,项目名称:medpy,代码行数:30,代码来源:split_results.py
示例9: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# check if output image already exists
if not args.force:
if os.path.exists(args.output):
logger.warning('The output image {} already exists. Exiting.'.format(args.output))
exit(-1)
# load input image
image_smoothed_data, image_header = load(args.input)
# apply additional hole closing step
logger.info('Closing holes...')
def fun_holes(arr):
return scipy.ndimage.morphology.binary_fill_holes(arr)
xd_iterator(image_smoothed_data, (1, 2), fun_holes)
# perform opening resp. closing
# in 3D case: size 1 = 6-connectedness, 2 = 12-connectedness, 3 = 18-connectedness, etc.
if 'erosion' == args.type:
logger.info('Applying erosion...')
def fun(arr):
if 0 == args.iterations: return arr
footprint = scipy.ndimage.morphology.generate_binary_structure(arr.ndim, args.size)
return scipy.ndimage.morphology.binary_erosion(arr, footprint, iterations=args.iterations)
elif 'dilation' == args.type:
logger.info('Applying dilation...')
def fun(arr):
if 0 == args.iterations: return arr
footprint = scipy.ndimage.morphology.generate_binary_structure(arr.ndim, args.size)
return scipy.ndimage.morphology.binary_dilation(arr, footprint, iterations=args.iterations)
elif 'opening' == args.type:
logger.info('Applying opening...')
def fun(arr):
if 0 == args.iterations: return arr
footprint = scipy.ndimage.morphology.generate_binary_structure(arr.ndim, args.size)
return scipy.ndimage.morphology.binary_opening(arr, footprint, iterations=args.iterations)
else: # closing
logger.info('Applying closing...')
def fun(arr):
if 0 == args.iterations: return arr
footprint = scipy.ndimage.morphology.generate_binary_structure(arr.ndim, args.size)
return scipy.ndimage.morphology.binary_closing(arr, footprint, iterations=args.iterations)
# iterate over slices and apply selected operation
xd_iterator(image_smoothed_data, (1, 2), fun)
# save resulting mas
save(image_smoothed_data, args.output, image_header, args.force)
logger.info('Successfully terminated.')
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:60,代码来源:morphology_sliced.py
示例10: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# laod input image
data_input, header_input = load(args.input)
# # check if output image exists
# if not args.force:
# if os.path.exists(image_gradient_name):
# logger.warning('The output image {} already exists. Skipping this step.'.format(image_gradient_name))
# continue
# prepare result image
data_output = scipy.zeros(data_input.shape, dtype=scipy.float32)
# apply the gradient magnitude filter
logger.info('Computing the gradient magnitude with Prewitt operator...')
generic_gradient_magnitude(data_input, prewitt, output=data_output) # alternative to prewitt is sobel
# save resulting mask
save(data_output, args.output, header_input, args.force)
logger.info('Successfully terminated.')
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:31,代码来源:medpy_gradient.py
示例11: zoom
def zoom(image, factor, dimension, hdr = False, order = 3):
"""
Zooms the provided image by the supplied factor in the supplied dimension.
The factor is an integer determining how many slices should be put between each
existing pair.
If an image header (hdr) is supplied, its voxel spacing gets updated.
Returns the image and the updated header or false.
"""
# check if supplied dimension is valid
if dimension >= image.ndim:
raise argparse.ArgumentError('The supplied zoom-dimension {} exceeds the image dimensionality of 0 to {}.'.format(dimension, image.ndim - 1))
# get logger
logger = Logger.getInstance()
logger.debug('Old shape = {}.'.format(image.shape))
# perform the zoom
zoom = [1] * image.ndim
zoom[dimension] = (image.shape[dimension] + (image.shape[dimension] - 1) * factor) / float(image.shape[dimension])
logger.debug('Reshaping with = {}.'.format(zoom))
image = interpolation.zoom(image, zoom, order=order)
logger.debug('New shape = {}.'.format(image.shape))
if hdr:
new_spacing = list(header.get_pixel_spacing(hdr))
new_spacing[dimension] = new_spacing[dimension] / float(factor + 1)
logger.debug('Setting pixel spacing from {} to {}....'.format(header.get_pixel_spacing(hdr), new_spacing))
header.set_pixel_spacing(hdr, tuple(new_spacing))
return image, hdr
开发者ID:loli,项目名称:medpy,代码行数:32,代码来源:medpy_zoom_image.py
示例12: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug:
logger.setLevel(logging.DEBUG)
elif args.verbose:
logger.setLevel(logging.INFO)
# check if output image exists (will also be performed before saving, but as the watershed might be very time intensity, a initial check can save frustration)
if not args.force:
if os.path.exists(args.output):
raise ArgumentError("The output image {} already exists.".format(args.output))
# loading image
data_input, header_input = load(args.input)
# apply the watershed
logger.info("Watershedding with settings: thr={} / level={}...".format(args.threshold, args.level))
data_output = watershed(data_input, get_pixel_spacing(header_input), args.threshold, args.level)
# save file
save(data_output, args.output, header_input, args.force)
logger.info("Successfully terminated.")
开发者ID:tatafarewell,项目名称:medpy,代码行数:29,代码来源:medpy_itk_watershed.py
示例13: __init__
def __init__(self, image_labels, image_original):
"""
Computes a number of statistics for the labels of a label image.
These include beside others:
1. a histogram of the sizes of the regions
2. a histogram of the sphericity (not roundness) of the regions
3. a histogram of how the intensity distribution in each region differs
from a Gaussian distribution
@param image_lables: The label image for which the statistics should be
computed as a numpy array
@param image_original: The original image for which the label image was created.
"""
if image_labels.shape != image_original.shape:
raise ValueError('The input images must be of the same shape.')
if not 3 == len(image_labels.shape):
raise ValueError('Currently this class is only working with 3D images.')
# prepare logger
self._logger = Logger.getInstance()
self._image_labels = image_labels
self._image_original = image_original
self._compute()
开发者ID:ShimonaNiharika,项目名称:MedIA,代码行数:26,代码来源:LabelImageStatistics.py
示例14: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# write header line
print('image;labels\n')
# iterate over input images
for image in args.images:
# get and prepare image data
logger.info('Processing image {}...'.format(image))
image_data, _ = load(image)
# count number of labels and flag a warning if they reach the ushort border
count = len(numpy.unique(image_data))
# count number of labels and write
print('{};{}\n'.format(image.split('/')[-1], count))
sys.stdout.flush()
logger.info('Successfully terminated.')
开发者ID:loli,项目名称:medpy,代码行数:30,代码来源:medpy_label_count.py
示例15: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input image
input_data, input_header = load(args.input)
logger.debug('Old shape={}.'.format(input_data.shape))
# compute cut
logger.info('Computing cut and cropping volume...')
cut = __parse_contour_list(args.contours, input_data)
# crop volume
input_data = input_data[cut]
logger.debug('New shape={}.'.format(input_data.shape))
# save result contour volume
save(input_data, args.output, input_header, args.force)
logger.info("Successfully terminated.")
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:25,代码来源:extract_subvolume_by_contourfile.py
示例16: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
with open(args.output, 'w') as outf:
outf.write('C;;E;;D;;ED;(std);ES;(std);Total;(std)')
with open(args.input, 'r') as inf:
for line in inf.readlines():
line = line.strip()
if 'ced' == line[0:3]:
_tmp = line.split('_')[1:]
_c = _tmp[0].split('-')
_e = _tmp[1].split('-')
_d = _tmp[2].split('-')
outf.write('\n')
outf.write('{};{};{};{};{};{};'.format(_c[0][1:], _c[1], _e[0][1:], _e[1], _d[0][1:], _d[1]))
elif 'Mean (std) endo DM' in line:
_tmp = line.split(' ')
outf.write('{};{};{};{};'.format(_tmp[5], _tmp[6], _tmp[8], _tmp[9]))
elif 'Total mean (std) endo DM' in line:
_tmp = line.split(' ')
outf.write('{};{}'.format(_tmp[5], _tmp[6]))
logger.info("Successfully terminated.")
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:28,代码来源:temporary.py
示例17: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input image1
data_input1, _ = load(args.input1)
# load input image2
data_input2, _ = load(args.input2)
# compare dtype and shape
if not data_input1.dtype == data_input2.dtype: print 'Dtype differs: {} to {}'.format(data_input1.dtype, data_input2.dtype)
if not data_input1.shape == data_input2.shape:
print 'Shape differs: {} to {}'.format(data_input1.shape, data_input2.shape)
print 'The voxel content of images of different shape can not be compared. Exiting.'
sys.exit(-1)
# compare image data
voxel_total = reduce(lambda x, y: x*y, data_input1.shape)
voxel_difference = len((data_input1 != data_input2).nonzero()[0])
if not 0 == voxel_difference:
print 'Voxel differ: {} of {} total voxels'.format(voxel_difference, voxel_total)
print 'Max difference: {}'.format(scipy.absolute(data_input1 - data_input2).max())
else: print 'No other difference.'
logger.info("Successfully terminated.")
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:30,代码来源:medpy_diff.py
示例18: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input image
data_input, header_input = load(args.input)
logger.debug('Original shape = {}.'.format(data_input.shape))
# check if supplied dimension parameters is inside the images dimensions
if args.dimension1 >= data_input.ndim or args.dimension1 < 0:
raise ArgumentError('The first swap-dimension {} exceeds the number of input volume dimensions {}.'.format(args.dimension1, data_input.ndim))
elif args.dimension2 >= data_input.ndim or args.dimension2 < 0:
raise ArgumentError('The second swap-dimension {} exceeds the number of input volume dimensions {}.'.format(args.dimension2, data_input.ndim))
# swap axes
data_output = scipy.swapaxes(data_input, args.dimension1, args.dimension2)
# swap pixel spacing and offset
ps = list(header.get_pixel_spacing(header_input))
ps[args.dimension1], ps[args.dimension2] = ps[args.dimension2], ps[args.dimension1]
header.set_pixel_spacing(header_input, ps)
os = list(header.get_offset(header_input))
os[args.dimension1], os[args.dimension2] = os[args.dimension2], os[args.dimension1]
header.set_offset(header_input, os)
logger.debug('Resulting shape = {}.'.format(data_output.shape))
# save resulting volume
save(data_output, args.output, header_input, args.force)
logger.info("Successfully terminated.")
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:35,代码来源:medpy_swap_dimensions.py
示例19: main
def main():
args = getArguments(getParser())
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# loading input images
b0img, b0hdr = load(args.b0image)
bximg, bxhdr = load(args.bximage)
# convert to float
b0img = b0img.astype(numpy.float)
bximg = bximg.astype(numpy.float)
# check if image are compatible
if not b0img.shape == bximg.shape:
raise ArgumentError('The input images shapes differ i.e. {} != {}.'.format(b0img.shape, bximg.shape))
if not header.get_pixel_spacing(b0hdr) == header.get_pixel_spacing(bxhdr):
raise ArgumentError('The input images voxel spacing differs i.e. {} != {}.'.format(header.get_pixel_spacing(b0hdr), header.get_pixel_spacing(bxhdr)))
# check if supplied threshold value as well as the b value is above 0
if args.threshold is not None and not args.threshold >= 0:
raise ArgumentError('The supplied threshold value must be greater than 0, otherwise a division through 0 might occur.')
if not args.b > 0:
raise ArgumentError('The supplied b-value must be greater than 0.')
# compute threshold value if not supplied
if args.threshold is None:
b0thr = otsu(b0img, 32) / 4. # divide by 4 to decrease impact
bxthr = otsu(bximg, 32) / 4.
if 0 >= b0thr:
raise ArgumentError('The supplied b0image seems to contain negative values.')
if 0 >= bxthr:
raise ArgumentError('The supplied bximage seems to contain negative values.')
else:
b0thr = bxthr = args.threshold
logger.debug('thresholds={}/{}, b-value={}'.format(b0thr, bxthr, args.b))
# threshold b0 + bx DW image to obtain a mask
# b0 mask avoid division through 0, bx mask avoids a zero in the ln(x) computation
mask = binary_fill_holes(b0img > b0thr) & binary_fill_holes(bximg > bxthr)
# perform a number of binary morphology steps to select the brain only
mask = binary_erosion(mask, iterations=1)
mask = largest_connected_component(mask)
mask = binary_dilation(mask, iterations=1)
logger.debug('excluding {} of {} voxels from the computation and setting them to zero'.format(numpy.count_nonzero(mask), numpy.prod(mask.shape)))
# compute the ADC
adc = numpy.zeros(b0img.shape, b0img.dtype)
adc[mask] = -1. * args.b * numpy.log(bximg[mask] / b0img[mask])
adc[adc < 0] = 0
# saving the resulting image
save(adc, args.output, b0hdr, args.force)
开发者ID:kleinfeld,项目名称:medpy,代码行数:59,代码来源:medpy_apparent_diffusion_coefficient.py
示例20: main
def main():
# parse cmd arguments
parser = getParser()
parser.parse_args()
args = getArguments(parser)
# prepare logger
logger = Logger.getInstance()
if args.debug: logger.setLevel(logging.DEBUG)
elif args.verbose: logger.setLevel(logging.INFO)
# load input image
logger.info('Loading {}...'.format(args.image))
image_data, image_header = load(args.image)
# check if supplied cut dimension is inside the input images dimensions
if args.dimension < 0 or args.dimension >= image_data.ndim:
logger.critical('The supplied cut-dimensions {} is invalid. The input image has only {} dimensions.'.format(args.dimension, image_data.ndim))
raise ArgumentError('The supplied cut-dimensions {} is invalid. The input image has only {} dimensions.'.format(args.dimension, image_data.ndim))
# prepare output filenames
name_output = args.output.replace('{}', '{:03d}')
# determine cut lines
no_sub_volumes = image_data.shape[args.dimension] / args.maxsize + 1 # int-division is desired
slices_per_volume = image_data.shape[args.dimension] / no_sub_volumes # int-division is desired
# construct processing dict for each sub-volume
processing_array = []
for i in range(no_sub_volumes):
processing_array.append(
{'path': name_output.format(i+1),
'cut': (i * slices_per_volume, (i + 1) * slices_per_volume)})
if no_sub_volumes - 1 == i: # last volume has to have increased cut end
processing_array[i]['cut'] = (processing_array[i]['cut'][0], image_data.shape[args.dimension])
# construct base indexing list
index = [slice(None) for _ in range(image_data.ndim)]
# execute extraction of the sub-volumes
logger.info('Extracting sub-volumes...')
for dic in processing_array:
# check if output images exists
if not args.force:
if os.path.exists(dic['path']):
logger.warning('The output file {} already exists. Skipping this volume.'.format(dic['path']))
continue
# extracting sub-volume
index[args.dimension] = slice(dic['cut'][0], dic['cut'][1])
volume = image_data[index]
logger.debug('Extracted volume is of shape {}.'.format(volume.shape))
# saving sub-volume in same format as input image
logger.info('Saving cut {} as {}...'.format(dic['cut'], dic['path']))
save(volume, dic['path'], image_header, args.force)
logger.info('Successfully terminated.')
开发者ID:AlexanderRuesch,项目名称:medpy,代码行数:59,代码来源:medpy_extract_sub_volume_auto.py
注:本文中的medpy.core.Logger类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论