seas package

seas.colormaps module

Functions for manipulating matploblib and cv2 colormaps, as well as some functions for converting between rescaled to dfof values. On first import, loads defaults set by seas.defaults configuration into REGION_COLORMAP, DEFAULT_COLORMAP, and COMPONENT_COLORMAP.

Authors: Sydney C. Weiser Date: 2020-03-28

Functions

apply_colormap(video[, colormap])

Save a plt colorbar with a given scale to a specified path.

dfof_to_rescaled(dfof_value, slope, array_min)

Convert a dfof value to 8-bit rescaled units (0-255).

get_mpl_colormap(colormap_name)

Convert a matplotlib colormap to a cv2-compatible colormap.

rescaled_to_dfof(rescaled_value, slope, …)

Convert a value in 8-bit rescaled units (0-255) to a dfof value.

save_colorbar(scale, path[, colormap])

Save a plt colorbar with a given scale to a specified path.

seas.defaults module

Default colormaps and parameters to be used throughout the seas module. The file is saved to config.txt within the seas library. On first import, the config file is loaded and can be accessed through seas.defaults.config.

Default parameters include colormaps, region assignment values, and region abbreviations.

Authors: Sydney C. Weiser Date: 2020-04-21

Functions

load_config([path])

Load the configuration file.

write_config(path[, parameters])

Writes a config file to path.

seas.domains module

Functions for creating and manipulating domain maps, created from maximum projections of independent components detected from mesoscale calcium imaging videos.

Authors: Sydney C. Weiser Date: 2019-06-16

Functions

domain_map(domain_ROIs[, values])

Used to generate a domain map with a specific coloration scheme.

filter_mean(mean[, filter_method, low_cutoff])

Applies a high pass filtration to the ica mean signal.

get_domain_edges(domain_ROIs[, clear_bg, …])

Get the edges of the domain map using canny edge detection.

get_domain_map(components[, blur, …])

Creates a domain map from extracted independent components.

get_domain_rebuilt_timecourses(domain_ROIs, …)

Get time courses for each domain ROI.

get_padded_borders(domain_ROIs, blur, rois)

Since a gaussian blur between a value with a number and a nan border will result in an increasingly large nan border, get this new border roi boundary.

make_mask(polylist, shape[, bounding_box])

Makes mask from coordinates of polygon(s).

mosaic_movie(domain_ROIs, ROI_timecourses[, …])

Creates a mosaic movie, where the original movie is played back as a series of domain timecourses, each displayed over its original domain.

rebuild_mean_roi_timecourse(components, mask)

Rebuild a mean timecourse under a specific region of interest (ROI), or set of ROIs.

rescale(array[, low, high, cap, mean_std, …])

determine upper and lower limits of colormap for playing movie files.

rolling_mosaic_movie(domain_ROIs, …[, …])

A low memory version of mosaic_movie.

rotate(array, n)

Rotate an image or video n times counterclockwise.

save(array, path[, resize_factor, …])

Check what the extension of path is, and use the appropriate function for saving the array.

save_colorbar(scale, path[, colormap])

Save a plt colorbar with a given scale to a specified path.

save_domain_map(domain_ROIs, basepath, …)

Saves domain maps to pngs for visualization.

seas.experiment module

Classes

Experiment(pathlist, downsample, …)

A class to store mesoscale calcium imaging experiment information and provide functions used for common experiment and video manipulations.

hdf5manager(path, verbose, create)

A class for managing saved artifacts in the hdf5 format.

waveletAnalysis(data, fps, **kwargs)

seas.filemanager module

Functions used for loading and finding files for brain analysis.

Authors: Sydney C. Weiser Date: 2017-07-28

Functions

call(*popenargs[, timeout])

Run command with arguments.

experiment_sorter(folder_path[, …])

Finds all files associated with an experiment in a particular folder, organizes them by filetype: movie files, processed files, metadata files.

find_files(folder_path, match_string[, …])

Finds files in folder_path that match a match_string, either at the end of the path if suffix=True, or anywhere if suffix=False.

get_basename(path)

Get the experiment basename, stripping any extensions or tiff file fount extensions.

get_exp_span_string(experiments)

Creates a formatted string based on the experiments found in the experiments list.

movie_sorter(pathlist[, matchstr, verbose])

Takes list of paths, sorts into experiments, and orders files by extension number.

read_yaml(path)

Loads nested dictionaries from .yaml formated files.

sort_experiments(files[, …])

Given a list of files, sort them into relevant experiments.

seas.gui module

Functions

domain_map(domain_ROIs[, values])

Used to generate a domain map with a specific coloration scheme.

get_domain_edges(domain_ROIs[, clear_bg, …])

Get the edges of the domain map using canny edge detection.

get_domain_map(components[, blur, …])

Creates a domain map from extracted independent components.

lag_n_autocorr(x, n[, verbose])

Calculate the lag-n autocorrelation.

rebuild_eigenbrain(eig_vec[, index, …])

Reshape components from (n_components, xy) shape into (n_components, x, y), either through reassigning pixels where the roimask indicates, or by reshaping it into the original dimensions.

run_gui(components[, rotate, savepath, …])

Create a tkinter GUI to select noise components from ica-decomposition components file.

short_time_fourier_transform(data[, fps, …])

Creates a short time windowed fourier transform of a time series

sort_noise([timecourses, lag1, …])

Sorts timecourses into two clusters (signal and noise) based on lag-1 autocorrelation.

seas.hdf5manager module

Tools for standardized saving/loading a class or dictionary to a .hdf5 file. Strings are saved as attributes of the file; lists of strings are saved as tab delimited strings; arrays are saved as datasets. Dicts are saved as a new folder, with data saved as numpy datasets. Other objects are saved as pickle dumps.

Useage:
  • listing objects in an hdf5 file:

    f = hdf5manager(mypath) f.print()

  • saving data to file:

    f = hdf5manager(mypath) f.save(mydict)

    OR:

    f.save(myClass)

  • loading data from file:

    f = hdf5manager(mypath) data = f.load()

Authors: Sydney C. Weiser Date: 2017-01-13

Classes

hdf5manager(path, verbose, create)

A class for managing saved artifacts in the hdf5 format.

seas.ica module

Functions

approximate_svd_linearity_transition(eig_val)

Approximates the transition between the svd signal distribution and the noise floor.

butterworth(data[, high, low, fps, order])

Apply a butterworth filter on the data.

filter_comparison(components[, downsample, …])

Create a filter comparison movie, displaying the original movie, artifacts removed, and the filtered movie side by side.

filter_mean(mean[, filter_method, low_cutoff])

Applies a high pass filtration to the ica mean signal.

lag_n_autocorr(x, n[, verbose])

Calculate the lag-n autocorrelation.

play(array[, textsavepath, min_max, …])

Play movie in opencv after normalizing display range.

project(vector, shape[, roimask, …])

Apply an ica decomposition to the first axis of the input vector.

rebuild(components[, artifact_components, …])

Rebuild original vector space based on a subset of principal components of the data.

rebuild_eigenbrain(eig_vec[, index, …])

Reshape components from (n_components, xy) shape into (n_components, x, y), either through reassigning pixels where the roimask indicates, or by reshaping it into the original dimensions.

rebuild_mean_roi_timecourse(components, mask)

Rebuild a mean timecourse under a specific region of interest (ROI), or set of ROIs.

rescale(array[, low, high, cap, mean_std, …])

determine upper and lower limits of colormap for playing movie files.

rotate(array, n)

Rotate an image or video n times counterclockwise.

save(array, path[, resize_factor, …])

Check what the extension of path is, and use the appropriate function for saving the array.

scale_video(array[, s_factor, t_factor, …])

Scale a video according to spatial and temporal resizing factors.

sort_noise([timecourses, lag1, …])

Sorts timecourses into two clusters (signal and noise) based on lag-1 autocorrelation.

timer

perf_counter() -> float

seas.rois module

Functions

draw_bounding_box(image[, required])

Draw a bounding box on a two dimensional image.

get_masked_region(array, mask[, maskval])

Extract a spatially masked array where the mask == 1 or mask == maskval.

insert_masked_region(array, masked_array, mask)

Insert a spatially masked array from get_masked_region.

make_mask(polylist, shape[, bounding_box])

Makes mask from coordinates of polygon(s).

roi_loader(path[, verbose])

seas.signalanalysis module

Functions

abline(slope, intercept, x_max[, label, …])

Plot a line to the currently active plt figure based on slope and intercept.

argrelextrema(data, comparator[, axis, …])

Calculate the relative extrema of data.

butterworth(data[, high, low, fps, order])

Apply a butterworth filter on the data.

gaussian_smooth_2d(matrix, dj, dt)

This takes a 2-d matrix and applies a smoothing gaussian filter defined by the two sigma variables (dj, dt)

get_peak_separation(log_pdf[, x_grid])

Get peak to peak separation value from the log pdf.

lag_n_autocorr(x, n[, verbose])

Calculate the lag-n autocorrelation.

linear_regression(time, signal[, verbose])

Applies a linear regression to the time-series signal.

local_max(x_values, array1d[, sig])

Finds the local max array values and their respective position (xvalues) by giving a significance cuttoff value array of the same size as the array1d, this will also return the cutoff significance at each local maxima.

local_min(x_values, array1d[, sig])

Finds the local min array values and their respective position (xvalues) by giving a significance cuttoff value array of the same size as the array1d, this will also return the cutoff significance at each local maxima.

short_time_fourier_transform(data[, fps, …])

Creates a short time windowed fourier transform of a time series

sort_noise([timecourses, lag1, …])

Sorts timecourses into two clusters (signal and noise) based on lag-1 autocorrelation.

tdelay_correlation(vectors, n[, max_offset, …])

Calculates correlations of timecourses stored in an array ‘vectors’, of shape (m, t) against the ‘n’th element of the array, or an input vector of size ‘t’.

seas.video module

Functions

ceil(x, /)

Return the ceiling of x as an Integral.

dfof(array[, win_size, win_type])

Calculates the change in fluorescence over mean fluorescense for a video.

downsample(array, new_shape[, keepdims])

Reshape m by n matrix by factor f by reshaping matrix into m f n f matricies, then applying sum across mxf, nxf matrices if keepdims, video is downsampled, but number of pixels remains the same.

get_masked_region(array, mask[, maskval])

Extract a spatially masked array where the mask == 1 or mask == maskval.

insert_masked_region(array, masked_array, mask)

Insert a spatially masked array from get_masked_region.

load(pathlist[, downsample, t_downsample, …])

Loads a list of tiff paths, returns concatenated arrays.

play(array[, textsavepath, min_max, …])

Play movie in opencv after normalizing display range.

rescale(array[, low, high, cap, mean_std, …])

determine upper and lower limits of colormap for playing movie files.

rotate(array, n)

Rotate an image or video n times counterclockwise.

save(array, path[, resize_factor, …])

Check what the extension of path is, and use the appropriate function for saving the array.

save_colorbar(scale, path[, colormap])

Save a plt colorbar with a given scale to a specified path.

scale_video(array[, s_factor, t_factor, …])

Scale a video according to spatial and temporal resizing factors.

timer

perf_counter() -> float

seas.waveletAnalysis module

Adapted from __author__ = ‘Mykhaylo Shumko’ : __init__, waveletTransform, plotPower, lagNAutoCorr All other functions written by Brian Mullen.

To find the global wavelet spectrum run these two scripts:

wave = waveletAnalysis(data) #create object & runs wavelet transform wave.globalWaveletSpectrum() #runs function to create global wavelet spectrum

To find signal change:

waveletAnalysis.tsSignal() There seems to be very little difference between binned data and full data

Classes

GridSpec(nrows, ncols[, figure, left, …])

A grid layout to place subplots within a figure.

datetime(year, month, day[, hour[, minute[, …)

The year, month and day arguments are required.

waveletAnalysis(data, fps, **kwargs)

seas.waveletFunctions module

Copyright (C) 1995-2004, Christopher Torrence and Gilbert P.Compo Python version of the code is written by Evgeniya Predybaylo in 2014

This software may be used, copied, or redistributed as long as it is not sold and this copyright notice is reproduced on each copy made. This routine is provided as is without any express or implied warranties whatsoever.

Notice: Please acknowledge the use of the above software in any publications:
``Wavelet software was provided by C. Torrence and G. Compo,

and is available at URL: http://paos.colorado.edu/research/wavelets/’’.

Reference: Torrence, C. and G. P. Compo, 1998: A Practical Guide to

Wavelet Analysis. <I>Bull. Amer. Meteor. Soc.</I>, 79, 61-78.

Please send a copy of such publications to either C. Torrence or G. Compo:

Dr. Christopher Torrence Dr. Gilbert P. Compo Research Systems, Inc. Climate Diagnostics Center 4990 Pearl East Circle 325 Broadway R/CDC1 Boulder, CO 80301, USA Boulder, CO 80305-3328, USA E-mail: chris[AT]rsinc[DOT]com E-mail: compo[AT]colorado[DOT]edu


Functions

chisquare_inv(P, V)

CHISQUARE_INV Inverse of chi-square cumulative distribution function (cdf).

chisquare_solve(XGUESS, P, V)

CHISQUARE_SOLVE Internal function used by CHISQUARE_INV

fminbound(func, x1, x2[, args, xtol, …])

Bounded minimization for scalar functions.

wave_bases(mother, k, scale, param)

WAVE_BASES 1D Wavelet functions Morlet, Paul, or DOG

wave_signif(Y, dt, scale[, sigtest, lag1, …])

WAVE_SIGNIF Significance testing for the 1D Wavelet transform WAVELET

wavelet(Y, dt[, pad, dj, s0, J1, mother, param])

WAVELET 1D Wavelet transform with optional significance testing