Exemplo n.º 1
0
def builder(SKID=None):
    if SKID is None:
        # sets list of all skeleton IDs
        mySkels = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int()

        for i in mySkels:
            mySkels.append(int(i))

        myNeurons = []

        for i in mySkels:
            x = neuronSet(i)
            myNeurons.append(x)

    else:
        SKID = int(SKID)
        myNeurons = []
        x = neuronSet(SKID)
        myNeurons.append(x)

    myAnnotations = GetListOfSkIDAndAnnotations.getMyAnnotations()

    myNames = GetAnnotationsRemoveExtraneousInfo.getLookUpTableSkID_Name()

    return myNeurons
Exemplo n.º 2
0
def buildSingleCell(SKID):

    aCell = GFinputNeuron(SKID)

    #sets annotations based on SKID
    aCell.annotations = GetAnnotationsRemoveExtraneousInfo.setAnnotationLookUpTable(
        SKID)

    aCell.neuronName = GetAnnotationsRemoveExtraneousInfo.getName(SKID)

    aCell.GF1synapseCount = 0

    return aCell
Exemplo n.º 3
0
def buildSingleCellLC6partners(SKID):
    aCell = GFinputNeuron(SKID)

    # sets annotations based on SKID
    aCell.annotations = GetAnnotationsRemoveExtraneousInfo.setAnnotationLookUpTable(
        SKID)

    aCell.neuronName = GetAnnotationsRemoveExtraneousInfo.getName(SKID)

    aCell.GF1synapseCount = 0

    for i in aCell.annotations:
        if 'cluster' in i:
            aCell.classification = i
    return aCell
Exemplo n.º 4
0
def buildFromSkidList(myList):
    #sets list of all skeleton IDs
    mySkels = myList

    #creates dictionary with keys as str(skel IDs) and values as number of synapses with GF1
    myGF1Connectivity = GetGF1Connectivity.removeExtra()

    #creates dictionary with key-value pairs of str(skelID) and list of str(annotations)
    myAnnotations = GetListOfSkIDAndAnnotations.getMyAnnotations()

    #creates a dictionary with key-value pairs of int(skelID) and and str(neuron name)
    myNames = GetAnnotationsRemoveExtraneousInfo.getLookUpTableSkID_Name()

    #creates empty list to be filled with all instances
    myNeurons = []

    #creates list of of all instances while setting each instance's name and skeletonID to be an element from mySkls
    for i in mySkels:
        x = GFinputNeuron(i)
        myNeurons.append(x)

    # converts skeletonID attribute to string for use as dictionary key then adds all available synapses from dictionary of synapses and all       available annotations from dictionary of annotations
    for elem in myNeurons:
        y = elem.skeletonID
        z = str(y)
        if z in myGF1Connectivity:
            elem.GF1synapseCount = myGF1Connectivity[z]
        if z in myAnnotations:
            elem.annotations = myAnnotations[z]
            p = elem.annotations
        if y in myNames:
            elem.neuronName = myNames[y]

    return myNeurons
Exemplo n.º 5
0
 def getAnnotations(self):
     myAnnotations = GARI.getMyAnnotations()
     y = self.skeletonID
     z = str(y)
     if z in myAnnotations:
         self.annotations = myAnnotations[z]
     return self.annotations
Exemplo n.º 6
0
 def getNeuronName(self):
     y = self.skeletonID
     z = str(y)
     myNames = GetAnnotationsRemoveExtraneousInfo.getLookUpTableSkID_Name()
     if y in myNames:
         self.neuronName = myNames[y]
     return self.neuronName
Exemplo n.º 7
0
def appendNonDNIN2(mySet, annotation):
    testList = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int(annotation)
    curSKIDs = []
    for i in mySet:
        curSKIDs.append(i.skeletonID)
    for item in testList:
        if item not in curSKIDs:
            myNeuron = LC6_neuronClass.buildSingleCellQuick(int(item))
            mySet += myNeuron
    return mySet
Exemplo n.º 8
0
def getLookUpTableSkID_Name(annotation=None):
    relevantDict = GARI.getAllSkeletonInfo(annotation)
    SkIDLookUpNeuronName = {}
    #returns dictionary containing SkID : neuron name pairs
    for d in relevantDict:

        if d["type"] == 'neuron':
            SkIDLookUpNeuronName[((d['skeleton_ids'])[0])] = d['name']

    return SkIDLookUpNeuronName
Exemplo n.º 9
0
def buildSingleCell(SKID):
    aCell = GFinputNeuron(SKID)

    # sets annotations based on SKID
    aCell.annotations = GLT.setAnnotationLookUpTable(SKID)

    aCell.neuronName = GARI.getName(SKID)

    aCell.GF1synapseCount = 0

    return aCell
def layer0(mySet):
    myClassTypes = GA.queryByMetaAnnotation('classType')
    classTypeGroups = {}
    for annotation in myClassTypes:
        globals()['{}'.format(annotation)] = []
        classTypeGroups[annotation] = []
    classTypeGroups['Unclassified'] = []
    for neuron in mySet:
        thisNeuron = False
        for annotation in neuron.annotations:
            if annotation in myClassTypes:  #and annotation != "Visual_Interneuron" and annotation != "secondary_auditory_interneurons":  #(annotation == "Descending Neuron" or annotation == "Ascending Neuron" or annotation == "Visual"):
                globals()['{}'.format(annotation)].append(neuron.skeletonID)
                classTypeGroups[annotation].append(neuron)
                thisNeuron = True

        if thisNeuron is False:
            classTypeGroups['Unclassified'].append(neuron)

    return classTypeGroups
def layer1(mySet=None, classTypeGroups=None):

    myCommissures = GA.queryByMetaAnnotation('commissure')
    myCommissures.append('unilateral')
    print(myCommissures)
    finalCommissures = {}
    comClass = {}
    for annotation in myCommissures:
        globals()['{}'.format(annotation)] = []
        finalCommissures[annotation] = []
    if mySet is not None:
        for neuron in mySet:
            for annotation in neuron.annotations:
                if annotation in myCommissures:
                    globals()['{}'.format(annotation)].append(
                        neuron.skeletonID)
                    finalCommissures[annotation].append(neuron.skeletonID)
    if classTypeGroups is not None:
        for aClass in classTypeGroups:
            comClass[aClass] = {}
            for neuron in classTypeGroups[aClass]:
                if neuron.commissure not in comClass[aClass]:
                    comClass[aClass][neuron.commissure] = [neuron]
                else:
                    comClass[aClass][neuron.commissure].append(neuron)

                #for annotation in neuron.annotations:

                #if annotation in myCommissures:
                #   if annotation not in comClass[aClass]:
                #      comClass[aClass][annotation] = [neuron]
                # else:
                #    comClass[aClass][annotation].append(neuron)
    if bool(comClass) is False:
        return finalCommissures
    else:
        return comClass
def layer2(args):
    myRinds = GA.queryByMetaAnnotation('cellBodyRind')
    if type(args) is CS.GFIN_set:
        mySet = args
        finalRinds = {}
        for annotation in myRinds:
            globals()['{}'.format(annotation)] = []
            finalRinds[annotation] = []
        for neuron in mySet:
            for annotation in neuron.annotations:
                if annotation in myRinds:
                    globals()['{}'.format(annotation)].append(
                        neuron.skeletonID)
                    finalRinds[annotation].append(neuron.skeletonID)
    else:
        CBR = {}
        comsAndClasses = args
        classList = list(comsAndClasses.keys())
        for aClass in classList:
            CBR[aClass] = {}
            for aCom in comsAndClasses[aClass]:
                CBR[aClass][aCom] = {}
                for neuron in comsAndClasses[aClass][aCom]:
                    for annotation in neuron.annotations:
                        if annotation in myRinds:
                            if annotation not in CBR[aClass][aCom]:
                                CBR[aClass][aCom][annotation] = [neuron]
                            else:
                                CBR[aClass][aCom][annotation].append(neuron)
                    if neuron.cellBodyRind is None:
                        if 'CBnotInBrain' not in CBR[aClass][aCom]:
                            CBR[aClass][aCom]['CBnotInBrain'] = [neuron]
                        else:
                            CBR[aClass][aCom]['CBnotInBrain'].append(neuron)

    return CBR
Exemplo n.º 13
0
    def getNumPartnersBySkid(self):
        myLC4List = []
        myLPLC2List = []
        myLPC1List = []
        myLPLC1List = []

        for neuron in self:
            if 'putative LC4 neuron' in neuron.annotations:
                myLC4List.append(str(neuron.skeletonID))
            if 'LPLC2' in neuron.annotations:
                myLPLC2List.append(str(neuron.skeletonID))
            if 'Postsynaptic to LPLC1' in neuron.annotations:
                myLPLC1List.append(str(neuron.skeletonID))
            if 'postsynaptic to LPC1' in neuron.annotations:
                myLPC1List.append(str(neuron.skeletonID))

        for i in self:
            a = None
            b = None
            c = None
            d = None
            if 'postsynaptic to LC6' in i.annotations:
                countOfLC6SynapsesOntoMyNeuron = 0
                d = {}
                a = GC.getSkeletonPartners(int(i.skeletonID))
                b = a[
                    'incoming']  # dict of key = SKID that is presynaptic : value = myNeuronSkid:[0,0,0,0,#synapses]
                c = list(b.keys(
                ))  # list of skeletonIDs that are presynaptic to neuron
                listOfLC6 = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int(
                    annotation=3489456)
                strListOfLC6 = []
                for x in listOfLC6:
                    strListOfLC6.append(str(x))

                for item in c:
                    if item in strListOfLC6:
                        d[item] = b[item]['skids'][str(i.skeletonID)][4]
                        countOfLC6SynapsesOntoMyNeuron += d[item]
                i.postsynapticToLC6 = countOfLC6SynapsesOntoMyNeuron

            if 'Postsynaptic to LC4' in i.annotations:
                countOfLC4SynapsesOntoMyNeuron = 0
                if a is None:
                    a = GC.getSkeletonPartners(int(i.skeletonID))
                    b = a[
                        'incoming']  # dict of key = SKID that is presynaptic : value = myNeuronSkid:[0,0,0,0,#synapses]
                    c = list(b.keys(
                    ))  # list of skeletonIDs that are presynaptic to neuron
                d = {}
                for item in c:
                    if item in myLC4List:
                        d[item] = b[item]['skids'][str(i.skeletonID)][4]
                        countOfLC4SynapsesOntoMyNeuron += d[item]
                i.postsynapticToLC4 = countOfLC4SynapsesOntoMyNeuron
            if 'Postsynaptic to LPLC2' in i.annotations:
                countOfLPLC2SynapsesOntoMyNeuron = 0
                if a is None:
                    a = GC.getSkeletonPartners(int(i.skeletonID))
                    b = a[
                        'incoming']  # dict of key = SKID that is presynaptic : value = myNeuronSkid:[0,0,0,0,#synapses]
                    c = list(b.keys(
                    ))  # list of skeletonIDs that are presynaptic to neuron
                d = {}
                for item in c:
                    if item in myLPLC2List:
                        d[item] = b[item]['skids'][str(i.skeletonID)][4]
                        countOfLPLC2SynapsesOntoMyNeuron += d[item]
                i.postsynapticToLPLC2 = countOfLPLC2SynapsesOntoMyNeuron

            # putative LPLC1 = 6022624
            if 'Postsynaptic to LPLC1' in i.annotations:
                countOfLPLC1SynapsesOntoMyNeuron = 0
                if a is None:
                    a = GC.getSkeletonPartners(int(i.skeletonID))
                    b = a[
                        'incoming']  # dict of key = SKID that is presynaptic : value = myNeuronSkid:[0,0,0,0,#synapses]
                    c = list(b.keys(
                    ))  # list of skeletonIDs that are presynaptic to neuron
                d = {}
                listOfLPLC1 = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int(
                    annotation=6022624)
                strListOfLPLC1 = []
                for x in listOfLPLC1:
                    strListOfLPLC1.append(str(x))
                for item in c:
                    if item in strListOfLPLC1:
                        d[item] = b[item]['skids'][str(i.skeletonID)][4]
                        countOfLPLC1SynapsesOntoMyNeuron += d[item]
                i.postsynapticToLPLC1 = countOfLPLC1SynapsesOntoMyNeuron
                '''for item in c:
                    if item in myLPLC1List:
                        d[item] = b[item]['skids'][str(i.skeletonID)][4]
                        countOfLPLC1SynapsesOntoMyNeuron += d[item]
                i.postsynapticToLPLC1 = countOfLPLC1SynapsesOntoMyNeuron'''

            # putative LPC1 = 2894936
            if 'postsynaptic to LPC1' in i.annotations:
                countOfLPC1SynapsesOntoMyNeuron = 0
                if a is None:
                    a = GC.getSkeletonPartners(int(i.skeletonID))
                    b = a[
                        'incoming']  # dict of key = SKID that is presynaptic : value = myNeuronSkid:[0,0,0,0,#synapses]
                    c = list(b.keys(
                    ))  # list of skeletonIDs that are presynaptic to neuron

                listOfLPC1 = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int(
                    annotation=2894936)
                strListOfLPC1 = []
                for x in listOfLPC1:
                    strListOfLPC1.append(str(x))
                d = {}
                for item in c:
                    if item in strListOfLPC1:
                        d[item] = b[item]['skids'][str(i.skeletonID)][4]
                        countOfLPC1SynapsesOntoMyNeuron += d[item]
                i.postsynapticToLPC1 = countOfLPC1SynapsesOntoMyNeuron
            ''' #for item in c:
                  #  if item in myLPC1List:
                 #       d[item] = b[item]['skids'][str(i.skeletonID)][4]
                #        countOfLPC1SynapsesOntoMyNeuron += d[item]
               # i.postsynapticToLPC1 = countOfLPC1SynapsesOntoMyNeuron'''

        self.varCheck.append('partners')
        return self
def getMyAnnotations():
    myNeuronswithAnnotations = GetAnnotationsRemoveExtraneousInfo.convertID2String()

    return myNeuronswithAnnotations
import CustomNeuronClassSet as CS
import jsonNeurons as JN
import exportToCSV as E2C
import GetAnnotationsRemoveExtraneousInfo as GA

#commissure = 9809716

mySet = CS.builder()

myClassTypes = GA.queryByMetaAnnotation('classType')
for annotation in myClassTypes:
    globals()['{}'.format(annotation)] = []

myCommissures = GA.queryByMetaAnnotation('commissure')
finalCommissures = {}
for annotation in myCommissures:
    globals()['{}'.format(annotation)] = []
    finalCommissures[annotation] = []


#layer0 set the class types(e.g. visual, secondary_auditory, etc...)
def layer0(mySet):
    myClassTypes = GA.queryByMetaAnnotation('classType')
    classTypeGroups = {}
    for annotation in myClassTypes:
        globals()['{}'.format(annotation)] = []
        classTypeGroups[annotation] = []
    classTypeGroups['Unclassified'] = []
    for neuron in mySet:
        thisNeuron = False
        for annotation in neuron.annotations:
Exemplo n.º 16
0
def builder(SKID=None):
    if SKID is None:
        # sets list of all skeleton IDs
        mySkels = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int()

        # creates dictionary with keys as str(skel IDs) and values as number of synapses with GF1
        myGF1Connectivity = GetGF1Connectivity.removeExtra()
        myGF2Connectivity = GetGF1Connectivity.removeExtra(
            skeleton_id='291870')

        # creates empty list to be filled with all instances
        myNeurons = []

        # creates list of of all instances while setting each instance's name and skeletonID to be an element from
        # mySkls
        for i in mySkels:
            x = GFinputNeuron(i)
            myNeurons.append(x)
    else:
        SKID = int(SKID)
        myNeurons = []
        x = GFinputNeuron(SKID)
        myNeurons.append(x)
        myGF1Connectivity = []
        myGF2Connectivity = []

        # creates dictionary with key-value pairs of str(skelID) and list of str(annotations)
    myAnnotations = GetListOfSkIDAndAnnotations.getMyAnnotations()

    # creates a dictionary with key-value pairs of int(skelID) and and str(neuron name)
    myNames = GetAnnotationsRemoveExtraneousInfo.getLookUpTableSkID_Name()

    myCommissures = GetAnnotationsRemoveExtraneousInfo.queryByMetaAnnotation(
        'commissure')

    myClassTypes = GetAnnotationsRemoveExtraneousInfo.queryByMetaAnnotation(
        'classType')
    # converts skeletonID attribute to string for use as dictionary key then adds all available synapses from
    # dictionary of synapses and all       available annotations from dictionary of annotations
    for elem in myNeurons:
        y = elem.skeletonID
        z = str(y)
        if z in myGF1Connectivity:
            elem.GF1synapseCount = myGF1Connectivity[z]
        else:
            elem.GF1synapseCount = 0
        if z in myGF2Connectivity:
            elem.GF2synapseCount = myGF2Connectivity[z]
        else:
            elem.GF2synapseCount = 0
        if z in myAnnotations:
            elem.annotations = myAnnotations[z]
            p = elem.annotations
            for abc in p:
                if (
                        'Unclassified' in abc or 'LC4' in abc or 'LPLC2' in abc or 'JONeuron' in abc or 'GCI' in abc
                        or 'putative DN' in abc) and 'synaptic' not in abc and 'andGFN' not in \
                        abc and 'HK' not in abc and 'Exploration' not in abc and 'type 37' not in abc and 'type 38' \
                        not in abc and 'type 44' not in abc and 'type 48' not in abc and 'miscellaneous' not in abc \
                        and "Ascending" not in abc and "Descending" not in abc and "shared" not in abc:
                    elem.classification = abc
                if 'RIGHT' in abc or 'LEFT' in abc or 'midLine' in abc:
                    if elem.hemisphere is None:
                        elem.hemisphere = abc
                        elem.somaSide = abc
                if "JON" in abc and "synaptic" not in abc:
                    elem.classification = abc
                if elem.commissure is None:
                    if abc in myCommissures:
                        elem.commissure = abc
                if elem.classType is None:
                    if abc in myClassTypes:
                        elem.classType = abc
                if elem.cellBodyRind is None:
                    if 'CBR' in abc and len(abc) == 4:
                        elem.cellBodyRind = abc
        if "JONeuron" in elem.annotations:
            elem.identification = 'JONeuron'
        if elem.hemisphere is None:
            elem.hemisphere = "RIGHT HEMISPHERE"
            elem.somaSide = "RIGHT HEMISPHERE"
        if elem.commissure is None and 'Bilateral' not in elem.annotations:
            elem.commissure = 'unilateral'
        if y in myNames:
            elem.neuronName = myNames[y]
    return myNeurons
Exemplo n.º 17
0
def builder(SKID=None):
    if SKID is None:
        #sets list of all skeleton IDs
        mySkels = GetAnnotationsRemoveExtraneousInfo.getListOfSkID_int()

        #creates dictionary with keys as str(skel IDs) and values as number of synapses with DNright
        myDNrightConnectivity = GetDNrightConnectivity.removeExtra()

        #creates empty list to be filled with all instances
        myNeurons = []

        #creates list of of all instances while setting each instance's name and skeletonID to be an element from mySkls
        for i in mySkels:
            x = DNinputNeuron(i)
            myNeurons.append(x)
    else:
        SKID = int(SKID)
        myNeurons = []
        x = DNinputNeuron(SKID)
        myNeurons.append(x)
        myDNrightConnectivity = []

    #creates dictionary with key-value pairs of str(skelID) and list of str(annotations)
    myAnnotations = GetListOfSkIDAndAnnotations.getMyAnnotations()

    #creates a dictionary with key-value pairs of int(skelID) and and str(neuron name)
    myNames = GetAnnotationsRemoveExtraneousInfo.getLookUpTableSkID_Name()

    # converts skeletonID attribute to string for use as dictionary key then adds all available synapses from dictionary of synapses and all       available annotations from dictionary of annotations
    for elem in myNeurons:
        y = elem.skeletonID
        z = str(y)
        if z in myDNrightConnectivity:
            elem.DNrightsynapseCount = myDNrightConnectivity[z]
        else:
            elem.DNrightsynapseCount = 0
        if z in myAnnotations:
            elem.annotations = myAnnotations[z]
            p = elem.annotations
            for abc in p:
                if ('Unclassified' in abc or 'LC4' in abc or 'LPLC2' in abc
                        or 'JO' in abc or 'B1' in abc or 'GCI' in abc
                        or 'Halted' in abc or 'Neuron Fragment' in abc
                        or 'Hampel' in abc or 'incomplete neuron' in abc
                        or 'DN' in abc) and 'synaptic' not in abc:
                    elem.classification = abc
                #if ('type 37' in abc or 'type 38' in abc or 'type 44' in abc or 'JO' in abc:
                #   elem.classification = 'JO'
                if elem.classification is None:
                    elem.classification = "Other"
                if "Descending" in abc or 'Ascending' in abc:
                    if 'Unclassified' in elem.classification and 'type' not in elem.classification:
                        elem.classification = "Unclassified {} DN input neuron".format(
                            abc)
                if 'RIGHT' in abc or 'LEFT' in abc:
                    if elem.hemisphere is None:
                        elem.hemisphere = abc
                if 'Bilateral' in abc:
                    elem.hemisphere = abc
        if elem.hemisphere is None:
            elem.hemisphere = "RIGHT HEMISPHERE"

        if y in myNames:
            elem.neuronName = myNames[y]

    return myNeurons