#pragma rtGlobals=3 // Use modern global access method and strict wave access. // for calculating image alignment parameters: //regisrationThresholdIma_TA_MT( ctrlName ) :BUTTONCONTROL // make/o /d /n = ( 22 ) parmW = 0 // parmW[0] = TAPrefs.regParams[ 1 ] // dx // parmW[1] = TAPrefs.regParams[ 2 ] // dy // parmW[3] = TAPrefs.regParams[ 3 ] // a11 = 1 // parmW[4] = TAPrefs.regParams[ 4 ] // a12 // parmW[6] = TAPrefs.regParams[ 5 ] //a21 // parmW[7] = TAPrefs.regParams[ 6 ] //a22 = 1 // parmW[11] = TAPrefs.regParams[ 7 ] //a33 = 1 // parmW[17] = TAPrefs.regParams[ 8 ] // originX = 127 // parmW[18] = TAPrefs.regParams[ 9 ] // originY = 255 //***** plotting functions: // pspPlot_DCurtains( yDim, xDim, threshCurVal, minAreaVal ) // sdPlot_DCurtains( xBin, yBin, maxY, maxX, minDur , yTol ); 2d plot - sdPlot; 1d waves - xW_sdPlot and yW_sdPlot, and ywFit_sdPlot // hist1D_DCurtains( xW, yW, minX, maxX, minY, maxY, xBins, yBins ); input - ywFit_sdPlot; output - xHist, yHist // adds the name of softwave to macros botton menu "Macros" "Initialize DNA Curtains Analyzer/5",/Q , markDNAs_DCurtains( ) end function markDNAs_DCurtains( ) // Variable/G intThreshGVar = 0 variable/G maxIntGVar = 200 variable/G maxIntKymGVar = 200 variable/G minAreaGVar = 1 variable/G maxErrorGVar = 20 variable/G fitWidthGVar = 3 Variable/G currImGVar = 0 variable/G numImagesPChGVar = 1 variable/G numImagesDNAChGVar = 1 variable/g currFrGVar = 0 variable/g flitDNAImgHoriz = 1 variable/g dualViewImg = 1 // definePaths_DCurtains( ) // make/o/n=(1,1) cropedW // create a window with DNA ch. image dowindow/k cropedDC_wind newimage /n= cropedDC_wind cropedW // // create control panel. doWindow/k controlPanel NewPanel/K=2/W=(400,10,700, 400) as "Control panel" doWindow/c controlPanel // // create buttons. Button button0 disable=0, fsize = 12, pos={155, 360}, valueColor=(0,0,30000),fstyle=1, size={ 135, 20 }, title="Align. param.",win=controlPanel, proc = bcFunct_DCurtains // Button button2 disable=0, fsize = 12, pos={10, 10}, valueColor=(0,0,40000),fstyle=1, size={ 135, 20 }, title="Prev. image",win=controlPanel, proc = bcFunct_DCurtains // Button button1 disable=0, fsize = 12, pos={155, 10}, valueColor=(0,0,40000),fstyle=1, size={ 135, 20 }, title="Next image",win=controlPanel, proc = bcFunct_DCurtains // Button button5 disable=0, fsize = 12, pos={10, 45}, fstyle=1, size={ 135, 20 }, title="Make kymogram",win=controlPanel, proc = bcFunct_DCurtains // Button button5_1 disable=0, fsize = 12, pos={155, 45}, fstyle=1, size={ 135, 20 }, title="Thresh. & save", win=controlPanel, proc = bcFunct_DCurtains // Button button5_2 disable=0, fsize = 12, pos={80, 85}, valueColor=(0,30000,0), fstyle=1, size={ 135, 20 }, title="Gauss fitting",win=controlPanel, proc = bcFunct_DCurtains // Button button4 disable=0, fsize = 12, pos={80, 130}, valueColor=(0,0,40000),fstyle=1, size={ 135, 20 }, title="Mark states",win=controlPanel, proc = bcFunct_DCurtains // Button button4_2 disable=0, fsize = 12, pos={10, 160}, valueColor=(0,30000,0),fstyle=1, size={ 135, 20 }, title="Pause marking",win=controlPanel, proc = bcFunct_DCurtains // Button button4_3 disable=0, fsize = 12, pos={155, 160}, valueColor=(0,30000,0),fstyle=1, size={ 135, 20 }, title="Continue marking",win=controlPanel, proc = bcFunct_DCurtains // Button button4_1 disable=0, fsize = 12, pos={80, 190}, valueColor=(0,0,30000),fstyle=1, size={ 135, 20 }, title="Save st. res.",win=controlPanel, proc = bcFunct_DCurtains // //create set variable controls SetVariable testSetting001 disable = 0, fsize=11, limits={0, 65000, 1}, pos={15, 220}, size = {140, 0}, value =maxIntGVar, proc = setting01_DCurtains , title= "Max. int.", win=controlPanel // SetVariable testSetting001r disable = 0, fsize=11, limits={0, 65000, 1}, pos={155, 220}, size = {140, 0}, value =maxIntKymGVar, proc = setting01_DCurtains , title= "Max. int. kym.", win=controlPanel // SetVariable testSetting002 disable = 0, fsize=11, limits={0, 65000, 1}, pos={155, 240}, size = {140, 0}, value = intThreshGVar, proc = setting01_DCurtains , title= "Thresh.", win=controlPanel // SetVariable testSetting003 disable = 0, fsize=11, limits={0, 65000, 1}, pos={15, 240}, size = {140, 0}, value = minAreaGVar, proc = setting01_DCurtains , title= "Min. area", win=controlPanel // SetVariable testSetting005 disable = 0, fsize=11, limits={0, 65000, 1}, pos={15, 260}, size = {140, 0}, value = maxErrorGVar, proc = setting01_DCurtains , title= "Max. error", win=controlPanel // SetVariable testSetting006 disable = 0, fsize=11, limits={0, 65000, 1}, pos={155, 260}, size = {140, 0}, value = fitWidthGVar, proc = setting01_DCurtains , title= "Fitting width", win=controlPanel // SetVariable testSetting007 disable = 0, fsize=11, limits={0, 65000, 1}, pos={15, 280}, size = {140, 0}, value = numImagesDNAChGVar, proc = setting01_DCurtains , title= "# im. DNA ch.", win=controlPanel // SetVariable testSetting008 disable = 0, fsize=11, limits={0, 65000, 1}, pos={155, 280}, size = {140, 0}, value = numImagesPChGVar, proc = setting01_DCurtains , title= "# im. Prot. ch.", win=controlPanel // status_DCurtains( "Ready: enter alignment par." ) // show cursors ShowInfo /W=cropedDC_wind // end function status_DCurtains( inStr ) string inStr // setDrawLayer/K/w=controlPanel userBack // SetDrawLayer/W=controlPanel /K progFront // SetDrawEnv/W=controlPanel xcoord=abs, ycoord=abs, fillbgc=(65000,0,0), fillfgc=(65000,0,0), linebgc=(65000,0,0), linefgc=(65000,0,0), textrgb=(0,30000,0), fillpat=1, linethick=2, fsize=14 // DrawText/W=controlPanel 30, 360, inStr // doUpdate // end // function bcFunct_DCurtains(ctrlName):buttonControl string ctrlName // variable aa, bb, x0, x1, y0, y1, first = 0, last = 0, sizeTable = 0 variable dx=0, dy=0, a11 = 1, a12=0, a21=0, a22=1, orgX = 127, orgY = 255 variable flipCurrV = 1 variable dualViewImgCUrrV = 1 string localStr = "" // NVAR currImGVar NVAR intThreshGVar, minAreaGVar NVAR maxErrorGVar, fitWidthGVar NVAR flitDNAImgHoriz NVAR dualViewImg // strswitch( ctrlName ) // case "button0": // align params. // make/o /d /n = ( 22 ) parmW = 0 // prompt dx, "dx" prompt dy, "dy" prompt a11, "a11" prompt a12, "a12" prompt a21, "a21" prompt a22, "a22" prompt orgX, "orgX" prompt orgY, "orgY" prompt flipCurrV, "horiz. flip: 1 - yes, other values - no" prompt dualViewImgCUrrV, "dual-view: 1 - yes, other values - no" // doPrompt "Enter values form alignment of DNA ch. image" , dx, dy, a11, a12, a21, a22, orgX, orgY, flipCurrV, dualViewImgCUrrV // parmW[0] = dx parmW[1] = dy parmW[3] = a11 parmW[4] = a12 parmW[6] = a21 parmW[7] = a22 parmW[11] = 1 // a33 parmW[17] = orgX // kai x pikseliu = 256, tada orgX = 127 parmW[18] = orgY // kai x pikseliu = 512, tada orgX = 255 flitDNAImgHoriz = flipCurrV dualViewImg = dualViewImgCUrrV // load and average image loadDNAChIm_DCurtains( ); wave avgW // status_DCurtains( "Curr. image #: "+num2str(currImGVar) ) // break // case "button1": // next image // string imagesNamesSTR = getImageNames_DCurtains( 1 ) // variable numImages = itemsinlist( imagesNamesSTR , ";" ) // if( currImGVar < numImages - 1 ) currImGVar += 1 else currImGVar = numImages - 1 endif // load and average image loadDNAChIm_DCurtains( ); wave avgW // status_DCurtains( "Curr. image #: "+num2str(currImGVar) ) // break // case "button2": // prev. image // if( currImGVar > 0 ) currImGVar -= 1 else currImGVar = 0 endif // load and average image loadDNAChIm_DCurtains( ); wave avgW // status_DCurtains( "Curr. image #: "+num2str(currImGVar) ) // break // case "button5": // make kymogram // x0 = pcsr(A, "cropedDC_wind") y0 = qcsr(A, "cropedDC_wind") x1 = pcsr(B, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // SetDrawLayer /W=cropedDC_wind /K UserFront SetDrawLayer /W=cropedDC_wind UserFront SetDrawEnv/w=cropedDC_wind xcoord = top, ycoord = left, linefgc = (65535,0,0) DrawLine/w=cropedDC_wind x0,y0,x1,y1 // print x0, y0, x1, y1, ": x0, y0, x1, y1 of the marked DNA." // genKymogram_DCurtains( x0, y0, x1, y1 ); wave kymogramCurrW // print "kymogram generated." status_DCurtains( "Kymogram generated.\rCurr. image #: "+num2str(currImGVar) ) // break // case "button5_1": // threshold and save kymogram // x0 = pcsr(A, "cropedDC_wind") y0 = qcsr(A, "cropedDC_wind") x1 = pcsr(B, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // wave kymogramCurrW // thresholdKymogram_DCurtains( y0, y1 ) // localStr = "kymW_"+num2str(x0)+"_"+num2str(y0)+"_"+num2str(x1)+"_"+num2str(y1)+"_"+num2str(currImGVar)+"_img.ibw" // Save/C/O/P = resPath kymogramCurrW as localStr // print "kymogram thresholded and saved." status_DCurtains( "Kymogram thresholded and saved.\rCurr. image #: "+num2str(currImGVar) ) // break // case "button5_2": // 2D Gaussian fitting // x0 = pcsr(A, "cropedDC_wind") y0 = qcsr(A, "cropedDC_wind") x1 = pcsr(B, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // spotDetect_DCurtains( x0, y0, x1, y1 ) // wave gFitResW, xW_fit , yW_fit // make/o /n = ( dimSize( xW_fit, 0 ), 2 ) xyW_fit // xyW_fit[ ][ 0 ] = xW_fit[ p ]; xyW_fit[ ][ 1 ] = yW_fit[ p ] // localStr = "xyWFit_"+num2str(x0)+"_"+num2str(y0)+"_"+num2str(x1)+"_"+num2str(y1)+"_"+num2str(currImGVar)+"_img.ibw" // Save/C /O /P = resPath xyW_fit as localStr // localStr = "gFitRes_"+num2str(x0)+"_"+num2str(y0)+"_"+num2str(x1)+"_"+num2str(y1)+"_"+num2str(currImGVar)+"_img.ibw" // Save/C /O /P = resPath gFitResW as localStr // print "Fitting done and results saved." status_DCurtains( "Fitting done and results saved.\rCurr. image #: "+num2str(currImGVar) ) // break // case "button3": // abort // dowindow/k cropedDC_wind; dowindow/k controlPanel ; doWIndow/k kymogram_wind // abort // break // case "button4": // mark states // y0 = qcsr(A, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // markStates_DCurtains( y0, y1, 1 ) // break // case "button4_1": // save mark states results // wave selStTable // x0 = pcsr(A, "cropedDC_wind") y0 = qcsr(A, "cropedDC_wind") x1 = pcsr(B, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // localStr = "selSt_"+num2str(x0)+"_"+num2str(y0)+"_"+num2str(x1)+"_"+num2str(y1)+"_"+num2str(currImGVar)+"_img.ibw" Save/C/O/P = resPath selStTable as localStr // print "State selection results saved." status_DCurtains( "State selection results saved.\rCurr. image #: "+num2str(currImGVar) ) // break // case "button4_2": // pause mark states // y0 = qcsr(A, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // markStates_DCurtains( y0, y1, 0 ) // break // case "button4_3": // continue mark states // y0 = qcsr(A, "cropedDC_wind") y1 = qcsr(B, "cropedDC_wind") // markStates_DCurtains( y0, y1, 2 ) // break // endswitch // end // function setting01_DCurtains(SV_Struct) : SetVariableControl STRUCT WMSetVariableAction &SV_Struct // NVAR maxIntGVar, intThreshGVar , minAreaGVar, maxErrorGVar, fitWidthGVar NVAR numImagesPChGVar, numImagesDNAChGVar, currFrGVar, maxIntKymGVar // wave cropedW, kymogramCurrW // if( SV_Struct.eventCode == 1 || SV_Struct.eventCode == 2 ) // act only on Enter key accepting edit, or on mouse up in the arrow buttons // checking which of the setVariable control was executed strswitch( SV_Struct.ctrlName ) // string switch // case "testSetting001": // wavestats/q cropedW // maxIntGVar = max( SV_Struct.dval, V_min ) // ModifyImage/w=cropedDC_wind cropedW explicit=0,ctab= {V_min,maxIntGVar,Grays,0} doUpdate // break // case "testSetting001r": // if(waveexists(kymogramCurrW) == 1) // wavestats/q kymogramCurrW // maxIntKymGVar = max( SV_Struct.dval, V_min ) // ModifyImage/w=kymogram_wind kymogramCurrW explicit=0,ctab= {V_min,maxIntKymGVar,Grays,0} doUpdate // endif // break // case "testSetting002": // intThreshGVar = SV_Struct.dval // break // case "testSetting003": // minAreaGVar = SV_Struct.dval // break // case "testSetting005": // maxErrorGVar = SV_Struct.dval // break // case "testSetting006": // fitWidthGVar = SV_Struct.dval // break // case "testSetting007": // numImagesDNAChGVar = SV_Struct.dval // break // case "testSetting008": // numImagesPChGVar = SV_Struct.dval // break // endswitch // endif // end function loadDNAChIm_DCurtains( ) variable hh NVAR currImGVar, numImagesDNAChGVar NVAR flitDNAImgHoriz, dualViewImg // string imagesNamesSTR = getImageNames_DCurtains( 1 ) for( hh = 0 ; hh < numImagesDNAChGVar ; hh += 1 ) // load image ImageLoad/Q /T=tiff /O /S=(hh) /C=1 /N=image /P = dnaChPath stringfromlist( currImGVar, imagesNamesSTR, ";" ) wave/z tempW = $stringfromlist(0, S_waveNames, ";") if( hh == 0 ) Duplicate/O tempW, avgW killwaves/z $stringfromlist(0, S_waveNames, ";") else avgW += tempW killwaves/z $stringfromlist(0, S_waveNames, ";") endif endfor avgW /= numImagesDNAChGVar if( dualViewImg == 1 ) Duplicate/O /R=[ (dimsize(avgW,0)*0.5), dimsize(avgW,0)-1 ][*,*] avgW, cropedWTemp setscale/p x , 0,1, cropedWTemp; setscale/p y , 0,1, cropedWTemp endif if( flitDNAImgHoriz == 1 ) // flip DNA channel image horizontally ImageRotate/H/O cropedWTemp endif // adjust the scale Duplicate/O cropedWTemp, cropedW; setscale/p x , 0,1, cropedW; setscale/p y , 0,1, cropedW // align image alignImage_DCurtains( cropedW ) ; wave M_RegOut duplicate/o M_RegOut, cropedW end Function alignImage_DCurtains( imW ) wave imW // wave/z parmW // if( WaveExists( parmW ) != 1 ) print "alignmet parameters wave does not exist." abort endif // redimension /s imW, imW ImageRegistration /USER= parmW /MSKC=2 /REFM=0 /TSTM=0 /ASTP=3 /STRT=20 /INTR=2 /FLVL=2 /TRNS={1,1,0} /MING=0 /SKEW={1,1,0} /CONV=1 /ROT={0,0,0} /Q testWave = imW, refWave = imW wave M_RegOut // end // function genKymogram_DCurtains( x0, y0, x1, y1 ) variable x0, y0, x1, y1 // variable jj, pp variable countY = 0 variable xCurrVar variable dXvar = ( x1 - x0 ) / ( y1 - y0) // string imagesNamesSTR_proteinCh = getImageNames_DCurtains( 2 ) // NVAR currImGVar, numImagesPChGVar, maxIntGVar, minAreaGVar, maxIntKymGVar, dualViewImg // print stringfromlist( currImGVar, imagesNamesSTR_proteinCh, ";" ) , ": name of current protein ch. image" print numImagesPChGVar, ": # of images to load from protein ch." // ImageLoad/Q /T=tiff /O /S=(0) /C=(numImagesPChGVar)/LR3D /N=imagePCh /P = proteinChPath stringfromlist( currImGVar, imagesNamesSTR_proteinCh, ";" ) wave/z cropedW_pCh = $stringfromlist( 0, S_waveNames, ";") // if( dualViewImg == 1 ) Duplicate/O /R=[ 0, (dimsize(cropedW_pCh,0)*0.5)-1 ][*,*] cropedW_pCh, cropedWTempPCh duplicate/o cropedWTempPCh, cropedW_pCh endif // setscale/p x , 0,1, cropedW_pCh; setscale/p y , 0,1, cropedW_pCh // print "all protein ch. images loaded" // make/o /n = ( numImagesPChGVar, ceil( y1 - y0 ) + 1 ) kymogramCurrW // make/o/n=( dimSize(cropedW_pCh,0) , dimSize(cropedW_pCh,1)) croppW // for( jj = 0 ; jj < numImagesPChGVar; jj += 1 ) // runs over images // countY = 0 // for( pp = y0; pp <= y1; pp += 1 ) // xCurrVar = x0 + round( dXvar * countY ) // //kymogramCurrW[ jj ][ countY ] = cropedW_pCh[ xCurrVar+256 ][ pp ][ jj ] kymogramCurrW[ jj ][ countY ] = cropedW_pCh[ xCurrVar ][ pp ][ jj ] // countY += 1 // endFor // endFor // print "kymogram was generated." // dowindow/k kymogram_wind // newimage/n=kymogram_wind kymogramCurrW // MoveWindow /W=kymogram_wind 10, 10, numImagesPChGVar, (ceil( y1 - y0 ))*3 // ModifyImage/w=kymogram_wind kymogramCurrW ctab= { *, maxIntKymGVar, Grays, 0 } // ModifyGraph/w=kymogram_wind nticks(left)=10 // end function thresholdKymogram_DCurtains( y0, y1 ) variable y0, y1 // wave kymogramCurrW // variable stopValue = 0 // NVAR intThreshGVar, maxIntGVar, minAreaGVar, numImagesPChGVar, maxIntKymGVar // make/o/n=(1,1) M_ImageThresh, M_Particle // dowindow/k kymogram_wind // newimage/n=kymogram_wind kymogramCurrW // MoveWindow /W=kymogram_wind 10, 10, numImagesPChGVar, (ceil( y1 - y0 ))*3 // ModifyImage/w=kymogram_wind kymogramCurrW ctab= { *, maxIntKymGVar, Grays, 0 } // ImageThreshold/I /Q /T=( intThreshGVar ) kymogramCurrW // ImageAnalyzeParticles/m=3 /Q /A=( minAreaGVar ) /E stats M_ImageThresh; Wave M_moments, M_Particle // AppendMatrixContour/T /w=kymogram_wind M_Particle // ModifyContour/w=kymogram_wind M_Particle labels=0, autoLevels={18,*,2} // ModifyGraph/w=kymogram_wind nticks(left)=10 // doupdate // end // function spotDetect_DCurtains( x0_in, y0_in, x1_in, y1_in ) // variable x0_in, y0_in, x1_in, y1_in // print x0_in, y0_in, x1_in, y1_in, ": x0, y0, x1, y1 of the marked DNA." // variable gg, ff variable/G countKym = 0 variable/G counter1 = 0 // string imagesNamesSTR_proteinCh = getImageNames_DCurtains( 2 ) // NVAR intThreshGVar, minAreaGVar, fitWidthGVar NVAR currImGVar, numImagesPChGVar, maxErrorGVar, dualViewImg // print intThreshGVar, fitWidthGVar, minAreaGVar, maxErrorGVar, ": int. threshold, fitting width, minimum area, maximum error." print stringfromlist( currImGVar, imagesNamesSTR_proteinCh, ";" ), ": curr. protein ch. image name" // ImageLoad/Q /T=tiff /O /S=(0) /C=(numImagesPChGVar)/LR3D /N=imagePCh /P = proteinChPath stringfromlist( currImGVar, imagesNamesSTR_proteinCh, ";" ) wave/z cropedW_pCh = $stringfromlist( 0, S_waveNames, ";") // if( dualViewImg == 1 ) Duplicate/O /R=[ 0, (dimsize(cropedW_pCh,0)*0.5)-1 ][*,*] cropedW_pCh, cropedWTempPCh duplicate/o cropedWTempPCh, cropedW_pCh endif // setscale/p x , 0,1, cropedW_pCh; setscale/p y , 0,1, cropedW_pCh // print "all protein ch. images loaded" // make/o /n = ( fitWidthGVar, ceil( y1_in - y0_in ) + 1 ) cropedW_pCh0 // make/o /n = ( numImagesPChGVar* fitWidthGVar, ceil( y1_in - y0_in ) + 1 ) kymogramFitting = 0 // Make/D /O /N = 7 coefW // for( gg = 0 ; gg < numImagesPChGVar ; gg += 1 ) // if( gg == numImagesPChGVar * 0.2 ) status_DCurtains( "Fitting is running.\r"+num2str(gg+1)+" frame, from "+num2str(numImagesPChGVar) ) elseif( gg == numImagesPChGVar * 0.4 ) status_DCurtains( "Fitting is running.\r"+num2str(gg+1)+" frame, from "+num2str(numImagesPChGVar) ) elseif( gg == numImagesPChGVar * 0.6 ) status_DCurtains( "Fitting is running.\r"+num2str(gg+1)+" frame, from "+num2str(numImagesPChGVar) ) elseif( gg == numImagesPChGVar * 0.8 ) status_DCurtains( "Fitting is running.\r"+num2str(gg+1)+" frame, from "+num2str(numImagesPChGVar) ) endif // // load protein ch. image frame number gg getFrame_DCurtains( x0_in , y0_in, x1_in, y1_in, cropedW_pCh0, cropedW_pCh , gg, kymogramFitting ) // //generate thresholded image ImageThreshold /I /Q /T=( intThreshGVar ) cropedW_pCh0; wave M_ImageThresh // detect FL spots inside the thresholded image ImageAnalyzeParticles/m=3 /Q /A=( minAreaGVar ) /E stats M_ImageThresh; Wave M_moments // for( ff = 0 ; ff < dimSize( M_moments, 0 ) ; ff += 1 ) // if( numtype( M_moments[ ff ][ 0 ] ) == 0 && numtype( M_moments[ ff ][ 1 ] ) == 0 ) // wavestats/q cropedW_pCh0 coefW[0] = {V_min, cropedW_pCh0[M_moments[ ff ][ 0 ]][M_moments[ ff ][ 1 ]], M_moments[ ff ][ 0 ], 2, M_moments[ ff ][ 1 ], 2, 0 } // fit_DCurtains( cropedW_pCh0 , gg, coefW ) // endif // endFor // endFor // // status_DCurtains( "Fitting finished!") // // killwaves/z $stringfromlist( 0, S_waveNames, ";") // wave gFitResW, xW_fit , yW_fit // wave kymogramCurrW // NVAR maxIntGVar, maxIntKymGVar // dowindow/k kymogram_wind // newimage/n=kymogram_wind kymogramCurrW // MoveWindow /W=kymogram_wind 10, 10, numImagesPChGVar, (ceil( y1_in - y0_in ))*3 // ModifyImage/w=kymogram_wind kymogramCurrW ctab= { *, maxIntKymGVar, Grays, 0 } // AppendToGraph/w=kymogram_wind /T yW_fit vs xW_fit // ModifyGraph/w=kymogram_wind msize=2, mrkThick=2, mode=3, nticks(left)=10 // doupdate // end function markStates_DCurtains( y0_in, y1_in , hookToggle) variable y0_in, y1_in, hookToggle // wave gFitResW, xW_fit , yW_fit // wave kymogramCurrW // NVAR maxIntGVar, numImagesPChGVar, maxIntKymGVar // dowindow/k kymogram_wind // newimage/n=kymogram_wind kymogramCurrW // MoveWindow /W=kymogram_wind 10, 10, numImagesPChGVar, (ceil( y1_in - y0_in ))*3 // ModifyImage/w=kymogram_wind kymogramCurrW ctab= { *, maxIntKymGVar, Grays, 0 } // AppendToGraph/w=kymogram_wind /T yW_fit vs xW_fit // ModifyGraph/w=kymogram_wind msize=2, mrkThick=2, mode=3, nticks(left)=10 // doupdate // variable/G numStSelected // if( hookToggle == 1 ) // numStSelected = 0 // make/o /n = ( 1, 3 ) selStTable = 0 // dowindow/k selStTrTable_table // edit/n = selStTrTable_table /W=(10, 350, 400, 600) selStTable // // enable manual state marking SetWindow kymogram_wind, hook(MyHook) = SelStatesHook_DCurtains // Install window hook // elseif( hookToggle == 2 ) // dowindow/k selStTrTable_table // edit/n = selStTrTable_table /W=(10, 350, 400, 600) selStTable // // enable manual state marking SetWindow kymogram_wind, hook(MyHook) = SelStatesHook_DCurtains // Install window hook // endif // end Function SelStatesHook_DCurtains(s) STRUCT WMWinHookStruct &s // Variable hookResult = 0 // 0 if we do not handle event, 1 if we handle it. // wave selStTable // NVAR numStSelected // string stringStates, stringStatesCorr // switch(s.eventCode) // case 0: // mouse moved event // dowindow/f controlPanel; dowindow/b kymogram_wind // if( AxisValFromPixel(s.winName, "top", s.mouseLoc.h) >= 0 ) // add state // if( numStSelected > 0 ) insertpoints/m = 0 numStSelected, 1 , selStTable endif // doUpdate // selStTable[ numStSelected ][ 0 ] = round( AxisValFromPixel( s.winName, "top", s.mouseLoc.h ) ) selStTable[ numStSelected ][ 1 ] = round( AxisValFromPixel( s.winName, "left", s.mouseLoc.v ) ) // numStSelected += 1 // else // remove state // if( numStSelected > 1 ) deletepoints/m = 0 numStSelected-1, 1, selStTable numStSelected -= 1 else make/o /n = ( 1, 3 ) selStTable = 0 numStSelected = 0 endif // endif // doUpdate // if( numStSelected > 1 ) // if( mod( dimSize( selStTable,0 ) , 2 ) == 0 ) // stateInfo_DCurtains( ) // drawStates_DCurtains( selStTable ) // endif // else SetDrawLayer /W=kymogram_wind /K UserFront endif // hookResult = 1 // break // endswitch // return hookResult // If non-zero, we handled event and Igor will ignore it. // End Function stateInfo_DCurtains( ) wave selStTable, yW_fit, xW_fit variable aa, bb, x0_loc, x1_loc, y0_loc, y1_loc, count_loc variable tolY = 3 for( aa = 0 ; aa < dimsize( selStTable, 0 ) ; aa += 2 ) x0_loc = selStTable[ aa ][ 0 ] x1_loc = selStTable[ aa + 1 ][ 0 ] y0_loc = selStTable[ aa ][ 1 ] y1_loc = selStTable[ aa + 1 ][ 1 ] make/o /n = ( 0 ) tempW count_loc = 0 for( bb = 0 ; bb < dimSize( xW_fit, 0 ) ; bb += 1 ) if( xW_fit[ bb ] >= x0_loc && xW_fit[ bb ] <= x1_loc && yW_fit[ bb ] >= y0_loc - tolY && yW_fit[ bb ] <= y1_loc + tolY ) insertpoints/m=0 count_loc, 1, tempW tempW[ count_loc ] = yW_fit[ bb ] count_loc += 1 endif endFor wavestats/q /m=1 /z tempW selStTable[ aa ][ 2 ] = V_avg selStTable[ aa + 1 ][ 2 ] = V_avg endFor end Function drawStates_DCurtains( selStTable ) wave selStTable // variable aa, c1, c2, c3, c4 // SetDrawLayer /W=kymogram_wind /K UserFront // SetDrawLayer /W=kymogram_wind UserFront for( aa = 0 ; aa < dimSize( selStTable,0 ) ; aa += 2 ) SetDrawEnv/w=kymogram_wind xcoord = top, ycoord = left, linefgc = (0,40000,0), linethick=3 c1 = selStTable[ aa ][ 0 ] c2 = selStTable[ aa ][ 2 ] c3 = selStTable[ aa + 1 ][ 0 ] c4 = selStTable[ aa ][ 2 ] DrawLine/w=kymogram_wind c1, c2, c3, c4 endFor end function getFrame_DCurtains( x0_in , y0_in, x1_in, y1_in, cropedW_pCh0, cropedW_pCh, frameId , kymogramFitting ) variable x0_in , y0_in, x1_in, y1_in wave cropedW_pCh0, cropedW_pCh variable frameId wave kymogramFitting // NVAR countKym // variable xCurrVar, tt, ee, cY = 0, cX = 0 // variable dXvar = ( x1_in - x0_in ) / ( y1_in - y0_in ) // NVAR fitWidthGVar // for( tt = y0_in; tt <= y1_in ; tt += 1 ) // cX = 0 // //xCurrVar = (( x0_in + round( dXvar * cY ) ) + 256 ) - ( fitWidthGVar / 2 ) // xCurrVar = (( x0_in + round( dXvar * cY ) ) ) - ( fitWidthGVar / 2 ) // for( ee = xCurrVar ; ee < xCurrVar + fitWidthGVar ; ee += 1 ) // cropedW_pCh0[ cX ][ cY ] = cropedW_pCh[ ee ][ tt ][ frameId ] // cX += 1 // endFor // cY+= 1 // endFor // // // for( tt = 0 ; tt < dimSize( cropedW_pCh0, 0 ) ; tt += 1 ) // // // for( ee = 0; ee < dimSize( cropedW_pCh0, 1 ) ; ee += 1 ) // // // kymogramFitting[ countKym ][ ee ] = cropedW_pCh0[ tt ][ ee ] // // // endfor // // // countKym += 1 // // // endFor // end function fit_DCurtains( cropedW_pCh0, frameId, coefW ) wave cropedW_pCh0 variable frameId wave coefW // variable/G V_fitError = 0, V_FitMaxIters = 100 // variable errorXW, errorYW, errorAmp // NVAR maxErrorGVar, fitWidthGVar, counter1 // CurveFit/N /G /Q /W = 2 /NTHR=0 Gauss2D kwCWave = coefW, cropedW_pCh0 // wave/z W_sigma // if( V_fitError == 0 ) errorXW = abs( W_sigma[3] / coefW[3] )*100; errorYW = abs( W_sigma[5] / coefW[5] )*100; errorAmp = abs( W_sigma[1] / coefW[1] )*100 //print errorXW, errorYW, errorAmp if( errorXW < maxErrorGVar && errorYW < maxErrorGVar && errorAmp < maxErrorGVar && coefW[ 4 ] > 0 && coefW[ 4 ] < dimsize( cropedW_pCh0, 1 ) ) if( counter1 == 0 ) make/o /n = ( 1, 6 ) gFitResW make/o /n = 1 xW_fit, yW_fit else insertPoints/m=0 counter1 , 1, gFitResW, xW_fit, yW_fit endif gFitResW[ counter1 ][ 0 ] = coefW[ 1 ] //amp gFitResW[ counter1 ][ 1 ] = coefW[ 2 ] //xC gFitResW[ counter1 ][ 2 ] = coefW[ 3 ] //xW gFitResW[ counter1 ][ 3 ] = coefW[ 4 ] //yC gFitResW[ counter1 ][ 4 ] = coefW[ 5 ] //yW gFitResW[ counter1 ][ 5 ] = frameId xW_fit[ counter1 ] = frameId yW_fit[ counter1 ] = coefW[ 4 ] counter1 += 1 endif endif end function/S getImageNames_DCurtains( pathIndex ) variable pathIndex string localStr if( pathIndex == 1 ) localStr = indexedFIle ( dnaChPath , -1 , "????" ) // list of DNA channel images names localStr= RemoveFromList(".DS_Store", localStr, ";" ) localStr= RemoveFromList("display_and_comments.txt;metadata.txt", localStr, ";" ) localStr = SortList( localStr, ";", 16 ) elseif( pathindex == 2 ) localStr = indexedFIle ( proteinChPath , -1 , "????" ) // list of protein channel images names localStr= RemoveFromList(".DS_Store", localStr, ";" ) localStr= RemoveFromList("display_and_comments.txt;metadata.txt", localStr, ";" ) localStr = SortList( localStr, ";", 16 ) endif return localStr end function definePaths_DCurtains( ) // variable stopVar = 0 // prompt stopVar, "Redifine paths? ", popup, "yes;no;abort;" doPrompt "Select", stopVar // if( V_flag == 1 ) abort else // if( stopVar == 1 ) // // path to folder containing DNA channel images killPath/z dnaChPath NewPath/M="Define directory, containg DNA ch. images"/Q/Z dnaChPath if( V_flag != 0 ) abort "Path was not defined." else pathinfo dnaChPath print S_path, ": path to DNA ch." endif // path to folder containing protein channel images killPath/z proteinChPath NewPath/M="Define directory, containg protein ch. images"/Q/Z proteinChPath if( V_flag != 0 ) abort "Path was not defined." else pathinfo proteinChPath print S_path, ": path to protein ch." endif // path to results folder killPath/z resPath NewPath/M="Define results directory"/Q/Z resPath if( V_flag != 0 ) abort "Path was not defined." else pathinfo resPath print S_path, ": path to results" endif // elseif( stopVar == 2 ) // pathinfo dnaChPath; print S_path, ": path to DNA ch." pathinfo proteinChPath; print S_path, ": path to protein ch." pathinfo resPath; print S_path, ": path to results." // elseif( stopVar == 3 ) abort endif // endif // end function pspPlot_DCurtains( yDim, xDim, threshCurVal, minAreaVal ) variable yDim, xDim, threshCurVal, minAreaVal variable aa, numKym, bb, cc, stopVar = 1 string currKym_Str killPath/z resPath NewPath/M="Define directory, containg kymograms"/Q/Z resPath if( V_flag != 0 ) abort "Path was not defined." else pathinfo resPath print S_path, ": path to kymogram folder." endif string localStr = indexedFIle ( resPath , -1 , "????" ) // list of kymogram names localStr= RemoveFromList(".DS_Store", localStr, ";" ) localStr= RemoveFromList("display_and_comments.txt;metadata.txt", localStr, ";" ) localStr = SortList( localStr, ";", 16 ) numKym = itemsinlist( localStr, ";" ) make/o/n=( xDim, yDim ) pspPlot = 0 for( aa = 0 ; aa < numKym ; aa += 1 ) currKym_Str = stringfromlist( aa , localStr, ";" ) if( stringmatch( currKym_Str, "kymWTresh_*" ) == 1 ) LoadWave/H/P=resPath/O currKym_Str wave/z currW = $stringfromlist( 0, S_waveNames, ";" ) // ImageThreshold /I /Q /T=( threshCurVal ) currW; wave M_ImageThresh // ImageAnalyzeParticles/m=3 /Q /A=( minAreaVal ) /E stats M_ImageThresh; Wave M_moments, M_Particle for( bb = 0 ; bb < min( dimsize(currW,0), yDim) ; bb += 1 ) for( cc = 0 ; cc < min( dimsize(currW,1), xDim ) ; cc += 1 ) if( currW[ bb ][ cc ] != 64 ) pspPlot[ cc ][ bb ] += 1 endif endFor endFor killwaves/z $stringfromlist( 0, S_waveNames, ";" ) endif endFor end function sdPlot_DCurtains( xBin, yBin, maxY, maxX, minDur , yTol ) variable xBin, yBin variable maxY, maxX, minDur, yTol // variable numW, aa, xC, yC, bb, durVar, numMol = 0, numStates = 0, yy variable x0_loc, x1_loc, y0_loc, y1_loc variable numPntsxyW = 0 variable okVar string curr_Str, localStr , xyWnameStr // killPath/z resPath_sdPlot NewPath/M="Define directory, containg results"/Q/Z resPath_sdPlot if( V_flag != 0 ) abort "Path was not defined." else pathinfo resPath_sdPlot print S_path, ": path to results folder." endif // localStr = indexedFIle ( resPath_sdPlot , -1 , "????" ) // list of kymogram names localStr = RemoveFromList(".DS_Store", localStr, ";" ) localStr = RemoveFromList("display_and_comments.txt;metadata.txt", localStr, ";" ) localStr = SortList( localStr, ";", 16 ) // numW = itemsinlist( localStr, ";" ) // make/o/n=( xBin+1, yBin+1 ) sdPlot = 0 // // making index wave for xAxis and yAxis of the 2D histogram plot make/o /n = ( xBin+1 ) indexWave1 = ( maxX / xBin ) * p // x grid wave // make/o /n = ( yBin+1 ) indexWave2 = ( maxY / yBin ) * p // y grid wave // make/o /t /n = ( yBin+1 ) avgDurBinTxt = "" // // set scale for 2D histograms. setscale/i x, 0, indexWave1[ xBin - 1 ] , sdPlot setscale/i y, 0, indexWave2[ yBin - 1 ] , sdPlot // make/o /n = 0 xW_sdPlot, yW_sdPlot, ywFit_sdPlot // for( aa = 0 ; aa < numW ; aa += 1 ) // curr_Str = stringfromlist( aa , localStr, ";" ) // if( stringmatch( curr_Str, "selSt_*" ) == 1 ) // // numMol += 1 // // xyWnameStr = "xyWFit" // for( yy = 1 ; yy < itemsinlist( curr_Str, "_" ) ; yy += 1 ) // xyWnameStr += "_"+stringFromList( yy, curr_Str, "_" ) // endfor // LoadWave/H /Q /P= resPath_sdPlot /O xyWnameStr // Duplicate/o $stringfromlist( 0, S_waveNames, ";" ) , xyWave // killwaves/z $stringfromlist( 0, S_waveNames, ";" ) // // LoadWave/H /Q /P= resPath_sdPlot /O curr_Str // wave/z currW = $stringfromlist( 0, S_waveNames, ";" ) // // if( mod( dimSize( currW, 0 ) , 2 ) == 0 && dimSize( currW, 1 ) == 3 && dimSize( currW, 0 ) > 1 ) // // for( bb = 0 ; bb + 1 < dimSize( currW, 0 ) ; bb += 2 ) // // if( bb + 1 >= dimSIze( currW, 0 ) ) abort endif // durVar = currW[ bb + 1 ][ 0 ] - currW[ bb ][ 0 ] // okVar = 0 // // if( currW[ bb ][ 2 ] > locMax && currW[ bb ][ 2 ] <= locTerminal ) // // // if( durVar < maxOffTargetDur ) // okVar = 1 // endif // // // elseif( currW[ bb ][ 2 ] > locTerminal ) // // // okVar = 0 // // // else // if( durVar >= minDur ) // okVar = 1 // endif // endif // if( durVar >= minDur ) okVar = 1 endif // if( okVar == 1 ) // FindLevel/P /Q indexWave1, durVar ; xC = round( V_LevelX ) FindLevel/P /Q indexWave2, currW[ bb ][ 2 ] ; yC = round( V_LevelX ) // // if( xC < dimSize( sdPlot, 0 ) && yC < dimSize( sdPlot, 1 ) && numtype( xC ) == 0 && numtype( yC ) == 0 ) // // if( currW[ bb ][ 2 ] >= 54 && currW[ bb ][ 2 ] < 60 ) // print curr_Str, currW[ bb ][ 2 ], durVar // endif // sdPlot[ xC ][ yC ] += 1 // avgDurBinTxt[ yC ] += num2str(durVar)+";" // insertpoints/m=0 numStates,1 , xW_sdPlot, yW_sdPlot // xW_sdPlot[ numStates ] = durVar yW_sdPlot[ numStates ] = currW[ bb ][ 2 ] // numStates += 1 // // x0_loc = currW[ bb ][ 0 ]; x1_loc = currW[ bb + 1 ][ 0 ] y0_loc = currW[ bb ][ 2 ] // for( yy = 0; yy < dimSize( xyWave, 0 ) ; yy += 1 ) // if( xyWave[ yy ][ 0 ] >= x0_loc && xyWave[ yy ][ 0 ] <= x1_loc && xyWave[ yy ][ 1 ] >= y0_loc - yTol && xyWave[ yy ][ 1 ]<= y0_loc + yTol ) insertpoints/m=0 numPntsxyW, 1, ywFit_sdPlot ywFit_sdPlot[ numPntsxyW ] = xyWave[ yy ][ 1 ] numPntsxyW += 1 //print numPntsxyW endif // endfor // // endif // endif // endFor // endif // // killwaves/z $stringfromlist( 0, S_waveNames, ";" ) // // endif // // endFor // make/o /n = ( yBin+1 ) avgDurBin = 0 make/o /n = ( yBin+1 ) sdDurBin = 0 // for( yy = 0 ; yy < dimsize( avgDurBinTxt, 0 ) ; yy += 1) localStr = avgDurBinTxt[ yy ] make/o/n=( itemsinlist( localStr, ";" ) ) durWBins = 0 for( bb = 0 ; bb < itemsinlist( localStr, ";" ) ; bb += 1 ) durWBins[ bb ] = str2num( stringfromlist( bb, localStr, ";" ) ) endFor wavestats/q /z durWBins avgDurBin[ yy ] = V_Avg sdDurBin[ yy ] = V_sem / 2 endFor // setscale/i x, 0, maxY, avgDurBin, sdDurBin // print numMol, numStates, ": # mol. , # states included." // end function hist1D_DCurtains( xW, yW, minX, maxX, minY, maxY, xBins, yBins ) wave xW, yW variable minX, maxX, minY, maxY, xBins, yBins // variable aa, count = 0 // make/o/n=(0) xW_1dHist, yW_1dHist // for( aa = 0 ; aa < dimSize( xW, 0 ) ; aa += 1 ) if( xW[ aa ] > minX && xW[ aa ] < maxX && yW[ aa ] > minY && yW[ aa ] < maxY ) insertpoints/m=0 count , 1 , xW_1dHist, yW_1dHist xW_1dHist[ count ] = xW[ aa ] yW_1dHist[ count ] = yW[ aa ] count += 1 endif endFor aa = maxX - minX make/o /n =( xBins ) xHist = 0 histogram/b = { minX, aa / xBins, xBins } xW_1dHist, xHist aa = maxY - minY make/o /n =( yBins ) yHist = 0 histogram/b = { minY, aa / yBins, yBins } yW_1dHist, yHist print count, ": # states included." end function stateAnal_DCurtains( yTol, expTime ) variable yTol, expTime // variable numW variable yy, aa, bb variable xC, yC variable durVar variable numMol = 0, numStates = 0 variable numPntsxyW = 0, intSum = 0, nPntsState variable x0_loc, x1_loc, y0_loc, y1_loc // string curr_Str, localStr , xyWnameStr // killPath/z resPath_sdPlot NewPath/M="Define directory, containg results"/Q/Z resPath_sdPlot if( V_flag != 0 ) abort "Path was not defined." else pathinfo resPath_sdPlot print S_path, ": path to results folder." endif // localStr = indexedFIle ( resPath_sdPlot , -1 , "????" ) // list of kymogram names localStr = RemoveFromList(".DS_Store", localStr, ";" ) localStr = RemoveFromList("display_and_comments.txt;metadata.txt", localStr, ";" ) localStr = SortList( localStr, ";", 16 ) // numW = itemsinlist( localStr, ";" ) // make/o /n = 0 durW_out, avgIntW_out, sumIntW_out // for( aa = 0 ; aa < numW ; aa += 1 ) // curr_Str = stringfromlist( aa , localStr, ";" ) // if( stringmatch( curr_Str, "selSt_*" ) == 1 ) // numMol += 1 // xyWnameStr = "gFitRes" // for( yy = 1 ; yy < itemsinlist( curr_Str, "_" ) ; yy += 1 ) // xyWnameStr += "_"+stringFromList( yy, curr_Str, "_" ) // endfor // LoadWave/H /Q /P= resPath_sdPlot /O xyWnameStr // gFit results wave print xyWnameStr // Duplicate/o $stringfromlist( 0, S_waveNames, ";" ) , xyWave // killwaves/z $stringfromlist( 0, S_waveNames, ";" ) // LoadWave/H /Q /P= resPath_sdPlot /O curr_Str // slected stateInfo Wave print curr_Str // wave/z currW = $stringfromlist( 0, S_waveNames, ";" ) // if( mod( dimSize( currW, 0 ) , 2 ) == 0 && dimSize( currW, 1 ) == 3 && dimSize( currW, 0 ) > 1 ) // for( bb = 0 ; bb + 1 < dimSize( currW, 0 ) ; bb += 2 ) // if( bb + 1 >= dimSIze( currW, 0 ) ) abort endif // intSum = 0 nPntsState = 0 // x0_loc = currW[ bb ][ 0 ]; x1_loc = currW[ bb + 1 ][ 0 ] y0_loc = currW[ bb ][ 2 ] // for( yy = 0; yy < dimSize( xyWave, 0 ) ; yy += 1 ) // scan individual state // if( xyWave[ yy ][ 5 ] >= x0_loc && xyWave[ yy ][ 5 ] <= x1_loc && xyWave[ yy ][ 3 ] >= y0_loc - yTol && xyWave[ yy ][ 3 ]<= y0_loc + yTol ) // if( nPntsState == 0 ) intSum = xyWave[ yy ][ 0 ] * max( xyWave[ yy ][ 2 ] , xyWave[ yy ][ 4 ] ) //amp * xw * yw else intSum += xyWave[ yy ][ 0 ] * max ( xyWave[ yy ][ 2 ] , xyWave[ yy ][ 4 ] ) //amp * xw * yw endif // nPntsState += 1 // endif // endfor // insertpoints/m=0 numStates, 1, avgIntW_out, sumIntW_out, durW_out // avgIntW_out[ numStates ] = intSum / nPntsState sumIntW_out[ numStates ] = intSum durW_out[ numStates ] = ( currW[ bb + 1 ][ 0 ] - currW[ bb ][ 0 ] ) * expTime // numStates += 1 // endFor // endif // killwaves/z $stringfromlist( 0, S_waveNames, ";" ) // endif // endFor // print numMol, numStates, ": # kymograms. , # states included." print "names of important waves: durW_out, avgIntW_out, sumIntW_out" // end //function analyseKymogram_DCurtains( inW, threshVal, minDurVal, ballSizeVar ) // wave inW // variable threshVal, minDurVal, ballSizeVar // // variable aa // // if( dimSize( inW, 2 ) > 1 ) // ImageTransform/O rgb2gray inW // endif // // subtractBackround( inW, ballSizeVar ) // ballsize >= 4 works well, the smaller the better. // // MatrixFilter/N=(3)/P=2 gauss inW // // abort // // make/o /n=( dimsize( inW, 1 ) ) cropedW // // //make/o/n=( 0,2 ) // // for( aa = 0 ; aa < dimsize( inW, 0 ) ; aa += 1 ) // // cropedW[ ] = inW[ aa ][ p ] // // FindLevels /B=5 /M=(minDurVal) /P /Q cropedW, threshVal // wave W_FindLevels // // if( V_LevelsFound > 1 ) // // print aa // // abort // // endif // // endFor // //end //function drawDNAs_DCurtains( ) // // wave roiCoordsW // // variable pp, lengthVar // // NVAR currDNAGVar // // SetDrawLayer/w=cropedDC_wind /K UserFront // // for( pp = 0; pp < dimSize( roiCoordsW, 0 ) ; pp += 1 ) // // // if( pp != currDNAGVar ) // // // SetDrawLayer/w=cropedDC_wind UserFront // SetDrawEnv/w=cropedDC_wind linefgc= (65535,65535,0),fillpat= 0,xcoord= top,ycoord= left, save // // // else // // // SetDrawLayer/w=cropedDC_wind UserFront // SetDrawEnv/w=cropedDC_wind linefgc= (65535,0,0),fillpat= 0,xcoord= top,ycoord= left, save // // // endif // // // lengthVar = round( sqrt( ( roiCoordsW[pp][2] - roiCoordsW[pp][0] )^2 +( roiCoordsW[pp][3] - roiCoordsW[pp][1] )^2) ) // // // DrawLine /W=cropedDC_wind roiCoordsW[pp][0], roiCoordsW[pp][1], roiCoordsW[pp][2], roiCoordsW[pp][3] // DrawText /W=cropedDC_wind roiCoordsW[pp][0], roiCoordsW[pp][1], num2str(pp) + ", " +num2str(lengthVar) // // // endFor // // //end // // //function alignManyDir_DCurtains( parmW, numImg ) // wave parmW // variable numImg // // string imagesNamesSTR // variable aa, bb // // // path to folder containing DNA channel images // killPath/z dnaChPath // NewPath/M="Define directory, containg DNA ch. images"/Q/Z dnaChPath // if( V_flag != 0 ) // abort "Path was not defined." // else // pathinfo dnaChPath // print S_path, ": path to DNA ch." // endif // // // path to results folder // killPath/z resPath // NewPath/M="Define results directory"/Q/Z resPath // if( V_flag != 0 ) // abort "Path was not defined." // else // pathinfo resPath // print S_path, ": path to results" // endif // // // // imagesNamesSTR = indexedFIle ( dnaChPath , -1 , "????" ) // list of DNA channel images names // imagesNamesSTR= RemoveFromList(".DS_Store", imagesNamesSTR, ";" ) // imagesNamesSTR= RemoveFromList("display_and_comments.txt;metadata.txt", imagesNamesSTR, ";" ) // imagesNamesSTR = SortList( imagesNamesSTR, ";", 16 ) // // for( aa = 0; aa < itemsinlist( imagesNamesSTR, ";" ) ; aa += 1 ) // // // for( bb = 0 ; bb < numImg ; bb += 1 ) // // load image // ImageLoad/Q /T=tiff /O /S=(bb) /C=1 /N=image /P = dnaChPath stringfromlist( aa, imagesNamesSTR, ";" ) // wave/z tempW = $stringfromlist(0, S_waveNames, ";") // // if( bb == 0 ) // Duplicate/O tempW, avgW // killwaves/z $stringfromlist(0, S_waveNames, ";") // else // avgW += tempW // killwaves/z $stringfromlist(0, S_waveNames, ";") // endif // // endfor // // // // avgW /= numImg // // // // print stringfromlist( aa, imagesNamesSTR, ";" ) // // // align image // alignImage_DCurtains( avgW ) // // save the aligned image // ImageSave/O/D=16/T="TIFF"/P=resPath avgW as stringfromlist( aa, imagesNamesSTR, ";" ) // // // endfor // //end