rapidtide.workflows: Rapidtide workflows

Common rapidtide workflows.


rapidtide.correlate: Correlation functions

Functions for calculating correlations and similar metrics between arrays.


Check for autocorrelation in an array.

rapidtide.correlate.shorttermcorr_1D(data1, ...)

Calculate short-term sliding-window correlation between two 1D arrays.

rapidtide.correlate.shorttermcorr_2D(data1, ...)

Calculate short-term sliding-window correlation between two 2D arrays.

rapidtide.correlate.calc_MI(x, y[, bins])

Calculate mutual information between two arrays.

rapidtide.correlate.mutual_info_2d(x, y[, ...])

Compute (normalized) mutual information between two 1D variate from a joint histogram.

rapidtide.correlate.cross_mutual_info(x, y)

Calculate cross-mutual information between two 1D arrays.


Convert mutual information to Pearson product-moment correlation.

rapidtide.correlate.delayedcorr(data1, ...)

Calculate correlation between two 1D arrays, at specific delay.

rapidtide.correlate.cepstraldelay(data1, ...)

Estimate delay between two signals using Choudhary's cepstral analysis method.

rapidtide.correlate.arbcorr(input1, Fs1, ...)

Calculate something.

rapidtide.correlate.faststcorrelate(input1, ...)

Perform correlation between short-time Fourier transformed arrays.

rapidtide.correlate.fastcorrelate(input1, input2)

Perform a fast correlation between two arrays.

rapidtide.correlate._centered(arr, newsize)

Return the center newsize portion of the array.


Check that two shapes are 'valid' with respect to one another.


Convolve two N-dimensional arrays using FFT.

rapidtide.correlate.gccproduct(fft1, fft2, ...)

Calculate product for generalized crosscorrelation.

rapidtide.filter: Filters

This module contains all the filtering operations for the rapidtide package.

rapidtide.filter.padvec(inputdata[, padlen, ...])

Returns a padded copy of the input data; padlen points of reflected data are prepended and appended to the input data to reduce end effects when the data is then filtered.

rapidtide.filter.unpadvec(inputdata[, padlen])

Returns a input data with the end pads removed (see padvec); padlen points of reflected data are removed from each end of the array.

rapidtide.filter.ssmooth(xsize, ysize, ...)

Applies an isotropic gaussian spatial filter to a 3D array

rapidtide.filter.dolpfiltfilt(Fs, upperpass, ...)

Performs a bidirectional (zero phase) Butterworth lowpass filter on an input vector and returns the result.

rapidtide.filter.dohpfiltfilt(Fs, lowerpass, ...)

Performs a bidirectional (zero phase) Butterworth highpass filter on an input vector and returns the result.

rapidtide.filter.dobpfiltfilt(Fs, lowerpass, ...)

Performs a bidirectional (zero phase) Butterworth bandpass filter on an input vector and returns the result.

rapidtide.filter.transferfuncfilt(inputdata, ...)

Filters input data using a previously calculated transfer function.

rapidtide.filter.getlpfftfunc(Fs, upperpass, ...)

Generates a brickwall lowpass transfer function.

rapidtide.filter.dolpfftfilt(Fs, upperpass, ...)

Performs an FFT brickwall lowpass filter on an input vector and returns the result.

rapidtide.filter.dohpfftfilt(Fs, lowerpass, ...)

Performs an FFT brickwall highpass filter on an input vector and returns the result.

rapidtide.filter.dobpfftfilt(Fs, lowerpass, ...)

Performs an FFT brickwall bandpass filter on an input vector and returns the result.

rapidtide.filter.getlptrapfftfunc(Fs, ...[, ...])

Generates a trapezoidal lowpass transfer function.

rapidtide.filter.dolptrapfftfilt(Fs, ...[, ...])

Performs an FFT filter with a trapezoidal lowpass transfer function on an input vector and returns the result.

rapidtide.filter.dohptrapfftfilt(Fs, ...[, ...])

Performs an FFT filter with a trapezoidal highpass transfer function on an input vector and returns the result.

rapidtide.filter.dobptrapfftfilt(Fs, ...[, ...])

Performs an FFT filter with a trapezoidal bandpass transfer function on an input vector and returns the result.


lambd is the SNR in the fourier domain


Calculate the power spectrum of an input signal

rapidtide.filter.spectrum(inputdata[, Fs, ...])

Performs an FFT of the input data, and returns the frequency axis and spectrum of the input signal.

rapidtide.filter.csdfilter(obsdata, commondata)

Cross spectral density filter - makes a filter transfer function that preserves common frequencies.

rapidtide.filter.arb_pass(Fs, inputdata, ...)

Filters an input waveform over a specified range.

rapidtide.filter.blackmanharris(length[, debug])

Returns a Blackman Harris window function of the specified length.

rapidtide.filter.hann(length[, debug])

Returns a Hann window function of the specified length.

rapidtide.filter.hamming(length[, debug])

Returns a Hamming window function of the specified length.

rapidtide.filter.windowfunction(length[, ...])

Returns a window function of the specified length and type.



rapidtide.fit: Fitting functions

rapidtide.fit.gaussresidualssk(p, y, x)

param p

rapidtide.fit.gaussskresiduals(p, y, x)

param p

rapidtide.fit.gaussresiduals(p, y, x)

param p

rapidtide.fit.trapezoidresiduals(p, y, x, ...)

param p

rapidtide.fit.risetimeresiduals(p, y, x)

param p

rapidtide.fit.gausssk_eval(x, p)

param x

rapidtide.fit.gauss_eval(x, p)

param x

rapidtide.fit.trapezoid_eval_loop(x, ...)

param x

rapidtide.fit.risetime_eval_loop(x, p)

param x

rapidtide.fit.trapezoid_eval(x, toplength, p)

param x

rapidtide.fit.risetime_eval(x, p)

param x

rapidtide.fit.locpeak(data, samplerate, ...)

param data

rapidtide.fit.trendgen(thexvals, ...)

param thexvals

rapidtide.fit.detrend(inputdata[, order, demean])

param inputdata

rapidtide.fit.findfirstabove(theyvals, thevalue)

param theyvals

rapidtide.fit.findtrapezoidfunc(thexvals, ...)

param thexvals

rapidtide.fit.findrisetimefunc(thexvals, ...)

param thexvals

rapidtide.fit.findmaxlag_gauss(thexcorr_x, ...)

param thexcorr_x

rapidtide.fit.maxindex_noedge(thexcorr_x, ...)

param thexcorr_x

rapidtide.fit.findmaxlag_gauss_rev(...[, ...])

param thexcorr_x

The time axis of the correlation function

rapidtide.fit.findmaxlag_quad(thexcorr_x, ...)

param thexcorr_x

rapidtide.fit.gaussfitsk(height, loc, width, ...)

param height

rapidtide.fit.gaussfit(height, loc, width, ...)

param height

rapidtide.fit.mlregress(x, y[, intercept])

param x

rapidtide.fit.parabfit(x_axis, y_axis, ...)

param x_axis

rapidtide.fit._datacheck_peakdetect(x_axis, ...)

param x_axis

rapidtide.fit.peakdetect(y_axis[, x_axis, ...])

Converted from/based on a MATLAB script at: http://billauer.co.il/peakdet.html

rapidtide.io: Input/output functions


Open a nifti file and read in the various important parts

rapidtide.io.readfromcifti(inputfile[, debug])

Open a cifti file and read in the various important parts



Split the dims array into individual elements


Split the size array into individual elements

rapidtide.io.savetonifti(thearray, ...)

Save a data array out to a nifti file

rapidtide.io.savetocifti(thearray, ...[, ...])

Save a data array out to a cifti


Check to see if a file name is a valid nifti name.


Split nifti filename into name base and extensionn.

rapidtide.io.niftisplit(inputfile, outputroot)

rapidtide.io.niftimerge(inputlist, outputname)

rapidtide.io.niftiroi(inputfile, outputfile, ...)

rapidtide.io.checkifcifti(filename[, debug])

Check to see if the specified file is CIFTI format


Check to see if the specified filename ends in '.txt'


Strip a nifti filename down to the root with no extensions


Retrieve the header information from a nifti file


Retrieve the repetition time and number of timepoints from a nifti file

rapidtide.io.checkspacematch(hdr1, hdr2[, ...])

Check the headers of two nifti files to determine if the cover the same volume at the same resolution (within tolerance)

rapidtide.io.checkspaceresmatch(sizes1, sizes2)

Check the spatial pixdims of two nifti files to determine if they have the same resolution (within tolerance)

rapidtide.io.checkspacedimmatch(dims1, dims2)

Check the dimension arrays of two nifti files to determine if the cover the same number of voxels in each dimension

rapidtide.io.checktimematch(dims1, dims2[, ...])

Check the dimensions of two nifti files to determine if the cover the same number of timepoints


Checks to see if a file is an FSL style motion parameter file


Checks to see if a file is an FSL style motion parameter file


Reads motion regressors from filename (from the columns specified in colspec, if given)

rapidtide.io.calcmotregressors(motiondict[, ...])

Calculates various motion related timecourses from motion data dict, and returns an array

rapidtide.io.sliceinfo(slicetimes, tr)



Read key value pairs out of a BIDS sidecar file

rapidtide.io.writedicttojson(thedict, ...)

Write key value pairs to a json file


Read key value pairs out of a json file


Read time series out of an fmriprep confounds tsv file


rapidtide.io.writebidstsv(outputfileroot, ...)

NB: to be strictly valid, a continuous BIDS tsv file (i.e.

rapidtide.io.readvectorsfromtextfile(...[, ...])

Read one or more time series from some sort of text file

rapidtide.io.readbidstsv(inputfilename[, ...])

Read time series out of a BIDS tsv file


param inputfilename

rapidtide.io.parsefilespec(filespec[, debug])

rapidtide.io.colspectolist(colspec[, debug])

rapidtide.io.processnamespec(maskspec, ...)


param inputfilename

rapidtide.io.readvecs(inputfilename[, ...])

param inputfilename

rapidtide.io.readvec(inputfilename[, numskip])

Read an array of floats in from a text file.

rapidtide.io.readtc(inputfilename[, colnum, ...])


param inputfilename

rapidtide.io.writedict(thedict, outputfile)

Write all the key value pairs from a dictionary to a text file.


Read key value pairs out of a text file

rapidtide.io.writevec(thevec, outputfile[, ...])

Write a vector out to a text file.

rapidtide.io.writenpvecs(thevecs, outputfile)

Write out a two dimensional numpy array to a text file

rapidtide.miscmath: Miscellaneous math functions


Return phase of complex numbers.

rapidtide.miscmath.polarfft(invec, samplerate)

param invec


param x


param x


param y


param n


param n


param vector


param vector


param vector


param vector


param vector

rapidtide.miscmath.corrnormalize(thedata[, ...])

param thedata


param vector

rapidtide.miscmath.envdetect(Fs, inputdata)

param Fs

Sample frequency in Hz.

rapidtide.resample: Resampling functions

rapidtide.resample.congrid(xaxis, loc, val, ...)

Perform a convolution gridding operation with a Kaiser-Bessel or Gaussian kernel of width 'width'.

rapidtide.resample.doresample(orig_x, ...[, ...])

Resample data from one spacing to another.

rapidtide.resample.arbresample(inputdata, ...)

param inputdata

rapidtide.resample.dotwostepresample(orig_x, ...)

param orig_x

rapidtide.resample.calcsliceoffset(sotype, ...)

param sotype

rapidtide.resample.timeshift(inputtc, ...[, ...])

param inputtc

rapidtide.resample.FastResampler(timeaxis, ...)


rapidtide.stats: Statistical functions

rapidtide.stats.fitjsbpdf(thehist, histlen, ...)

param thehist

rapidtide.stats.getjohnsonppf(percentile, ...)

param percentile


param vallist

rapidtide.stats.rfromp(fitfile, thepercentiles)

param fitfile

rapidtide.stats.tfromr(r, nsamps[, ...])

param r

rapidtide.stats.zfromr(r, nsamps[, ...])

param r


param r

rapidtide.stats.gethistprops(indata, histlen)

param indata

rapidtide.stats.makehistogram(indata, histlen)

param indata

rapidtide.stats.makeandsavehistogram(indata, ...)

param indata

rapidtide.stats.symmetrize(a[, ...])

param a

rapidtide.stats.getfracval(datamat, thefrac)

param datamat

rapidtide.stats.makepmask(rvals, pval, ...)

param rvals

rapidtide.stats.getfracvals(datamat, thefracs)

param datamat


param histfit

rapidtide.stats.getfracvalsfromfit(histfit, ...)

param histfit

rapidtide.stats.makemask(image[, threshpct, ...])

param image

The image data to generate the mask for.

rapidtide.util: Utility functions


Log memory usage with a logging object.


param command


param command

rapidtide.util.savecommandline(theargs, thename)

param theargs

rapidtide.util.valtoindex(thearray, thevalue)

param thearray

An ordered list of values (does not need to be equally spaced)

rapidtide.util.progressbar(thisval, end_val)

param thisval

rapidtide.util.makelaglist(lagstart, lagend, ...)

param lagstart



param thenumber

rapidtide.util.proctiminginfo(thetimings[, ...])

param thetimings