seqfish_fm_match package

class seqfish_fm_match.CrossChannelFMMatcher(ro, ref, ref_final=None, eps_xy=0, eps_z=0)

Bases: object

align_channels()
align_refs()
auto_set_params()
class seqfish_fm_match.FMMatcher(ro, ref, ref_final=None, eps_xy=0, eps_z=0)

Bases: object

This Class aligns dots in a seqFISH experiment image containing fiducial markers, to a reference image containing only the fiducial markers

Parameters:
  • ro – pandas dataframe of reodout points with columns = (“x”, “y”, “z”, “int”) and index “hyb” denoting the hybridiztion in which the point was found.

  • ref – pandas dataframe of reference points with columns = (“x”, “y”, “z”, “int”)

  • ref_final – Optional- pandas dataframe of final reference points measured after readout hybridizations. Used for automatically setting parameters in the auto_set_parameters method.

Return FMMatcher:

align(hybs=None)

aligns hybridizations in the readout points to the reference

Parameters:

hybs – list of hybridizations to align. If None, aligns all hybridizations.

Returns:

align_hyb(hyb, ch=None, print_hyb=True)

Finds the alignment of a readout hybridization to the reference

Parameters:
  • hyb – integer number of the hybridization to align (if not supplying the to_align dataframe)

  • ref – Optional- pandas DataFrame of the reference dots. If not given, uses self.ref

  • to_align – Optional - pandas DataFrame of readout dots to align. if not given, aligns the hyb number given.

Returns:

list: [x_mean_offset, y_mean_offset, z_mean_offset, x_mean_offset_se, y_mean_offset_se, z_mean_offset_se, <number of dots used to calculate offsets>]

auto_set_params()

Matches the initial reference dots to the final reference dots by trying a range of possible search parameters. Uses summary statistics of the alignment errors and differences in brightness to set search parameters to help in the search for the fiducial markers in the readout hybridizations.

Returns:

tuple(opt_matches :: pd.DataFrame, mm_lt, mm_zt, x_offset, y_offset, z_offset, lat_offset)

load_saved_parameters(params_file_name)

Load previously found and saved parameters to the FMMatcher object.

Parameters:

params_file_name

Returns:

None

remove_double_reference_markers(ref, xy_r, z_r)

Removes fiducial markers from the reference list that are within given lateral and z radii of each other.

Parameters:
  • ref – dataframe of fiducial markers in the reference image

  • xy_r – minimum allowed lateral separation of fiducial markers

  • z_r – minimum allowed z separation of fiducial markers

Returns:

save_loocv_errors(filename)

Saves leave-one-out cross validation error estimates to a csv file.

Parameters:

filename – Name of the file to which to save error estimates.

Returns:

save_matches(save_name)

Save csv file of fiducial marker matches between the reference and each readout hybridization.

Parameters:

save_name – Name of the file to which to save matches.

Returns:

save_offsets(filename)

Saves alignment offsets found to csv file.

Parameters:

filename – name of the csv file to which to save.

Returns:

save_pairwise_tforms(filename)

Saves a for dimensional array of affine transforms between hybridizations to a npy file. The first two dimensions are for each of the pairwise hybridizations. The Matrix returned in the index [i, j, :, :] gives the output of the [estimateAffine3D](https://docs.opencv.org/3.4/d9/d0c/group__calib3d.html#ga396afb6411b30770e56ab69548724715) function of OpenCV when estimating an affine transformation between hybridization i and hybridization j.

Parameters:

filename – name of the csv file to which to save.

Returns:

save_params(save_name)

Saves the parameters from the FMMatcher object to a csv file.

Parameters:

save_name – The file name which to save the parameters to.

Returns:

set_max_bright_prop(mbp)

Sets tne maximum proportion of brightness between fiducial markers in the readout hybridiztions to the reference image.

Parameters:

mbp

Returns:

None

set_max_lat_offset(mlo)

Sets an upper bound on the lateral drift from the reference image to each readout hybridization to help narrow the search for initial pairs of fiducial markers (optional).

Parameters:

mlo – the maximum allowed lateral (xy) offset from reference

Returns:

None

set_max_z_offset(mzo)

Sets an upper bound on the z drift from the reference image to each readout hybridization to help narrow the search for initial pairs of fiducial markers (optional).

Parameters:

mzo – the maximum allowed z offset from reference

Returns:

None

set_min_bright_prop(mbp)

The set the minimum proportion of brightness between fiducial markers in the readout hybridations to in the reference image.

Parameters:

mbp – the minimum proportion of brightness between fiducial markers in the readout hybridations to in the reference

image. :return: None

set_min_dot_matches(mdm)

At least this many dots must be matched to consider a fiducial marker pattern in a readout image matched to the reference pattern.

Parameters:

mdm – The minimum number of matched dots in a matched hybridization image fiducial marker pattern

Returns:

None

set_min_edge_match(min_edge_matches)

Set the minimum number of pairs of fiducial markers that must be matched to consider the fiducial markers pattern matched.

Parameters:

min_edge_matches

Returns:

None

set_min_fm_hyb_matches(mfhm)

Fiducial markers that were matched in fewer hybridizations than this will be discarded.

Parameters:

mfhm – the minimum fidicuial marker hyb marches

Returns:

set_n_longest_edges(nle)

Sets the number of longest edges to search through to find initial pair of fiducial markers.

Parameters:

nle – The number of pairs of longest edges to search through to find initial pair of fiducial markers.

Returns:

None

set_n_unmatch_give_up(nugu)

If after finding an initial pair of fiducial markers, the algorithm searches for this many other fiducial markers without finding any, assume that the initial match was in error, and proceed to search for a new initial match.

Parameters:

nugu

Returns:

None

set_outlier_sd_thresh(ost)

Matched fiducial markers that have drifted more than this many standard deviations difference that the mean distance that all matched have drifted will be removed.

Parameters:

ost – the z-score threshold for outliers

Returns:

set_xy_search_error(xyse)

Sets the allowed lateral error when matching pairs of fiducial markers.

Parameters:

xyse

Returns:

None

set_z_search_error(zse)

Sets the allowed z error when matching pairs of fiducial markers.

Parameters:

zse

Returns:

None