mrbles.data module¶
Data Classes and Functions¶
This file stores the data classes and functions for the MRBLEs Analysis module.
-
class
mrbles.data.
ImageDataFrame
(data=None)[source]¶ Bases:
future.types.newobject.newobject
Xarray based dataframe object for images.
Variables: - data (Xarray DataArray) – Returns (cropped, if crop_x and/or crop_y is set) Xarray DataArray.
- xdata (Xarray DataArray) – Returns uncropped Xarray DataArray.
- sets (list) – Returns a list of all set names, if ‘set’ column is present.
- crop_x (slice) – Crop X slice. Set with slice().
- crop_y (slice) – Crop Y slice. Set with slice().
-
combine
(images)[source]¶ Combine iamges with dataframe.
Parameters: images (Xarray DataArray, dict of Xarray DataArrays)
-
crop_x
¶ Crop X slice. Set with slice().
-
crop_y
¶ Crop Y slice. Set with slice().
-
data
¶ Return cropped Xarray dataframe.
-
sets
¶ Return list of sets.
-
shift_channel
(channel, x_shift, y_shift)[source]¶ Shift images of channel by x and y pixels.
WARNING: This will shift the images permanently and sets inbound pixels to 0. Reload images to reset.
Parameters: - channel (str) – Channel name to shift.
- x_shift (int) – Pixels to shift in X dimension.
- y_shift (int) – Pixels to shift in Y dimension.
-
xdata
¶ Return uncropped Xarray dataframe.
-
class
mrbles.data.
ImageSetRead
(file_path, series=0, output='xr')[source]¶ Bases:
mrbles.data.ImageDataFrame
Image set data object that loads image set from file(s).
Parameters: - file_path (string/list [string, string, …]) – File path as string, e.g. ‘C:/folder/file.tif’, or as list of file paths, e.g. [‘C:/folder/file.tif’, ‘C:/folder/file.tif’].
- series (int, optional) – Sets the series number if file has multiple series. To Loads all series set to series=’all’. Defaults to 0.
- output (str, optional) – Sets default output method. Options: ‘nd’ for NumPy ndarray or ‘xd’ for xarray. Defaults to ‘ndarray’.
Variables: function descriptions. (See) –
Returns: - _dataframe (xarray dataframe) – Returned when calling the instance.
- _dataframe[idx] (NumPy ndarray) – Returns the index value or slice values: [start:stop:stride]. Warning: when using column names stop values are included.
Examples
>>> image_data_object = ImageSetRead('C:/folder/file.tif') >>> image_files = ['C:/folder/file.tif', 'C:/folder/file.tif'] >>> image_data_object = ImageSetRead(image_files, output='xd') >>> image_data_object['BF', 100:400, 100:400] (301L, 301L)
-
axes
¶ Return data order.
Returns: data_order – Returns order as string with: P for position; F for file; T for timepoint, C for channel; Y for Y-axis; X for X-axis. Return type: string Examples
>>> image_data_object = ImageSetRead('C:/folder/file.tif') >>> image_data_object.axes 'TCYX'
-
c_names
¶ Return channel names.
-
c_size
¶ Return channel count.
-
f_names
¶ Return file names.
-
f_size
¶ Return file count.
-
is_multi_file
¶ Return if from multiple files.
-
classmethod
load
(file_path, series=0)[source]¶ Load image files into data structures.
Class method. Can be used without instantiating.
Parameters: - file_path (string/list [string, string, …]) – File path as string, e.g. ‘C:/folder/file.tif’, or as list of file paths, e.g. [‘C:/folder/file.tif’, ‘C:/folder/file.tif’].
- series (int, optional) – Sets the series number if file has multiple series (or positions). Use series=’all’ for loading all series. Defaults to 0.
Examples
>>> ImageSetRead.load('C:/folder/file.tif') >>> image_files = ['C:/folder/file.tif', 'C:/folder/file.tif'] >>> ImageSetRead.load(image_files)
-
p_size
¶ Return position count.
-
s_size
¶ Return series count.
-
static
scan_path
(path, pattern='.*.tif')[source]¶ Scan folder recursively for files matching the pattern.
Parameters: - path (string) – Folder path as string, e.g. r’C:/folder/file.tif’.
- pattern (string) – General file pattern as search string, e.g. ‘20160728_MOL_*’, using regular expressions (regex). Defaults to ‘.*.tif’.
-
classmethod
scan_paths
(paths, pattern='.*.tif')[source]¶ Scan folders recursively for files matching the pattern.
Parameters: - paths (list) – Folder paths as list, e.g. [‘C:/folder/file.tif’, …].
- pattern (string) – General file pattern as search string, e.g. ‘20160728_MOL_*’, using regular expressions (regex).
-
t_deltas
¶ Return time deltas between each image acquisition.
Default in milliseconds (ms), check object.t_unit for time unit.
-
t_interval
¶ Return set time interval.
Default in milliseconds (ms), check object.t_unit for time unit.
-
t_size
¶ Return time-point count.
-
t_unit
¶ Return time unit.
-
z_size
¶ Return Z-slice count.