//Kalen edits //12/1/14 added option for Nothing Markers in previous images //12/2/14 changed ("SpineWithInhibitorySynapse" category names //12/5/14 added error checking to the alignment option; // 1/7/14 added stats result window showing number objects and image start stop points //2/23/15 changed C button to turn channels on or off only //Vars have to be defined at the top of the file, else some hard to fix errors occur. //variable below saves Z state var Zext = 0; var ALock = 0; var tempSave = 0; //Variables here are for Emad's functions below var alignMe = newArray(); var theOrigin = -1; var alignmentOption = ""; var applyMarkersToPrevious = "Yes"; //Gets the toolbar ready for objectJ analysis macro "Lock Alt Key On or Off for Scrolling ESC aborts Action Tool - C037T0b11AT8b09cTcb09t" { run("Action Bar","/plugins/ActionBar/_Kalensbar.txt"); } macro "Count object types in each image in the current object file Action Tool - C037T0b11CT8b09nTcb09t" { Landmark=0; SpineWithPSD=0; InhibitoryShaft=0; SpineWithInhibitorySynapse=0; NudeSpine=0; Nothing=0; lastLandmarkImage=0; markers = newArray("Landmark","SpineWithPSD","InhibitoryShaft","SpineWithInhibitorySynapse","NudeSpine","Nothing"); valArray= newArray(Landmark,SpineWithPSD,InhibitoryShaft,SpineWithInhibitorySynapse,NudeSpine,Nothing); imageTemp=1; for (n=1;n<=ojNObjects();n++){ column="Landmark_X"; if( ojResult(column,ojIndexToRow(n)) >0){ lastLandmarkImage++; } for(markTypeNum=0;markTypeNum<6;markTypeNum++){ column=markers[markTypeNum]+"_X"; if( ojResult(column,ojIndexToRow(n)) >0){ valArray[markTypeNum]=valArray[markTypeNum]+1; } } if(n==ojLastObject(imageTemp)){ setResult("First Object", imageTemp-1, ojFirstObject(imageTemp)); setResult("Last Object", imageTemp-1, ojLastObject(imageTemp)); setResult("Last Landmark Object", imageTemp-1, lastLandmarkImage); for(markTypeNum=0;markTypeNum<6;markTypeNum++){ setResult(markers[markTypeNum]+"#", imageTemp-1, valArray[markTypeNum]); } setResult("Label",imageTemp-1,ojGetImageName(imageTemp)); //Reseting for the next image imageTemp++; lastLandmarkImage=n; valArray= newArray(Landmark,SpineWithPSD,InhibitoryShaft,SpineWithInhibitorySynapse,NudeSpine,Nothing); } } IJ.renameResults("Synaptic Counts Per Image") } macro "Go to Object Action Tool - C037O00aaL99ff" { //This finds markers based on what they are labeled as on an image //if (isKeyDown("shift")) ojnum=getNumber("Go to Object # on all sessions ", 0); currentimage=ojImageLink(); firstoncurrentimage=ojFirstObject(currentimage); zoom=getZoom(); //print("after get zoom"); totalimages=ojNImages(); for (n=1; n<=totalimages; n=n+1){ firstonimage=ojFirstObject(n); relativeid=ojnum+firstonimage-1; // the below makes sure this isnt the image I was on, that it is open, and that it has the mark I want. if (n != currentimage && ojGetImageValue(n, "ID")!=0 && ojLastObject(n)>=relativeid) { //ojShowImage(n); ojShowObject(relativeid); yoj=ojYPos(1); xoj=ojXPos(1); ojZoom(zoom,xoj,yoj); } } // To return the view to the start ojShowImage(currentimage); ojShowObject(ojnum+firstoncurrentimage-1); yoj=ojYPos(1); xoj=ojXPos(1); ojZoom(zoom,xoj,yoj); } macro "Set all channels Action Tool - C059T3e16C" { //This finds markers based on what they are labeled as on an image currentimage=ojImageLink(); var min=newArray(3); var max=newArray(3); ok = getBoolean("The display range of the current\n" +"image will be propagated to all open images."); if (!ok) exit(); for (i=0; i<3; i++){ Stack.setChannel(i+1); getMinAndMax(min[i], max[i]); } totalimages=ojNImages(); for (n=1; n<=totalimages; n=n+1){ if (n != currentimage) { ojShowImage(n); for (i=0; i<3; i++){ Stack.setChannel(i+1); setMinAndMax(min[i], max[i]); } } } // To return the view to the start ojShowImage(currentimage); Stack.setChannel(2) ; } //These are EMADS tools to do alignment inside ImageJ //These are EMADS tools to do alignment inside ImageJ macro "Align select images Action Tool - C059T3e16A " { var alignMeStr = ""; var numAlignErrorBool=false; var numAlignErrorString = ""; while (alignMe.length == 0 || theOrigin == -1) { // turn alignMe into a string for (anI = 0; anI < alignMe.length-1; anI++) { alignMeStr = alignMeStr + alignMe[anI] + ","; } if (alignMe.length != 0) { alignMeStr = alignMeStr + alignMe[alignMe.length-1]; } showMessage("Error", "You haven't designated images that you want to align, or you haven't chosen an origin. Fix that."); // prompt for values //KB removed need for 0 indexing var alignChoices = newArray("No", "Yes"); Dialog.create("Set origin and images to align"); Dialog.addNumber("Number of origin image", theOrigin); Dialog.addString("Comma separated values of images to align ie 1,2,3,4", alignMeStr, 24); Dialog.addChoice("Overwrite non Landmark points in non Origin images above?", alignChoices, alignmentOption); Dialog.addChoice("Place empty markers in previous sessions?", alignChoices, applyMarkersToPrevious); Dialog.show(); theOrigin = Dialog.getNumber(); alignMe = split(Dialog.getString(), ","); alignmentOption = Dialog.getChoice(); applyMarkersToPrevious = Dialog.getChoice(); } for (anI = 0; anI < alignMe.length; anI++) { // turn alignMe into a string that doesn't end in a comma if (anI==alignMe.length){ alignMeStr = alignMeStr + alignMe[anI]; }else{ alignMeStr = alignMeStr + alignMe[anI] + ","; } } // confirm that the assumption of the origin having the most possible landmarks is true numOrigin=ojLastObject(theOrigin)-ojFirstObject(theOrigin)+1; //error check for origin length for(i=1;i<=ojNImages();i++){ numAlign=ojLastObject(i)-ojFirstObject(i)+1; if(numAlign>numOrigin){ numAlignErrorString=numAlignErrorString+ i + ","; numAlignErrorBool=true; } } if (numAlignErrorBool){ showMessageWithCancel("Potential Error","The following list of images have more objects than the origin you specified.\n " +"If any of these images are ones you wanted to align to, they will be deleted if you press ok.\n " +"If the image is not in your list to align, but you have enabled the place empty markers in previous sessions, " +"I haven't found an issue...YET. \n" +"I would think about whatever you thought you were going to do if I were you. " +"Pressing Cancel will not alter your project. \n\n" +"Images with more objects than the origin you chose are: " +numAlignErrorString); } // ask the user for some confirmation if (getBoolean("You are about to align the following images: [" + alignMeStr + "] with image number " + theOrigin + " as the origin. Are you sure?")) { run("ptReg ", "command=doAlign align="+ alignMeStr + " origin=" + theOrigin + " overwrite=" + alignmentOption+ " emptyMarkers="+ applyMarkersToPrevious); showMessage("done"); } } macro "Align select images Action Tool Options" { // turn alignMe into a string var alignMeStr = ""; for (anI = 0; anI < alignMe.length-1; anI++) { alignMeStr = alignMeStr + alignMe[anI] + ","; } if (alignMe.length != 0) { alignMeStr = alignMeStr + alignMe[alignMe.length-1]; } var alignChoices = newArray("No", "Yes"); var alignChoices2 = newArray("No", "Yes"); Dialog.create("Set origin and images to align"); Dialog.addNumber("Number of origin image", theOrigin); Dialog.addString("Comma separated values of images to align", alignMeStr, 24); Dialog.addChoice("Overwrite non Landmark points in non Origin images above?", alignChoices, alignmentOption); Dialog.addChoice("Place empty markers in previous sessions?", alignChoices2, applyMarkersToPrevious); Dialog.show(); theOrigin = Dialog.getNumber(); alignMe = split(Dialog.getString(), ","); alignmentOption = Dialog.getChoice(); applyMarkersToPrevious = Dialog.getChoice(); } macro "Extend Z Action Tool - C059T3e16Z " { if (Zext == 0){ Zext = 1; numberper=getNumber("Value visible +- marked Z plane : ", 1); ojExtendVisibilityDepth(numberper, numberper); } else { Zext = 0; ojExtendVisibilityDepth(0, 0); } } macro "Open and or move all other images in project to same location as current image Action Tool - C059T3e16S " { currentimage=ojImageLink(); totalimages=ojNImages(); getLocationAndSize(x, y, width, height); for (n=1; n<=totalimages; n=n+1){ if (n != currentimage) { ojShowImage(n); wait(15); setLocation(x, y); } } }