Module gonioanalysis.drosom.loading

Functions related to DrosoM data loading.

Module Level Variables

REPETITION_INDICATOR : str In filenames, the text preceding the repetition value POSITION_INDICATOR : str In filenames, the text preceding the imaging location value IMAGE_NAME_EXTENSIONS : str File name extensions that are treated as image files.

Functions

def angleFromFn(fn)

Returns the horizontal and vertical angles from a given filename The filename must be IMSOFT formatted as im_pos(-30, 170)_rep0_0.tiff

fn Filename, from which to read the angles

def angles_from_fn(fn, prefix='pos')

Takes in a filename that somewhere contains string "pos(hor, ver)", for example "pos(-30, 170)" and returns tuple (-30, 170)

Returns

angle : tuple of ints
Rotation stage values or (0, 0) if the rotation was not found.
def arange_fns(fns)

Arange filenames based on REPETITION_INDICATOR and POSITION_INDICATOR in their time order (repeat 1, image1,2,3,4, repeat 2, image1,2,3,4, …).

If no indicators are found in the filenames then the ordering is at least alphabetical.

def load_data(drosom_folder)

Loads GonioImsoft imaging data filenames into a dictionary.

The data has to be saved according to the folder hierarchy:

LEVEL   Content             Examples
1       specimen_folder     "DrosoM2"
2       image_folder        "pos(0, 0)" "pos(20, 20)") "pos(0, 10)_somesuffixhere"
3       image files         "im_pos(0, 0)_rep0_stack.tiff", "im_pos(0, 0)_rep0_cam2_stack.tiff"

Arguments

drosom_folder : string
Path to the specimen folder that contains the image folders.

Returns

stacks_dictionary : dict

Contains the str((horizontal, pitch)) as keys and a list of image stacks as values.

stacks_dictionary = {"(hor1, pitch1): [[stack_rep1], [stack_rep2], ...]"},
where stack_rep1 = [image1_fn, image2_fn, ...].

Notice 1: The horizontal and pitch angles in the keys are in rotary encoder steps (not degrees).

def split_to_repeats(fns)

Split a list of filenames into repeats (sublists) based on the REPETITION_INDICATOR

Arguments

fns : list
1D sequence of filenames

Returns

splitted_fns : list
A list where each item is a sublist of filenames (or empty list if there were no filenames for that repeat)