Extract
- class celltk.extract.Extract(images=[], masks=[], channels=[], regions=[], lineages=[], time=None, condition='condition', position_id=0, min_trace_length=0, remove_parent=True, output='data_frame', save=True, force_rerun=True, skip_frames=(), _output_id=None, **kwargs)
- Parameters
images (
Collection[str], default:[]) –masks (
Collection[str], default:[]) –channels (
Collection[str], default:[]) –regions (
Collection[str], default:[]) –lineages (
Collection[ndarray], default:[]) –time (
Optional[float], default:None) –condition (
str, default:'condition') –position_id (
int, default:0) –min_trace_length (
int, default:0) –remove_parent (
bool, default:True) –output (
str, default:'data_frame') –save (
bool, default:True) –force_rerun (
bool, default:True) –skip_frames (
Tuple[int], default:()) –_output_id (
Optional[Tuple[str]], default:None) –
- add_derived_metric(metric_name, keys, func='sum', inverse=False, propagate=False, frame_rng=None, *args, **kwargs)
Calculate additional metrics based on information already in array
- Parameters
metric_name (
str) – Key to save the metric underkeys (
Collection[Tuple[str]]) – One or multiple keys to calculate with. Each key will be used to index an array, ConditionArray[key]. Each key should produce a 2D array when indexed.func (
str, default:'sum') – Name of numpy function to apply, e.g. ‘sum’inverse (
bool, default:False) – If True, repeats the calculation as if the keys were passed in the opposite order and saves in the other keys.propagate ((
str,bool), default:False) – If True, propagates the results of the calculation to the other keys in the array.frame_rng (
Union[int,Tuple[int],None], default:None) – Frames to use in calculation. If int, takes that many frames from start of trace. If tuple, uses passed frames.
- Return type
None
- add_extra_metric(name, func=None)
Add custom metrics or metrics from regionprops to array. If function is none, value will just be nan.
- Parameters
name (
str) – key for the metric in the ConditionArrayfunc (
Optional[Callable], default:None) – If str, name of the metric from skiamge.regionprops. if Callable, function that calculates the metric. Cannot be used if Operation must be saved as YAML before running.
- Return type
None
- add_filter(filter_name, metric, region=0, channel=0, frame_rng=None, *args, **kwargs)
Remove cells from array that do not match the filter.
- Parameters
filter_name (
str) – Options are ‘outside’, ‘inside’, ‘outside_percentile’, ‘inside_percentile’.metric (
str) – Name of metric to use. Can be any key in the array.region (
Union[str,int], default:0) – Name of region to calculate the filter in.channel (
Union[str,int], default:0) – Name of channel to calculate filter in.frame_rng (
Union[int,Tuple[int],None], default:None) – Frames to use in calculation. If int, takes that many frames from start of trace. If tuple, uses passed frames.
- Return type
None
- extract_data_from_image(images, masks, channels=[], regions=[], lineages=[], time=None, condition='default', position_id=None, min_trace_length=0, skip_frames=(), remove_parent=True, parent_track=0)
Extracts data from stacks of images and constructs a ConditionArray.
- Parameters
images (
Image) – Images to extract data from.masks (
Mask) – Masks to segment images with.channels (
Collection[str], default:[]) – Names of channels corresponding toregions (
Collection[str], default:[]) – Names of segmented regions corresponding, tracks and masks, in that order.lineages (
Collection[ndarray], default:[]) – Lineage files corresponding to masks if provided.time (
Union[float,ndarray,None], default:None) – If int or float, designates time between frames. If array, marks the frame time points.condition (
str, default:'default') – Name of the conditionposition_id (
Optional[int], default:None) – Unique identifier if multiple ConditionArrays will share the same conditionmin_trace_length (
int, default:0) – All cells with shorter traces will be deleted from the final array.skip_frames (
Tuple[int], default:()) – Use to specify frames to be skipped. If provided to Pipeline, does not need to be provided again, but must match.remove_parent (
bool, default:True) – If true, parents of cells are not kept in the final ConditionArray.parent_track (
int, default:0) – If multiple tracks are provided, designates the one to use for lineage tracking
- Returns
ConditionArray with data from the images.
- Return type
The following axes dimensions are used: ax 0 - cell locations (nuc, cyto, population, etc.) ax 1 - channels (TRITC, FITC, etc.) ax 2 - metrics (median_int, etc.) ax 3 - cells ax 4 - frames
- set_metric_list(metrics)
Sets the list of metrics to get. For a possible list, see skimage.regionprops or Extract._possible_metrics.
- Parameters
metrics (
Collection[str]) – List of metrics to measure from images- Return type
None- Returns
None
Note
CellTK can only use the scalar metrics in regionprops.