Example #1
0
def calculate_cell_locations(
        db,
        filename=''):  # to be filled after complete collecting histology data
    pass


if __name__ == "__main__":
    # Cluster your data
    CLUSTER_DATA = 0  # We don't generally run this code. We kept this for documentation
    # d1mice = studyparams.ASTR_D1_CHR2_MICE
    d1mice = studyparams.SINGLE_MOUSE
    if CLUSTER_DATA:  # SPIKE SORTING
        inforecFile = os.path.join(settings.INFOREC_PATH,
                                   '{}_inforec.py'.format(d1mice))
        clusteringObj = spikesorting.ClusterInforec(inforecFile)
        clusteringObj.process_all_experiments()
        pass

    # Generate_cell_database_filters cells with the followings: isi < 0.05, spike quality > 2
    basicDB = celldatabase.generate_cell_database_from_subjects(d1mice)

    d1DBFilename = os.path.join(settings.FIGURES_DATA_PATH,
                                '{}_d1mice.h5'.format(studyparams.STUDY_NAME))
    # Create and save a database, computing first the base stats and then the indices
    firstDB = calculate_base_stats(basicDB, filename=d1DBFilename)
    # bestCells = calculate_indices(firstDB, filename = d1DBFilename)

    if SAVE:
        dbpath = os.path.join(settings.FIGURES_DATA_PATH,
                              studyparams.STUDY_NAME,
STUDY_NAME = '2018thstr'
SAVE = 1
RECALCULATE_TETRODESTATS=0
FIND_TETRODES_WITH_NO_SPIKES=0

#We need access to ALL of the neurons from all animals that have been recorded from.
animals = ['pinp0'+s for s in map(str, [15, 16, 17, 18, 19, 20, 21, 25, 26, 29])] #22 not done yet
inforecFolder = '/home/nick/src/jaratest/common/inforecordings'

dbList = []
for animal in animals:
    inforecFn = os.path.join(inforecFolder, '{}_inforec.py'.format(animal))

    #If we need to regenerate the tetrodeStats files
    if RECALCULATE_TETRODESTATS:
        ci = spikesorting.ClusterInforec(inforecFn)
        ci.process_all_experiments(recluster=False)

    if FIND_TETRODES_WITH_NO_SPIKES:
        ci = spikesorting.ClusterInforec(inforecFn)
        ci.find_tetrodes_with_no_spikes()
        continue

    db = celldatabase.generate_cell_database(inforecFn)

    #Calculate noiseburst response
    #TODO: Instead of using alternative session types if 'noiseburst' is not available, should we
    #just calculate the onset response to each sound stimulus type and see if any of them are significant?
    noiseZscore = np.empty(len(db))
    noisePval = np.empty(len(db))
    baseRange = [-0.1,0]
def cluster_spike_data(subjects):
    for subject in subjects:
        inforec = '/home/jarauser/src/jaratest/common/inforecordings/{0}_inforec.py'.format(
            subject)
        ci = spikesorting.ClusterInforec(inforec)
        ci.process_all_experiments()
import os
import pandas as pd
import subprocess
from jaratest.nick.database import dataloader_v2 as dataloader
import numpy as np
from scipy import stats
import imp

animal = 'adap041'
inforecFullPath = os.path.join(settings.INFOREC_PATH,
                               '{}_inforec.py'.format(animal))
CASE = 3

if CASE == 1:
    # -- Cluster inforec and store stats, if have not already done so -- #
    ci = spikesorting.ClusterInforec(inforecFullPath)
    ci.cluster_all_experiments(maxClusters=6,
                               maxPossibleClusters=6,
                               recluster=False)
    ##############################################################

if CASE == 2:
    databaseFullPath = os.path.join(settings.DATABASE_PATH,
                                    '{}_database.h5'.format(animal))
    key = 'head_fixed'

    baseRange = [-0.1, 0]  #Range of baseline period, in sec
    respRange = [0, 0.1]  #Range of sound response period, in sec
    timeRange = [-0.5, 1]
    movementTimeRange = [0.05, 0.15]
    soundTriggerChannel = 0