slist = os.listdir('/mnt/data001/MBAProcessingResults/PMD') for sr in slist: if sr.startswith('PMD17'): brain = Brain(name=sr) brain.save() numSections = (len(os.listdir('/mnt/data001/MBAProcessingResults/PMD/'+sr))-1)/2 #sampleSectionNum = random.randrange(1,numSections) errorf.write(' sample section num ' + str(sampleSectionNum) + '\n') series_n = Series(desc=brain.name + ' Nissl Series', brain_id=brain.id, isRestricted=False, sectionThickness = 20, sectionThicknessUnit = 'mu' ,lab_id=lab_m.id, labelMethod_id = lm_n.id, imageMethod_id = im_b.id, sectioningPlane_id=sp_s.id, numQCSections = numSections) series_n.save() series_f = Series(desc=brain.name + ' Flourescent Series', brain_id=brain.id, isRestricted=False, sectionThickness = 20, sectionThicknessUnit = 'mu', lab_id=lab_m.id, labelMethod_id = lm_f.id, imageMethod_id = im_f.id, sectioningPlane_id=sp_s.id, numQCSections = numSections) series_f.save() series_ihc = Series(desc=brain.name + ' IHC Series', brain_id=brain.id, isRestricted=False, sectionThickness = 20, sectionThicknessUnit = 'mu' ,lab_id=lab_m.id, labelMethod_id = lm_ihc.id, imageMethod_id = im_b.id, sectioningPlane_id=sp_s.id, numQCSections = numSections) series_ihc.save() for l in limslist: if l.name == sr: tn = l.tracer tracer = Tracer(name=tn) try: # errorf.write('Match found : ' + sr + ' - ' + tn + '\n')
slist = os.listdir('/mnt/data001/MBAProcessingResults/PMD') for sr in slist: if sr.startswith('PMD'): brain = Brain(name=sr) brain.save() numSections = (len(os.listdir('/mnt/data001/MBAProcessingResults/PMD/'+sr))-1)/2 sampleSectionNum = random.randrange(1,numSections) errorf.write(' sample section num ' + str(sampleSectionNum) + '\n') series_n = Series(desc=brain.name + ' Nissl Series', brain_id=brain.id, isRestricted=False, sectionThickness = 20, sectionThicknessUnit = 'mu' ,lab_id=lab_m.id, labelMethod_id = lm_n.id, imageMethod_id = im_b.id, sectioningPlane_id=sp_s.id, numQCSections = numSections) series_n.save() series_f = Series(desc=brain.name + ' Flourescent Series', brain_id=brain.id, isRestricted=False, sectionThickness = 20, sectionThicknessUnit = 'mu', lab_id=lab_m.id, labelMethod_id = lm_f.id, imageMethod_id = im_f.id, sectioningPlane_id=sp_s.id, numQCSections = numSections) series_f.save() series_ihc = Series(desc=brain.name + ' IHC Series', brain_id=brain.id, isRestricted=False, sectionThickness = 20, sectionThicknessUnit = 'mu' ,lab_id=lab_m.id, labelMethod_id = lm_ihc.id, imageMethod_id = im_b.id, sectioningPlane_id=sp_s.id, numQCSections = numSections) series_ihc.save() for l in limslist: if l.name == sr: tn = l.tracer tracer = Tracer(name=tn) try: # errorf.write('Match found : ' + sr + ' - ' + tn + '\n')
labelBOOLDict = {} with open('/brainimg/' + brainName + '/ImageLookup.txt') as f: for line in f: m = re.match(r"(Section.*)\:\s+(-?\d+.\d+)\s+(N|IHC|F)", line) section2yDict[m.group(1)] = m.group(2) section2labelDict[m.group(1)] = m.group(3) labelBOOLDict[m.group(3)] = 1 idSeries = -1 label2fullDict = {'N':'Nissl', 'IHC':'IHC', 'F':'Fluorescent'} label2fieldDict = {'N':'Brightfield', 'IHC':'Brightfield', 'F':'Fluorescent'} for label in ('N', 'IHC', 'F'): if label in labelBOOLDict: series = Series(desc = brain.name + ' ' + label2fullDict[label], brain_id = brain.id, sectionThickness = 20, lab_id = Laboratory.objects.get(name='Mitra').id, labelMethod_id = LabelMethod.objects.get(name=label2fullDict[label]).id, imageMethod_id = ImageMethod.objects.get(name=label2fieldDict[label]).id, sectioningPlane_id = SectioningPlane.objects.get(desc='Coronal').id) series.save() if label == 'IHC' or label == 'F': idSeries = series.id mouse = series2limsDict[brainName] tn = mouse.tracer try: tracer = Tracer(name=tn) tracer.save() except: pass try: