neuroprob/utils/neural.py
def spiketrain_CV(folds, spiketrain, track_samples, behaviour_list=None):
    """
    Creates subsets of the the neural data (behaviour plus spike trains) and splits it 
    into folds cross-validation sets with validation data and test data as one out of the 
    folds subsets, validation data being the rest. Each cross-validation set will take 
    a different folds subset for validation data.
    
    :param int folds: number of cross-validation segments to split into
    :param np.array spiketrain: spike train of shape (neuron, timestep)
    :param int track_samples: time steps of recording
    :param list behaviour_list: list of covariate time series
    :returns: cross-validation set as tuple
    :rtype: tuple
    """
    behav = np.array(behaviour_list) # dims, timesteps
    df = track_samples // folds
    cv_set = []
    valset_start = []
    
    blocks_t = []
    blocks_c = []
    
    for f in range(folds):
        valset_start.append(df*f)
        blocks_t.append(spiketrain[:, df*f:df*(f+1)])
        blocks_c.append(behav[:, df*f:df*(f+1)])

    for f in range(folds):
        fb = np.delete(np.arange(folds), f)
        
        ftrain = np.concatenate(tuple(blocks_t[f_] for f_ in fb), axis=1)
        vtrain = blocks_t[f]
        
        if behaviour_list is not None:
            fcov_t = list(np.concatenate(tuple(blocks_c[f_] for f_ in fb), axis=1))
            vcov_t = list(blocks_c[f])
        else:
            fcov_t = None
            vcov_t = None
                    
        cv_set.append((ftrain, fcov_t, vtrain, vcov_t))

    return cv_set, valset_start

    Creates subsets of the the neural data (behaviour plus spike trains) and splits it 
    into folds cross-validation sets with validation data and test data as one out of the 
    folds subsets, validation data being the rest. Each cross-validation set will take 
    a different folds subset for validation data.
    
    :param int folds: number of cross-validation segments to split into
    :param np.array spiketrain: spike train of shape (neuron, timestep)
    :param int track_samples: time steps of recording
    :param list behaviour_list: list of covariate time series
    :returns: cross-validation set as tuple
    :rtype: tuple
    
Creates subsets of the the neural data (behaviour plus spike trains) and splits it
into folds cross-validation sets with validation data and test data as one out of the
folds subsets, validation data being the rest. Each cross-validation set will take
a different folds subset for validation data.
Creates subsets of the the neural data ( behaviour plus spike trains ) and splits it into folds cross - validation sets with validation data and test data as one out of the folds subsets validation data being the rest . Each cross - validation set will take a different folds subset for validation data .
def spiketrain_CV(folds, spiketrain, track_samples, behaviour_list=None):
    behav = np.array(behaviour_list) 
    df = track_samples // folds
    cv_set = []
    valset_start = []
    blocks_t = []
    blocks_c = []
    for f in range(folds):
        valset_start.append(df*f)
        blocks_t.append(spiketrain[:, df*f:df*(f+1)])
        blocks_c.append(behav[:, df*f:df*(f+1)])
    for f in range(folds):
        fb = np.delete(np.arange(folds), f)
        ftrain = np.concatenate(tuple(blocks_t[f_] for f_ in fb), axis=1)
        vtrain = blocks_t[f]
        if behaviour_list is not None:
            fcov_t = list(np.concatenate(tuple(blocks_c[f_] for f_ in fb), axis=1))
            vcov_t = list(blocks_c[f])
        else:
            fcov_t = None
            vcov_t = None
        cv_set.append((ftrain, fcov_t, vtrain, vcov_t))
    return cv_set, valset_start
def spiketrain_CV ( folds , spiketrain , track_samples , behaviour_list = None ) : behav = np . array ( behaviour_list ) df = track_samples // folds cv_set = [ ] valset_start = [ ] blocks_t = [ ] blocks_c = [ ] for f in range ( folds ) : valset_start . append ( df * f ) blocks_t . append ( spiketrain [ : , df * f : df * ( f + 1 ) ] ) blocks_c . append ( behav [ : , df * f : df * ( f + 1 ) ] ) for f in range ( folds ) : fb = np . delete ( np . arange ( folds ) , f ) ftrain = np . concatenate ( tuple ( blocks_t [ f_ ] for f_ in fb ) , axis = 1 ) vtrain = blocks_t [ f ] if behaviour_list is not None : fcov_t = list ( np . concatenate ( tuple ( blocks_c [ f_ ] for f_ in fb ) , axis = 1 ) ) vcov_t = list ( blocks_c [ f ] ) else : fcov_t = None vcov_t = None cv_set . append ( ( ftrain , fcov_t , vtrain , vcov_t ) ) return cv_set , valset_start
Creates subsets of the the neural data (behaviour plus spike trains) and splits it
into folds cross-validation sets with validation data and test data as one out of the
folds subsets, validation data being the rest.
Creates subsets of the the neural data ( behaviour plus spike trains ) and splits it into folds cross - validation sets with validation data and test data as one out of the folds subsets validation data being the rest .
"""
    Creates subsets of the the neural data (behaviour plus spike trains) and splits it 
    into folds cross-validation sets with validation data and test data as one out of the 
    folds subsets, validation data being the rest. Each cross-validation set will take 
    a different folds subset for validation data.
    
    :param int folds: number of cross-validation segments to split into
    :param np.array spiketrain: spike train of shape (neuron, timestep)
    :param int track_samples: time steps of recording
    :param list behaviour_list: list of covariate time series
    :returns: cross-validation set as tuple
    :rtype: tuple
    """ # dims, timesteps
cross-validation set as tuple
cross - validation set as tuple
tuple
folds
number of cross-validation segments to split into
number of cross - validation segments to split into
spiketrain
spike train of shape (neuron, timestep)
spike train of shape ( neuron timestep )
track_samples
time steps of recording
time steps of recording
behaviour_list
list of covariate time series
list of covariate time series