morphoclass.data.filters module

Various filters used for morphology data loading.

A typical use of filter is in constructing instances of the morphoclass.data.MorphologyDataset class. The filters can be passed under the pre_filter argument in the constructor.

morphoclass.data.filters.attribute_check(attribute, default_return)

Decorate filter function to check for an attribute in data.

The filter function should have the signature filter_fn(data), where data is an instance of torch_geometric.data.Data.

The decorated filter function will check if the data object has the given attribute, and if it doesn’t then a warning is issued and the default_return will be returned.

Parameters
  • attribute (str) – The attribute to check for in data.

  • default_return (bool) – The default value to be returned by the decorated filter function in case where the attribute is missing in data.

Returns

wrapped_filter

Return type

function

morphoclass.data.filters.combined_filter(*filters)

Combine multiple data filters into one.

Parameters

filters (function) – A list of filter functions to be combined.

Returns

filter_fn – A filter function combining all filters in filters.

Return type

function

Examples

>>> filter_1 = data_exclusion_filter("IPC")
>>> filter_2 = data_exclusion_filter(["file1", "file2"])
>>> my_filter = combined_filter(filter_1, filter_2)
morphoclass.data.filters.exclusion_filter(arg)
morphoclass.data.filters.exclusion_filter(filenames: list)
morphoclass.data.filters.exclusion_filter(mtype_substring: str)

Construct an exclusion filter for morphology dataset loaders.

This is a single dispatch class, therefore the concrete implementation depends on the type of the arg argument.

Parameters

arg (The argument for the concrete implementation of the filter) –

Returns

filter_implementation – The filter function with the signature filter_implementation(data), which return True if the data object should be loaded, and False otherwise.

Return type

function

morphoclass.data.filters.filename_exclusion_filter(filenames: list)

Exclusion filter based on a list of filenames.

Parameters

filenames (list) – A list of filenames to exclude.

Returns

filter_implementation – The filter function.

Return type

function

morphoclass.data.filters.filename_inclusion_filter(filenames)

Exclusion filter based on a list of filenames.

Parameters

filenames (list) – A list of filenames to include.

Returns

filter_implementation – The filter function.

Return type

function

morphoclass.data.filters.has_apicals_filter(data)

Keep only data objects with morphologies containing apical dendrites.

Returns

keep – Whether to keep or not to keep the data object.

Return type

bool

morphoclass.data.filters.inclusion_filter(arg)
morphoclass.data.filters.inclusion_filter(filenames: list)

Construct an inclusion filter for morphology dataset loaders.

A typical use of filter is in constructing instances of the morphoclass.data.MorphologyDataset class. The filters can be passed under the pre_filter argument in the constructor.

This is a single dispatch class, therefore the concrete implementation depends on the type of the arg argument.

Parameters

arg (The argument for the concrete implementation of the filter) –

Returns

filter_implementation – The filter function with the signature filter_implementation(data), which return True if the data object should be loaded, and False otherwise.

Return type

function

morphoclass.data.filters.mtype_exclusion_filter(mtype_substring: str)

Exclusion filter based on the m-type of sample.

It is assumed that the morphology files are organised in folders, each folder representing an m-type. If the mtype_substring is part of the m-type folder name of the given data instance, then this instance is ignored.

Parameters

mtype_substring (str) – All m-types that contain mtype_substring are excluded.

Returns

filter_implementation – The implementation of the filter.

Return type

function