nibabel.fileslice

Utilities for getting array slices out of file-like objects

Functions

calc_slicedefs(sliceobj, in_shape, itemsize, ...)

Return parameters for slicing array with sliceobj given memory layout

canonical_slicers(sliceobj, shape[, check_inds])

Return canonical version of sliceobj for array shape shape

fileslice(fileobj, sliceobj, shape, dtype[, ...])

Slice array in fileobj using sliceobj slicer and array definitions

fill_slicer(slicer, in_len)

Return slice object with Nones filled out to match in_len

is_fancy(sliceobj)

Returns True if sliceobj is attempting fancy indexing

optimize_read_slicers(sliceobj, in_shape, ...)

Calculates slices to read from disk, and apply after reading

optimize_slicer(slicer, dim_len, all_full, ...)

Return maybe modified slice and post-slice slicing for slicer

predict_shape(sliceobj, in_shape)

Predict shape of array from slicing array shape shape with sliceobj

read_segments(fileobj, segments, n_bytes[, lock])

Read n_bytes byte data implied by segments from fileobj

slice2len(slicer, in_len)

Output length after slicing original length in_len with slicer Parameters ---------- slicer : slice object in_len : int

slice2outax(ndim, sliceobj)

Matching output axes for input array ndim ndim and slice sliceobj

slicers2segments(read_slicers, in_shape, ...)

Get segments from read_slicers given in_shape and memory steps

strided_scalar(shape[, scalar])

Return array shape shape where all entries point to value scalar

threshold_heuristic(slicer, dim_len, stride)

Whether to force full axis read or contiguous read of stepped slice