neurochat.nc_circular module¶
This module implements CircStat Class for NeuroChaT software.
@author: Md Nurul Islam; islammn at tcd dot ie
-
class
neurochat.nc_circular.CircStat(**kwargs)[source]¶ Bases:
objectThis class is the placeholder for circular data.
It provides functionalities for calculating circular statistics. For example, Rayleigh Z statistics of the circular data.
Currently the class only supports calculations in degrees. As such, radians should be converted to degrees when entering theta.
The initialisation function should be passed with keyword arguments.
Keyword Arguments: - rho (ndarry) – Polar co-ordinate rho, the radii of points.
- theta (ndarray) – Polar co-ordinate theta, the angle of points.
-
_rho¶ Polar co-ordinate rho, the radii of points.
Type: ndarray
-
_theta¶ Polar co-ordinate theta, the angle of points.
Type: ndarray
-
_result¶ Holds the result of many circular statistics functions.
Type: OrderedDict
-
calc_stat()[source]¶ Calculate and return all the circular statistics parameters.
Parameters: None – Returns: dict – Returns the mean, standard deviation, resultant vector length. The Rayleigh Z statistics. The von Mises concentration parameter Kappa.
-
circ_histogram(bins=5)[source]¶ Calculate the circular histogram of the angular coordinates.
Parameters: bins (int or ndarray) – Angular binsize for the circular histogram if int. Angular bins if ndarray. Returns: - count (ndarray) – Histogram bin count
- ind (ndarray) – Indices of the bins to which each value in input array belongs. Similar to the return values of the numpy.digitize function.
- bins (ndarray) – Histogram bins
-
static
circ_regroup(x)[source]¶ Circular regrouping of the angles. It unwraps the angular coordinates.
For example, if the input array x is x = np.ndarray([270, 340, 350, 20, 40]), the output will be y = np.ndarray([270, 340, 350, 380, 400])
Parameters: x (ndarray) – Array containing the angular coordinates Returns: y (ndarray) – Regrouped or unwrapped angular coordinates
-
circ_scatter(bins=2, step=0.05, rmax=None)[source]¶ Prepare data for circular scatter plot.
For each theta in a bin, the radius is increased by ‘step’ The size of step is capped at ‘rmax’.
Parameters: - bins (int) – Angular binsize for the circular scatter
- step (float) – Stepsize to increase the radius for each count of theta
- rmax (float) – Maximum value for the radius
Returns: - radius (ndarray) – Radius for the theta values. For each new theta in a bin, the radius is increased by ‘step’.
- theta (ndarray) – Binned theta samples
-
circ_smooth(filttype='b', filtsize=5)[source]¶ Calculate the circular average of theta.
Each sample is replaced by the circular mean of length ‘filtsize’ and weights determined by the type of filter.
Parameters: - filttype (str) – Type of smoothing filter. ‘b’ for Box filter, or ‘g’ for Gaussian filter.
- filtsize (int) – Length of the averaging filter
Returns: smooth_theta (ndarray) – Theta values after the smoothing
-
get_mean_std()[source]¶ Return the circular mean and standard deviation of the data.
Also return the resultant vector length of the data.
Parameters: None – Returns: dict – Dictionary of mean, standard deviation and resultant vector length.
-
get_rayl_stat()[source]¶ Return the Rayleigh Z statistics of the circular data.
Parameters: None – Returns: dict – Rayleigh Z statistics
-
get_result()[source]¶ Return the results of the circular statistics analyses.
Parameters: None – Returns: dict – Results of the circular statistics analyses
-
get_rho()[source]¶ Return the radial coordinates (rho) of the circular data.
Parameters: None – Returns: ndarray – Radial coordinates of the circular data
-
get_theta()[source]¶ Return the angular coordinates (theta) of the circular data.
Parameters: None – Returns: ndarray – Angular coordinates of the circular data
-
get_vonmises_stat()[source]¶ Return the von Mises concentration parameter kappa.
Parameters: None – Returns: dict – Returns the von Mises concentration parameter kappa