Stoner.Image.ImageFolder¶
- class Stoner.Image.ImageFolder(*args, **kwargs)[source]¶
Folder object for images.
ImageFolder is designed to behave pretty much like DataFolder but with functions and loaders appropriate for image based files.
- type¶
the type ob object to store in the folder (defaults to
Stoner.Cire.Data)
- extra_args¶
Extra arguments to use when instantiatoing the contents of the folder from a file on disk.
- Type:
- pattern¶
A filename globbing pattern that matches the contents of the folder. If a regular expression is provided then any named groups are used to construct additional metadata entryies from the filename. Default is . to match all files with an extension.
- Type:
str or regexp
- read_means¶
If true, additional metadata keys are added that return the mean value of each column of the data. This can hep in grouping files where one column of data contains a constant value for the experimental state. Default is False
- Type:
- recursive¶
Specifies whether to search recursively in a whole directory tree. Default is True.
- Type:
- flatten¶
Specify where to present subdirectories as separate groups in the folder (False) or as a single group (True). Default is False. The
DiskBasedFolderMixin.flatten()method has the equivalent effect andDiskBasedFolderMixin.unflatten()reverses it.- Type:
- directory¶
The root directory on disc for the folder - by default this is the current working directory.
- Type:
- multifile¶
Whether to select individual files manually that are not (necessarily) in a common directory structure.
- Type:
boo
Methods
__init__(*args, **kwargs)Additional constructor for DiskBasedFolderMixins.
add_group(key)Add a new group to the current BaseFolder with the given key.
align(*args, **kwargs)Align each image in the folder to the reference image.
all()Iterate over all the files in the Folder and all it's sub Folders recursely.
append(value)Append an item to the folder object.
apply_all(func, *args, **kwargs)Apply function to all images in the stack.
as_stack()Return a ImageStack of the images in the current group.
average([weights, _box, _metadata])Get an array of average pixel values for the stack.
clear()Clear the subgroups.
compress([base, key, keep_terminal])Compresses all empty groups from the root up until the first non-empty group is located.
concatenate([sort, reverse])Concatenates all the files in a objectFolder into a single metadataObject like object.
count(value)Provide a count method like a sequence.
extend(values)S.extend(iterable) -- extend sequence by appending elements from the iterable
extract(*metadata, **kwargs)Extract metadata from each of the files in the terminal group.
fetch()Preload the contents of the DiskBasedFolderMixin.
file(name, value[, create, pathsplit])Recursely add groups in order to put the named value into a virtual tree of
BaseFolder.filter([filter, invert, copy, recurse, prune])Filter the current set of files by some criterion.
filterout(filter[, copy, recurse, prune])Synonym for fldr.filter(filter,invert=True).
flatten([depth])Compresses all the groups and sub-groups iunto a single flat file list.
from_tiff(filename, **kwargs)Create a new ImageArray from a tiff file.
gather([xcol, ycol])Collect xy and y columns from the subfiles in the final group in the tree.
get(name[, default])Return either a sub-group or named object from this folder.
getlist(**kwargs)Scan the current directory, optionally recursively to build a list of filenames.
group(key)Sort Files into a series of objectFolders according to the value of the key.
index(value[, start, stop])Provide an index method like a sequence.
insert(index, value)Implement the insert method with the option to append as well.
items()Return the key,value pairs for the subbroups of this folder.
Filter out earlier revisions of files with the same name.
keys()Return the keys used to access the sub-=groups of this folder.
Load all files from this group into memory.
make_name([value])Construct a name from the value object if possible.
Run the ImageFile.mask.select() on each image.
mean([_box, _metadata])Calculate the mean value of all the images in the stack.
montage(*args, **kwargs)Call the plot method for each metadataObject, but switching to a subplot each time.
on_load_process(tmp)Carry out processing on a newly loaded file to set means and extra metadata.
pop([name, default])Return and remove either a subgroup or named object from this folder.
popitem()Return the most recent subgroup from this folder.
prune([name])Remove any empty groups from the objectFolder (and subgroups).
remove(value)S.remove(value) -- remove first occurrence of value.
reverse()S.reverse() -- reverse IN PLACE
save([root])Save the entire data folder out to disc using the groups as a directory tree.
select(*args, **kwargs)Select a subset of the objects in the folder based on flexible search criteria on the metadata.
setdefault(k[, d])Return or set a subgroup or named object.
slice_metadata(key[, output])Return an array of the metadata values for each item/file in the top level group.
sort([key, reverse, recurse])Sort the files by some key.
stddev([weights, _box, _metadata])Calculate weighted standard deviation for stack.
stderr([weights, _box, _metadata])Calculate standard error in the stack average.
to_tiff(filename)Save the ImageArray as a tiff image with metadata.
Take the file list an unflattens them according to the file paths.
unload([name])Remove the instance from memory without losing the name in the Folder.
update(other)Update this folder with a dictionary or another folder.
values()Return the sub-groups of this folder.
walk_groups(walker, **kwargs)Walk through a hierarchy of groups and calls walker for each file.
zip_groups(groups)Return a list of tuples of metadataObjects drawn from the specified groups.
Attributes
basenamesReturn a list of just the filename parts of the objectFolder.
cloneClone just does a deepcopy as a property for compatibility with
Stoner.Core.DataFile.debugJust read the local debug value.
defaultsBuild a single list of all of our defaults by iterating over the __mro__, caching the result.
depthGive the maximum number of levels of group below the current objectFolder.
Just alias directory to root now.
eachReturn a
Stoner.folders.each.itemproxy object.filesReturn an iterator of potentially unloaded named objects.
groupsSubfolders are held in an ordered dictionary of groups.
imagesIterate over just the images in the Folder.
instanceReturn a default instance of the type of object in the folder.
is_emptyReturn True if the folder is empty.
keyOverride the parent class key to use the directory attribute.
layoutReturn a tuple that describes the number of files and groups in the folder.
loadedIterate only over those members of the folder in memory.
loaderReturn a callable that will load the files on demand.
lsList just the names of the objects in the folder.
lsgrpReturn a list of the groups as a generator.
metadataReturn a
Stoner.folders.metadata.MetadataProxyobject.mindepthGive the minimum number of levels of group below the current objectFolder.
not_emptyIterate over the objectFolder that checks whether the loaded metadataObject objects have any data.
not_loadedReturn an array of True/False for whether we've loaded a metadataObject yet.
objectsReturn the objects in the folder are stored in a
RegexpDict.Provide support for getting the pattern attribute.
rootReturn the real folder root.
setasReturn the proxy for the setas attribute for each object in the folder.
shapeReturn a data structure that is characteristic of the objectFolder's shape.
sizeReturn the size of an individual image or False if not all images are the same size.
trunkdepthReturn the number of levels of group before a group with files is found.
Return the (sub)class of the
Stoner.Core.metadataObjectinstances.