_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q232500
smooth_image
train
def smooth_image(image, sigma, sigma_in_physical_coordinates=True, FWHM=False, max_kernel_width=32): """ Smooth an image ANTsR function: `smoothImage` Arguments --------- image Image to smooth sigma Smoothing factor. Can be scalar, in which case the same sigma is...
python
{ "resource": "" }
q232501
build_template
train
def build_template( initial_template=None, image_list=None, iterations = 3, gradient_step = 0.2, **kwargs ): """ Estimate an optimal template from an input image_list ANTsR function: N/A Arguments --------- initial_template : ANTsImage initialization for the templat...
python
{ "resource": "" }
q232502
resample_image
train
def resample_image(image, resample_params, use_voxels=False, interp_type=1): """ Resample image by spacing or number of voxels with various interpolators. Works with multi-channel images. ANTsR function: `resampleImage` Arguments --------- image : ANTsImage input image re...
python
{ "resource": "" }
q232503
apply_ants_transform
train
def apply_ants_transform(transform, data, data_type="point", reference=None, **kwargs): """ Apply ANTsTransform to data ANTsR function: `applyAntsrTransform` Arguments --------- transform : ANTsTransform transform to apply to image data : ndarray/list/tuple data to which t...
python
{ "resource": "" }
q232504
compose_ants_transforms
train
def compose_ants_transforms(transform_list): """ Compose multiple ANTsTransform's together ANTsR function: `composeAntsrTransforms` Arguments --------- transform_list : list/tuple of ANTsTransform object list of transforms to compose together Returns ------- ANTsTransform ...
python
{ "resource": "" }
q232505
transform_index_to_physical_point
train
def transform_index_to_physical_point(image, index): """ Get spatial point from index of an image. ANTsR function: `antsTransformIndexToPhysicalPoint` Arguments --------- img : ANTsImage image to get values from index : list or tuple or numpy.ndarray location in image ...
python
{ "resource": "" }
q232506
ANTsTransform.invert
train
def invert(self): """ Invert the transform """ libfn = utils.get_lib_fn('inverseTransform%s' % (self._libsuffix)) inv_tx_ptr = libfn(self.pointer) new_tx = ANTsTransform(precision=self.precision, dimension=self.dimension, transform_type=self.transform_typ...
python
{ "resource": "" }
q232507
ANTsTransform.apply
train
def apply(self, data, data_type='point', reference=None, **kwargs): """ Apply transform to data """ if data_type == 'point': return self.apply_to_point(data) elif data_type == 'vector': return self.apply_to_vector(data) elif data_type == 'image': ...
python
{ "resource": "" }
q232508
ANTsTransform.apply_to_point
train
def apply_to_point(self, point): """ Apply transform to a point Arguments --------- point : list/tuple point to which the transform will be applied Returns ------- list : transformed point Example ------- >>> import a...
python
{ "resource": "" }
q232509
ANTsTransform.apply_to_vector
train
def apply_to_vector(self, vector): """ Apply transform to a vector Arguments --------- vector : list/tuple vector to which the transform will be applied Returns ------- list : transformed vector """ if isinstance(vector, np.nd...
python
{ "resource": "" }
q232510
plot_hist
train
def plot_hist(image, threshold=0., fit_line=False, normfreq=True, ## plot label arguments title=None, grid=True, xlabel=None, ylabel=None, ## other plot arguments facecolor='green', alpha=0.75): """ Plot a histogram from an ANTsImage Arguments --------- image : ANTsImage ima...
python
{ "resource": "" }
q232511
morphology
train
def morphology(image, operation, radius, mtype='binary', value=1, shape='ball', radius_is_parametric=False, thickness=1, lines=3, include_center=False): """ Apply morphological operations to an image ANTsR function: `morphology` Arguments --------- input : ANTsIma...
python
{ "resource": "" }
q232512
rgb_to_vector
train
def rgb_to_vector(image): """ Convert an RGB ANTsImage to a Vector ANTsImage Arguments --------- image : ANTsImage RGB image to be converted Returns ------- ANTsImage Example ------- >>> import ants >>> mni = ants.image_read(ants.get_data('mni')) >>> mni_rg...
python
{ "resource": "" }
q232513
vector_to_rgb
train
def vector_to_rgb(image): """ Convert an Vector ANTsImage to a RGB ANTsImage Arguments --------- image : ANTsImage RGB image to be converted Returns ------- ANTsImage Example ------- >>> import ants >>> img = ants.image_read(ants.get_data('r16'), pixeltype='uns...
python
{ "resource": "" }
q232514
quantile
train
def quantile(image, q, nonzero=True): """ Get the quantile values from an ANTsImage """ img_arr = image.numpy() if isinstance(q, (list,tuple)): q = [qq*100. if qq <= 1. else qq for qq in q] if nonzero: img_arr = img_arr[img_arr>0] vals = [np.percentile(img_arr, qq...
python
{ "resource": "" }
q232515
bandpass_filter_matrix
train
def bandpass_filter_matrix( matrix, tr=1, lowf=0.01, highf=0.1, order = 3): """ Bandpass filter the input time series image ANTsR function: `frequencyFilterfMRI` Arguments --------- image: input time series image tr: sampling time interval (inverse of sampling rate) lowf: lo...
python
{ "resource": "" }
q232516
compcor
train
def compcor( boldImage, ncompcor=4, quantile=0.975, mask=None, filter_type=False, degree=2 ): """ Compute noise components from the input image ANTsR function: `compcor` this is adapted from nipy code https://github.com/nipy/nipype/blob/e29ac95fc0fc00fedbcaa0adaf29d5878408ca7c/nipype/algorithms/confou...
python
{ "resource": "" }
q232517
n3_bias_field_correction
train
def n3_bias_field_correction(image, downsample_factor=3): """ N3 Bias Field Correction ANTsR function: `n3BiasFieldCorrection` Arguments --------- image : ANTsImage image to be bias corrected downsample_factor : scalar how much to downsample image before performing bias co...
python
{ "resource": "" }
q232518
n4_bias_field_correction
train
def n4_bias_field_correction(image, mask=None, shrink_factor=4, convergence={'iters':[50,50,50,50], 'tol':1e-07}, spline_param=200, verbose=False, weight_mask=None): """ N4 Bias Field Correction ANTsR function: `n4BiasFieldCorrection` Arguments...
python
{ "resource": "" }
q232519
abp_n4
train
def abp_n4(image, intensity_truncation=(0.025,0.975,256), mask=None, usen3=False): """ Truncate outlier intensities and bias correct with the N4 algorithm. ANTsR function: `abpN4` Arguments --------- image : ANTsImage image to correct and truncate intensity_truncation : 3-tuple ...
python
{ "resource": "" }
q232520
image_mutual_information
train
def image_mutual_information(image1, image2): """ Compute mutual information between two ANTsImage types ANTsR function: `antsImageMutualInformation` Arguments --------- image1 : ANTsImage image 1 image2 : ANTsImage image 2 Returns ------- scalar Exam...
python
{ "resource": "" }
q232521
get_mask
train
def get_mask(image, low_thresh=None, high_thresh=None, cleanup=2): """ Get a binary mask image from the given image after thresholding ANTsR function: `getMask` Arguments --------- image : ANTsImage image from which mask will be computed. Can be an antsImage of 2, 3 or 4 dimensions. ...
python
{ "resource": "" }
q232522
label_image_centroids
train
def label_image_centroids(image, physical=False, convex=True, verbose=False): """ Converts a label image to coordinates summarizing their positions ANTsR function: `labelImageCentroids` Arguments --------- image : ANTsImage image of integer labels physical : boolean wh...
python
{ "resource": "" }
q232523
MultiResolutionImage.transform
train
def transform(self, X, y=None): """ Generate a set of multi-resolution ANTsImage types Arguments --------- X : ANTsImage image to transform y : ANTsImage (optional) another image to transform Example ------- >>> import an...
python
{ "resource": "" }
q232524
LocallyBlurIntensity.transform
train
def transform(self, X, y=None): """ Locally blur an image by applying a gradient anisotropic diffusion filter. Arguments --------- X : ANTsImage image to transform y : ANTsImage (optional) another image to transform. Example ----...
python
{ "resource": "" }
q232525
get_data
train
def get_data(name=None): """ Get ANTsPy test data filename ANTsR function: `getANTsRData` Arguments --------- name : string name of test image tag to retrieve Options: - 'r16' - 'r27' - 'r64' - 'r85' - 'ch2' ...
python
{ "resource": "" }
q232526
convolve_image
train
def convolve_image(image, kernel_image, crop=True): """ Convolve one image with another ANTsR function: `convolveImage` Arguments --------- image : ANTsImage image to convolve kernel_image : ANTsImage image acting as kernel crop : boolean whether to automatica...
python
{ "resource": "" }
q232527
ndimage_to_list
train
def ndimage_to_list(image): """ Split a n dimensional ANTsImage into a list of n-1 dimensional ANTsImages Arguments --------- image : ANTsImage n-dimensional image to split Returns ------- list of ANTsImage types Example ------- >>> import ants >>> image = ...
python
{ "resource": "" }
q232528
_int_antsProcessArguments
train
def _int_antsProcessArguments(args): """ Needs to be better validated. """ p_args = [] if isinstance(args, dict): for argname, argval in args.items(): if '-MULTINAME-' in argname: # have this little hack because python doesnt support # multiple dic...
python
{ "resource": "" }
q232529
initialize_eigenanatomy
train
def initialize_eigenanatomy(initmat, mask=None, initlabels=None, nreps=1, smoothing=0): """ InitializeEigenanatomy is a helper function to initialize sparseDecom and sparseDecom2. Can be used to estimate sparseness parameters per eigenvector. The user then only chooses nvecs and optional regularizat...
python
{ "resource": "" }
q232530
eig_seg
train
def eig_seg(mask, img_list, apply_segmentation_to_images=False, cthresh=0, smooth=1): """ Segment a mask into regions based on the max value in an image list. At a given voxel the segmentation label will contain the index to the image that has the largest value. If the 3rd image has the greatest value, ...
python
{ "resource": "" }
q232531
label_stats
train
def label_stats(image, label_image): """ Get label statistics from image ANTsR function: `labelStats` Arguments --------- image : ANTsImage Image from which statistics will be calculated label_image : ANTsImage Label image Returns ------- ndarray ? ...
python
{ "resource": "" }
q232532
ANTsImage.spacing
train
def spacing(self): """ Get image spacing Returns ------- tuple """ libfn = utils.get_lib_fn('getSpacing%s'%self._libsuffix) return libfn(self.pointer)
python
{ "resource": "" }
q232533
ANTsImage.set_spacing
train
def set_spacing(self, new_spacing): """ Set image spacing Arguments --------- new_spacing : tuple or list updated spacing for the image. should have one value for each dimension Returns ------- None """ if not isin...
python
{ "resource": "" }
q232534
ANTsImage.origin
train
def origin(self): """ Get image origin Returns ------- tuple """ libfn = utils.get_lib_fn('getOrigin%s'%self._libsuffix) return libfn(self.pointer)
python
{ "resource": "" }
q232535
ANTsImage.set_origin
train
def set_origin(self, new_origin): """ Set image origin Arguments --------- new_origin : tuple or list updated origin for the image. should have one value for each dimension Returns ------- None """ if not isinstanc...
python
{ "resource": "" }
q232536
ANTsImage.direction
train
def direction(self): """ Get image direction Returns ------- tuple """ libfn = utils.get_lib_fn('getDirection%s'%self._libsuffix) return libfn(self.pointer)
python
{ "resource": "" }
q232537
ANTsImage.set_direction
train
def set_direction(self, new_direction): """ Set image direction Arguments --------- new_direction : numpy.ndarray or tuple or list updated direction for the image. should have one value for each dimension Returns ------- None ...
python
{ "resource": "" }
q232538
ANTsImage.astype
train
def astype(self, dtype): """ Cast & clone an ANTsImage to a given numpy datatype. Map: uint8 : unsigned char uint32 : unsigned int float32 : float float64 : double """ if dtype not in _supported_dtypes: raise ValueEr...
python
{ "resource": "" }
q232539
ANTsImage.new_image_like
train
def new_image_like(self, data): """ Create a new ANTsImage with the same header information, but with a new image array. Arguments --------- data : ndarray or py::capsule New array or pointer for the image. It must have the same shape as the cur...
python
{ "resource": "" }
q232540
ANTsImage.to_file
train
def to_file(self, filename): """ Write the ANTsImage to file Args ---- filename : string filepath to which the image will be written """ filename = os.path.expanduser(filename) libfn = utils.get_lib_fn('toFile%s'%self._libsuffix) libfn...
python
{ "resource": "" }
q232541
ANTsImage.apply
train
def apply(self, fn): """ Apply an arbitrary function to ANTsImage. Args ---- fn : python function or lambda function to apply to ENTIRE image at once Returns ------- ANTsImage image with function applied to it """ ...
python
{ "resource": "" }
q232542
ANTsImage.sum
train
def sum(self, axis=None, keepdims=False): """ Return sum along specified axis """ return self.numpy().sum(axis=axis, keepdims=keepdims)
python
{ "resource": "" }
q232543
ANTsImage.range
train
def range(self, axis=None): """ Return range tuple along specified axis """ return (self.min(axis=axis), self.max(axis=axis))
python
{ "resource": "" }
q232544
ANTsImage.argrange
train
def argrange(self, axis=None): """ Return argrange along specified axis """ amin = self.argmin(axis=axis) amax = self.argmax(axis=axis) if axis is None: return (amin, amax) else: return np.stack([amin, amax]).T
python
{ "resource": "" }
q232545
ANTsImage.unique
train
def unique(self, sort=False): """ Return unique set of values in image """ unique_vals = np.unique(self.numpy()) if sort: unique_vals = np.sort(unique_vals) return unique_vals
python
{ "resource": "" }
q232546
LabelImage.uniquekeys
train
def uniquekeys(self, metakey=None): """ Get keys for a given metakey """ if metakey is None: return self._uniquekeys else: if metakey not in self.metakeys(): raise ValueError('metakey %s does not exist' % metakey) return self._u...
python
{ "resource": "" }
q232547
label_clusters
train
def label_clusters(image, min_cluster_size=50, min_thresh=1e-6, max_thresh=1, fully_connected=False): """ This will give a unique ID to each connected component 1 through N of size > min_cluster_size ANTsR function: `labelClusters` Arguments --------- image : ANTsImage input imag...
python
{ "resource": "" }
q232548
make_points_image
train
def make_points_image(pts, mask, radius=5): """ Create label image from physical space points Creates spherical points in the coordinate space of the target image based on the n-dimensional matrix of points that the user supplies. The image defines the dimensionality of the data so if the input ima...
python
{ "resource": "" }
q232549
weingarten_image_curvature
train
def weingarten_image_curvature(image, sigma=1.0, opt='mean'): """ Uses the weingarten map to estimate image mean or gaussian curvature ANTsR function: `weingartenImageCurvature` Arguments --------- image : ANTsImage image from which curvature is calculated sigma : scalar ...
python
{ "resource": "" }
q232550
from_numpy
train
def from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False): """ Create an ANTsImage object from a numpy array ANTsR function: `as.antsImage` Arguments --------- data : ndarray image data array origin : tuple/list image origin s...
python
{ "resource": "" }
q232551
_from_numpy
train
def _from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False): """ Internal function for creating an ANTsImage """ if is_rgb: has_components = True ndim = data.ndim if has_components: ndim -= 1 dtype = data.dtype.name ptype = _npy_to_itk_map...
python
{ "resource": "" }
q232552
make_image
train
def make_image(imagesize, voxval=0, spacing=None, origin=None, direction=None, has_components=False, pixeltype='float'): """ Make an image with given size and voxel value or given a mask and vector ANTsR function: `makeImage` Arguments --------- shape : tuple/ANTsImage input image size...
python
{ "resource": "" }
q232553
matrix_to_images
train
def matrix_to_images(data_matrix, mask): """ Unmasks rows of a matrix and writes as images ANTsR function: `matrixToImages` Arguments --------- data_matrix : numpy.ndarray each row corresponds to an image array should have number of columns equal to non-zero voxels in the mask ...
python
{ "resource": "" }
q232554
images_to_matrix
train
def images_to_matrix(image_list, mask=None, sigma=None, epsilon=0.5 ): """ Read images into rows of a matrix, given a mask - much faster for large datasets as it is based on C++ implementations. ANTsR function: `imagesToMatrix` Arguments --------- image_list : list of ANTsImage types ...
python
{ "resource": "" }
q232555
timeseries_to_matrix
train
def timeseries_to_matrix( image, mask=None ): """ Convert a timeseries image into a matrix. ANTsR function: `timeseries2matrix` Arguments --------- image : image whose slices we convert to a matrix. E.g. a 3D image of size x by y by z will convert to a z by x*y sized matrix mas...
python
{ "resource": "" }
q232556
matrix_to_timeseries
train
def matrix_to_timeseries( image, matrix, mask=None ): """ converts a matrix to a ND image. ANTsR function: `matrix2timeseries` Arguments --------- image: reference ND image matrix: matrix to convert to image mask: mask image defining voxels of interest Returns ------- ...
python
{ "resource": "" }
q232557
image_header_info
train
def image_header_info(filename): """ Read file info from image header ANTsR function: `antsImageHeaderInfo` Arguments --------- filename : string name of image file from which info will be read Returns ------- dict """ if not os.path.exists(filename): raise...
python
{ "resource": "" }
q232558
image_read
train
def image_read(filename, dimension=None, pixeltype='float', reorient=False): """ Read an ANTsImage from file ANTsR function: `antsImageRead` Arguments --------- filename : string Name of the file to read the image from. dimension : int Number of dimensions of the image rea...
python
{ "resource": "" }
q232559
dicom_read
train
def dicom_read(directory, pixeltype='float'): """ Read a set of dicom files in a directory into a single ANTsImage. The origin of the resulting 3D image will be the origin of the first dicom image read. Arguments --------- directory : string folder in which all the dicom images exis...
python
{ "resource": "" }
q232560
image_write
train
def image_write(image, filename, ri=False): """ Write an ANTsImage to file ANTsR function: `antsImageWrite` Arguments --------- image : ANTsImage image to save to file filename : string name of file to which image will be saved ri : boolean if True, return ima...
python
{ "resource": "" }
q232561
otsu_segmentation
train
def otsu_segmentation(image, k, mask=None): """ Otsu image segmentation This is a very fast segmentation algorithm good for quick explortation, but does not return probability maps. ANTsR function: `thresholdImage(image, 'Otsu', k)` Arguments --------- image : ANTsImage ...
python
{ "resource": "" }
q232562
crop_image
train
def crop_image(image, label_image=None, label=1): """ Use a label image to crop a smaller ANTsImage from within a larger ANTsImage ANTsR function: `cropImage` Arguments --------- image : ANTsImage image to crop label_image : ANTsImage image with label values. If ...
python
{ "resource": "" }
q232563
decrop_image
train
def decrop_image(cropped_image, full_image): """ The inverse function for `ants.crop_image` ANTsR function: `decropImage` Arguments --------- cropped_image : ANTsImage cropped image full_image : ANTsImage image in which the cropped image will be put back Returns ...
python
{ "resource": "" }
q232564
kmeans_segmentation
train
def kmeans_segmentation(image, k, kmask=None, mrf=0.1): """ K-means image segmentation that is a wrapper around `ants.atropos` ANTsR function: `kmeansSegmentation` Arguments --------- image : ANTsImage input image k : integer integer number of classes kmask : ANTsImag...
python
{ "resource": "" }
q232565
reorient_image2
train
def reorient_image2(image, orientation='RAS'): """ Reorient an image. Example ------- >>> import ants >>> mni = ants.image_read(ants.get_data('mni')) >>> mni2 = mni.reorient_image2() """ if image.dimension != 3: raise ValueError('image must have 3 dimensions') inpixelt...
python
{ "resource": "" }
q232566
reorient_image
train
def reorient_image(image, axis1, axis2=None, doreflection=False, doscale=0, txfn=None): """ Align image along a specified axis ANTsR function: `reorientImage` Arguments --------- image : ANTsImage image to reorient axis1 : list/tuple of integers vector of size dim,...
python
{ "resource": "" }
q232567
get_center_of_mass
train
def get_center_of_mass(image): """ Compute an image center of mass in physical space which is defined as the mean of the intensity weighted voxel coordinate system. ANTsR function: `getCenterOfMass` Arguments --------- image : ANTsImage image from which center of mass will be ...
python
{ "resource": "" }
q232568
to_nibabel
train
def to_nibabel(image): """ Convert an ANTsImage to a Nibabel image """ if image.dimension != 3: raise ValueError('Only 3D images currently supported') import nibabel as nib array_data = image.numpy() affine = np.hstack([image.direction*np.diag(image.spacing),np.array(image.origin).r...
python
{ "resource": "" }
q232569
from_nibabel
train
def from_nibabel(nib_image): """ Convert a nibabel image to an ANTsImage """ tmpfile = mktemp(suffix='.nii.gz') nib_image.to_filename(tmpfile) new_img = iio2.image_read(tmpfile) os.remove(tmpfile) return new_img
python
{ "resource": "" }
q232570
RandomShear3D.transform
train
def transform(self, X=None, y=None): """ Transform an image using an Affine transform with shear parameters randomly generated from the user-specified range. Return the transform if X=None. Arguments --------- X : ANTsImage Image to transform ...
python
{ "resource": "" }
q232571
RandomZoom3D.transform
train
def transform(self, X=None, y=None): """ Transform an image using an Affine transform with zoom parameters randomly generated from the user-specified range. Return the transform if X=None. Arguments --------- X : ANTsImage Image to transform ...
python
{ "resource": "" }
q232572
Translate2D.transform
train
def transform(self, X=None, y=None): """ Transform an image using an Affine transform with the given translation parameters. Return the transform if X=None. Arguments --------- X : ANTsImage Image to transform y : ANTsImage (optional) An...
python
{ "resource": "" }
q232573
RandomTranslate2D.transform
train
def transform(self, X=None, y=None): """ Transform an image using an Affine transform with translation parameters randomly generated from the user-specified range. Return the transform if X=None. Arguments --------- X : ANTsImage Image to transform ...
python
{ "resource": "" }
q232574
Shear2D.transform
train
def transform(self, X=None, y=None): """ Transform an image using an Affine transform with the given shear parameters. Return the transform if X=None. Arguments --------- X : ANTsImage Image to transform y : ANTsImage (optional) Another...
python
{ "resource": "" }
q232575
Zoom2D.transform
train
def transform(self, X=None, y=None): """ Transform an image using an Affine transform with the given zoom parameters. Return the transform if X=None. Arguments --------- X : ANTsImage Image to transform y : ANTsImage (optional) Another ...
python
{ "resource": "" }
q232576
kelly_kapowski
train
def kelly_kapowski(s, g, w, its=50, r=0.025, m=1.5, **kwargs): """ Compute cortical thickness using the DiReCT algorithm. Diffeomorphic registration-based cortical thickness based on probabilistic segmentation of an image. This is an optimization algorithm. Arguments --------- s : AN...
python
{ "resource": "" }
q232577
new_ants_transform
train
def new_ants_transform(precision='float', dimension=3, transform_type='AffineTransform', parameters=None): """ Create a new ANTsTransform ANTsR function: None Example ------- >>> import ants >>> tx = ants.new_ants_transform() """ libfn = utils.get_lib_fn('newAntsTransform%s%i' % (u...
python
{ "resource": "" }
q232578
create_ants_transform
train
def create_ants_transform(transform_type='AffineTransform', precision='float', dimension=3, matrix=None, offset=None, center=None, translation=None, ...
python
{ "resource": "" }
q232579
read_transform
train
def read_transform(filename, dimension=2, precision='float'): """ Read a transform from file ANTsR function: `readAntsrTransform` Arguments --------- filename : string filename of transform dimension : integer spatial dimension of transform precision : string ...
python
{ "resource": "" }
q232580
write_transform
train
def write_transform(transform, filename): """ Write ANTsTransform to file ANTsR function: `writeAntsrTransform` Arguments --------- transform : ANTsTransform transform to save filename : string filename of transform (file extension is ".mat" for affine transforms) ...
python
{ "resource": "" }
q232581
reflect_image
train
def reflect_image(image, axis=None, tx=None, metric='mattes'): """ Reflect an image along an axis ANTsR function: `reflectImage` Arguments --------- image : ANTsImage image to reflect axis : integer (optional) which dimension to reflect across, numbered from 0 to image...
python
{ "resource": "" }
q232582
BIDSCohort.create_sampler
train
def create_sampler(self, inputs, targets, input_reader=None, target_reader=None, input_transform=None, target_transform=None, co_transform=None, input_return_processor=None, target_return_processor=None, co_return_processor=None): """ Create a BIDSSampler that can be used to generate in...
python
{ "resource": "" }
q232583
slice_image
train
def slice_image(image, axis=None, idx=None): """ Slice an image. Example ------- >>> import ants >>> mni = ants.image_read(ants.get_data('mni')) >>> mni2 = ants.slice_image(mni, axis=1, idx=100) """ if image.dimension < 3: raise ValueError('image must have at least 3 dimensi...
python
{ "resource": "" }
q232584
pad_image
train
def pad_image(image, shape=None, pad_width=None, value=0.0, return_padvals=False): """ Pad an image to have the given shape or to be isotropic. Arguments --------- image : ANTsImage image to pad shape : tuple - if shape is given, the image will be padded in each dimension ...
python
{ "resource": "" }
q232585
ANTsImageToImageMetric.set_fixed_image
train
def set_fixed_image(self, image): """ Set Fixed ANTsImage for metric """ if not isinstance(image, iio.ANTsImage): raise ValueError('image must be ANTsImage type') if image.dimension != self.dimension: raise ValueError('image dim (%i) does not match metric...
python
{ "resource": "" }
q232586
ANTsImageToImageMetric.set_moving_image
train
def set_moving_image(self, image): """ Set Moving ANTsImage for metric """ if not isinstance(image, iio.ANTsImage): raise ValueError('image must be ANTsImage type') if image.dimension != self.dimension: raise ValueError('image dim (%i) does not match metr...
python
{ "resource": "" }
q232587
image_to_cluster_images
train
def image_to_cluster_images(image, min_cluster_size=50, min_thresh=1e-06, max_thresh=1): """ Converts an image to several independent images. Produces a unique image for each connected component 1 through N of size > min_cluster_size ANTsR function: `image2ClusterImages` Arguments ------...
python
{ "resource": "" }
q232588
threshold_image
train
def threshold_image(image, low_thresh=None, high_thresh=None, inval=1, outval=0, binary=True): """ Converts a scalar image into a binary image by thresholding operations ANTsR function: `thresholdImage` Arguments --------- image : ANTsImage Input image to operate on low_thresh...
python
{ "resource": "" }
q232589
symmetrize_image
train
def symmetrize_image(image): """ Use registration and reflection to make an image symmetric ANTsR function: N/A Arguments --------- image : ANTsImage image to make symmetric Returns ------- ANTsImage Example ------- >>> import ants >>> image = ants.image_r...
python
{ "resource": "" }
q232590
BaseManager._get_attachments
train
def _get_attachments(self, id): """Retrieve a list of attachments associated with this Xero object.""" uri = '/'.join([self.base_url, self.name, id, 'Attachments']) + '/' return uri, {}, 'get', None, None, False
python
{ "resource": "" }
q232591
BaseManager._put_attachment_data
train
def _put_attachment_data(self, id, filename, data, content_type, include_online=False): """Upload an attachment to the Xero object.""" uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename]) params = {'IncludeOnline': 'true'} if include_online else {} headers = {'Content-...
python
{ "resource": "" }
q232592
PartnerCredentialsHandler.page_response
train
def page_response(self, title='', body=''): """ Helper to render an html page with dynamic content """ f = StringIO() f.write('<!DOCTYPE html>\n') f.write('<html>\n') f.write('<head><title>{}</title><head>\n'.format(title)) f.write('<body>\n<h2>{}</h2>\n'....
python
{ "resource": "" }
q232593
PartnerCredentialsHandler.redirect_response
train
def redirect_response(self, url, permanent=False): """ Generate redirect response """ if permanent: self.send_response(301) else: self.send_response(302) self.send_header("Location", url) self.end_headers()
python
{ "resource": "" }
q232594
PublicCredentials._init_credentials
train
def _init_credentials(self, oauth_token, oauth_token_secret): "Depending on the state passed in, get self._oauth up and running" if oauth_token and oauth_token_secret: if self.verified: # If provided, this is a fully verified set of # credentials. Store the oa...
python
{ "resource": "" }
q232595
PublicCredentials._init_oauth
train
def _init_oauth(self, oauth_token, oauth_token_secret): "Store and initialize a verified set of OAuth credentials" self.oauth_token = oauth_token self.oauth_token_secret = oauth_token_secret self._oauth = OAuth1( self.consumer_key, client_secret=self.consumer_sec...
python
{ "resource": "" }
q232596
PublicCredentials._process_oauth_response
train
def _process_oauth_response(self, response): "Extracts the fields from an oauth response" if response.status_code == 200: credentials = parse_qs(response.text) # Initialize the oauth credentials self._init_oauth( credentials.get('oauth_token')[0], ...
python
{ "resource": "" }
q232597
PublicCredentials.state
train
def state(self): """Obtain the useful state of this credentials object so that we can reconstruct it independently. """ return dict( (attr, getattr(self, attr)) for attr in ( 'consumer_key', 'consumer_secret', 'callback_uri', 'verif...
python
{ "resource": "" }
q232598
PublicCredentials.verify
train
def verify(self, verifier): "Verify an OAuth token" # Construct the credentials for the verification request oauth = OAuth1( self.consumer_key, client_secret=self.consumer_secret, resource_owner_key=self.oauth_token, resource_owner_secret=self.oau...
python
{ "resource": "" }
q232599
PublicCredentials.url
train
def url(self): "Returns the URL that can be visited to obtain a verifier code" # The authorize url is always api.xero.com query_string = {'oauth_token': self.oauth_token} if self.scope: query_string['scope'] = self.scope url = XERO_BASE_URL + AUTHORIZE_URL + '?' + \...
python
{ "resource": "" }