コード例 #1
0
ファイル: nrnDoAll.py プロジェクト: TimHacker/Bio-Brains
def nrnDoAll( nrnType, nrnNumber, nrnVersion="",nrnDate=""):
    versionSuffix = "" if not nrnVersion else " "+nrnVersion
    dateSuffix = "" if not nrnDate else " " + nrnDate 
    srcFileNRN = srcDir+"%s %s/%s %s nrn%s%s.txt"%(nrnType,nrnNumber,nrnType,nrnNumber, dateSuffix, versionSuffix)
    srcFileNS =  srcDir+"%s %s/%s %s ns%s%s.txt"%(nrnType,nrnNumber, nrnType,nrnNumber, dateSuffix,  versionSuffix)
    
    print "nrnType = " + nrnType
    print "nrnNumber = " + nrnNumber
    print "versionSuffix = " + versionSuffix
    print "dateSuffix = " + dateSuffix
    
    print "srcFileNRN:" + srcFileNRN
    print "srcFileNS:" + srcFileNS
    
    transFileNRN = outDir+"%s %s/%s %s nrn%s%s.transl.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    transFileNS = outDir+"%s %s/%s %s ns%s%s.transl.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    
    print "transFileNRN:" + transFileNRN
    print "transFileNS:" + transFileNS
    
    invTransFileNRN = outDir+"%s %s/%s %s nrn%s%s.transl.invX.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    invTransFileNS = outDir+"%s %s/%s %s ns%s%s.transl.invX.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)

    scaledInvTransFileNRN = outDir+"%s %s/%s %s nrn%s%s.transl.invX.scaled.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    scaledInvTransFileNS = outDir+"%s %s/%s %s ns%s%s.transl.invX.scaled.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)

    
    invTransFileConCat = outDir+"%s %s/%s %s nrn + ns%s%s.transl.invX.scaled.txt"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    
    invTransFileConCatSWC = outDir+"%s %s/%s %s nrn + ns%s%s.transl.invX.scaled.swc"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    
    matlabscriptname = outDir+"%s %s/mscript.m"%(nrnType,nrnNumber) #,nrnType,nrnNumber,versionSuffix)
    invTransFileConCatSWCStraight = outDir+"%s %s/%s %s nrn + ns%s%s.transl.invX.scaled.straightened.swc"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    
    #Old version without unique folder for each cellID
    #final = swcs_outDir+"%s %s nrn + ns%s%s.transl.invX.scaled.straightened.swc"%(nrnType,nrnNumber,dateSuffix,versionSuffix)
    final = swcs_outDir+"%s %s/%s %s nrn + ns%s%s.transl.invX.scaled.straightened.swc"%(nrnType,nrnNumber,nrnType,nrnNumber,dateSuffix,versionSuffix)
    
    print "final: " +  final
    
    print "Source Files"
    print "\t", srcFileNRN
    print "\t", srcFileNS 
    
    print "Producing"
    print "\t",transFileNRN
    print "\t",transFileNS
    
    print "\t",invTransFileNRN
    print "\t",invTransFileNS
    
    print "\t",scaledInvTransFileNRN
    print "\t",scaledInvTransFileNS
    
    print "\t",invTransFileConCat
    print "\t",invTransFileConCatSWC
    print "\t",invTransFileConCatSWCStraight
    
    
    print "Executing:"
    
    
    nrnTranslate(  
        nsFilenameSrc=srcFileNS, 
        nrnFilenameSrc=srcFileNRN, 
        nsFilenameSink=transFileNS, 
        nrnFilenameSink=transFileNRN)
    
    nrnInvertX( srcFilename=transFileNS, sinkFilename=invTransFileNS)
    nrnInvertX( srcFilename=transFileNRN, sinkFilename=invTransFileNRN) 
    
    nrnScale(srcFilename=invTransFileNS, sinkFilename=scaledInvTransFileNS, scaleFactor=1.28)
    nrnScale(srcFilename=invTransFileNRN, sinkFilename=scaledInvTransFileNRN, scaleFactor=1.28)
        
    nrnConcatenateXYZS(  srcFilename1=scaledInvTransFileNRN, srcFilename2=scaledInvTransFileNS, sinkFilename=invTransFileConCat)
    
    nrnXYZToSWC(srcFilename=invTransFileConCat, sinkFilename=invTransFileConCatSWC)
    
    nrnStraighten( srcFilename = invTransFileConCatSWC, sinkFilename=invTransFileConCatSWCStraight,matlabscriptname=matlabscriptname)
    
    #Create Unique output folder for each unique cellID if the folder doesn't exist
    if not os.path.exists(swcs_outDir+"%s %s/"%(nrnType,nrnNumber)): os.makedirs(swcs_outDir+"%s %s/"%(nrnType,nrnNumber))
	
    shutil.copyfile(invTransFileConCatSWCStraight,final)
コード例 #2
0
def nrnDoAll( nrnType, nrnNumber, nrnVersion="",nrnDate=""):
    versionSuffix = "" if not nrnVersion else " "+nrnVersion
    dateSuffix = "" if not nrnDate else " " + nrnDate 
    srcFileNRN = srcDir+"%s %s%s/%s %s nrn%s%s.txt"%(nrnType,nrnNumber, versionSuffix,nrnType,nrnNumber, dateSuffix, versionSuffix)
    srcFileNS =  srcDir+"%s %s%s/%s %s ns%s%s.txt"%(nrnType,nrnNumber, versionSuffix,nrnType,nrnNumber, dateSuffix,  versionSuffix)
    
    transFileNRN = outDir+"%s %s%s/%s %s nrn%s.transl.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    transFileNS = outDir+"%s %s%s/%s %s ns%s.transl.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    
    invTransFileNRN = outDir+"%s %s%s/%s %s nrn%s.transl.invX.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    invTransFileNS = outDir+"%s %s%s/%s %s ns%s.transl.invX.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)

    scaledInvTransFileNRN = outDir+"%s %s%s/%s %s nrn%s.transl.invX.scaled.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    scaledInvTransFileNS = outDir+"%s %s%s/%s %s ns%s.transl.invX.scaled.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)

    
    invTransFileConCat = outDir+"%s %s%s/%s %s nrn + ns%s.transl.invX.scaled.txt"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    
    invTransFileConCatSWC = outDir+"%s %s%s/%s %s nrn + ns%s.transl.invX.scaled.swc"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    
    matlabscriptname = outDir+"%s %s%s/mscript.m"%(nrnType,nrnNumber,versionSuffix) #,nrnType,nrnNumber,versionSuffix)
    invTransFileConCatSWCStraight = outDir+"%s %s%s/%s %s nrn + ns%s.transl.invX.scaled.straightened.swc"%(nrnType,nrnNumber,versionSuffix,nrnType,nrnNumber,versionSuffix)
    
    
    
    final = swcs_outDir+"%s %s nrn + ns%s.transl.invX.scaled.straightened.swc"%(nrnType,nrnNumber,versionSuffix)
    
    
    
    print "Source Files"
    print "\t", srcFileNRN
    print "\t", srcFileNS 
    
    print "Producing"
    print "\t",transFileNRN
    print "\t",transFileNS
    
    print "\t",invTransFileNRN
    print "\t",invTransFileNS
    
    print "\t",scaledInvTransFileNRN
    print "\t",scaledInvTransFileNS
    
    print "\t",invTransFileConCat
    print "\t",invTransFileConCatSWC
    print "\t",invTransFileConCatSWCStraight
    
    
    print "Executing:"
    
    
    nrnTranslate(  
        nsFilenameSrc=srcFileNS, 
        nrnFilenameSrc=srcFileNRN, 
        nsFilenameSink=transFileNS, 
        nrnFilenameSink=transFileNRN)
    
    nrnInvertX( srcFilename=transFileNS, sinkFilename=invTransFileNS)
    nrnInvertX( srcFilename=transFileNRN, sinkFilename=invTransFileNRN) 
    
    nrnScale(srcFilename=invTransFileNS, sinkFilename=scaledInvTransFileNS, scaleFactor=1.28)
    nrnScale(srcFilename=invTransFileNRN, sinkFilename=scaledInvTransFileNRN, scaleFactor=1.28)
        
    nrnConcatenateXYZS(  srcFilename1=scaledInvTransFileNRN, srcFilename2=scaledInvTransFileNS, sinkFilename=invTransFileConCat)
    
    nrnXYZToSWC(srcFilename=invTransFileConCat, sinkFilename=invTransFileConCatSWC)
    
    nrnStraighten( srcFilename = invTransFileConCatSWC, sinkFilename=invTransFileConCatSWCStraight,matlabscriptname=matlabscriptname)
    if not os.path.exists(swcs_outDir): os.makedirs(swcs_outDir)
	
    shutil.copyfile(invTransFileConCatSWCStraight,final)