Hello,
I have create a macro to help me quickly change "Set scale..." values, when handling with different scaled images. It is very specific for my set up, but should be easy enough to edit it to other needs (although you have to edit the code directly). It is similar to Microscope_Scale plugin. Basically, it is a dialog where you choose your equipment (e.g. compound scope model, stereoscope... - in this case more than 1 equipment) and a second dialog with an array of magnifications available to be selected (specific of that chosen equipment). However, when I first thought about this macro I considered it as a one-dialog process, where the selection of the equipment array would change the second array on the run, within the same dialog. So, I wonder: 1- Is it possible to make this "2 dialog" into a 1 dynamic dialog, where the first array defines what is being shown in the second array, before hitting "ok"? 2- Any hints and improvements in the code and/or functionality are really welcome! I'm using it as a toolset, so just copy-paste and save it as a .txt (or download it<http://marcus.ib.usp.br/nelas/mestrado/wp-content/uploads/quick-set-scale.txt>) into the "/ImageJ/macros/toolsets" folder, and restart imagej. http://marcus.ib.usp.br/nelas/mestrado/wp-content/uploads/quick-set-scale.txt macro "Unused Tool-1 - " {} // leave slot between text tool and magnifying > glass unused > > // Quick Set Scale v0.99 - 15/10/2007 > // Copyleft - Bruno C. Vellutini [[hidden email]] > // Macro specific for Compound Microscope Zeiss Axioplan2 and Stereoscope > Zeiss Stemi SV11 APO > // with photos taken with a Nikon Coolpix 4500 camera (max zoom) > // If you are using this macro you need to input your own values > // specific for your scope and camera set up > > macro "Quick Set Scale Action Tool - > C037L1cfcL1a1eLfafeL8b8dL5b5dLbbbdT0707qT4707uT8707iTa707cTe707k" { > Dialog.create("Quick Set Scale"); > // Write the name of the equipments you want to quickly set scale in > the array below > Dialog.addChoice("Equipment:", newArray("Microscópio Zeiss Axioplan2", > "Lupa Zeiss Stemi SV11 APO")); > Dialog.show(); > equip = Dialog.getChoice(); > // Options for Axioplan2 > if (equip=="Microscópio Zeiss Axioplan2") { > Dialog.create("Microscópio Zeiss"); > // Write the magnifications available for your equipment > Dialog.addChoice("Objective:", newArray("2.5x", "10x", "20x", > "40x", "100x")); > Dialog.show(); > scale = Dialog.getChoice(); > // Input distance values for each magnification > if (scale=="2.5x") { > run("Set Scale...", "distance=1 known=2.0450 pixel=1 > unit=micron global"); > } > if (scale=="10x") { > run("Set Scale...", "distance=1 known=0.5277 pixel=1 > unit=micron global"); > } > if (scale=="20x") { > run("Set Scale...", "distance=1 known=0.2571 pixel=1 > unit=micron global"); > } > if (scale=="40x") { > run("Set Scale...", "distance=1 known=0.1333 pixel=1 > unit=micron global"); > } > if (scale=="100x") { > run("Set Scale...", "distance=1 known=0.05255 pixel=1 > unit=micron global"); > } > } > // End of Axioplan2 > // Options for Stereoscope. Same rules, different values. > if (equip=="Lupa Zeiss Stemi SV11 APO") { > Dialog.create("Lupa Zeiss"); > Dialog.addChoice("Objective:", newArray("0.6x", "0.8x", "1.0x", " > 1.2x", "1.6x", "2.0x", "2.5x", "3.2x", "4.0x", "5.0x", "6.6x")); > Dialog.show(); > scale = Dialog.getChoice(); > if (scale=="0.6x") { > run("Set Scale...", "distance=1 known=5.788712012 pixel=1 > unit=micron global"); > } > if (scale=="0.8x") { > run("Set Scale...", "distance=1 known=4.246284501 pixel=1 > unit=micron global"); > } > if (scale=="1.0x") { > run("Set Scale...", "distance=1 known=3.318620781 pixel=1 > unit=micron global"); > } > if (scale=="1.2x") { > run("Set Scale...", "distance=1 known=2.631509697 pixel=1 > unit=micron global"); > } > if (scale=="1.6x") { > run("Set Scale...", "distance=1 known=2.087682672 pixel=1 > unit=micron global"); > } > if (scale=="2.0x") { > run("Set Scale...", "distance=1 known=1.680672269 pixel=1 > unit=micron global"); > } > if (scale=="2.5x") { > run("Set Scale...", "distance=1 known=1.353784505 pixel=1 > unit=micron global"); > } > if (scale=="3.2x") { > run("Set Scale...", "distance=1 known=1.06835324 pixel=1 > unit=micron global"); > } > if (scale=="4.0x") { > run("Set Scale...", "distance=1 known=0.850340136 pixel=1 > unit=micron global"); > } > if (scale=="5.0x") { > run("Set Scale...", "distance=1 known=0.661371287 pixel=1 > unit=micron global"); > } > if (scale=="6.6x") { > run("Set Scale...", "distance=1 known=0.506072874 pixel=1 > unit=micron global"); > } > } > // End of Stereoscope > } > cheers! Bruno -- Bruno C. Vellutini [organelas.com] Centro de Biologia Marinha (CEBIMar) Universidade de São Paulo Av. Manoel H. do Rego km 131,5 11600-000 São Sebastião, SP, Brasil http://www.usp.br/cbm/ |
Hmm, not sure I can help you too much with the programming. With
macros, I don't know of any way to do that, but with plugins you can use listeners. I know little about listeners, but I know that the Image->Resize command uses them to do pretty much exactly what you want to do, and you could look at that as an example. Basically, the listener watches for some specific user action, then executes some code which changes the dialog. However, I see that you're using Zeiss equipment. If you save the files as .zvi then the scale is stored in the file. You can use the Bio-Formats plugin ( http://www.loci.wisc.edu/ome/formats.html ) to load the files. When the file is loaded, it automatically sets the scale in ImageJ which is about as quick as it gets. I find this very convienient since I don't have to export the images, it keeps all of my channels in a single file, the scale is already set, and, possibly most importantly, it records all of my settings (exposure, magnification etc.). Justin On 10/15/07, NeLaS <[hidden email]> wrote: > Hello, > > I have create a macro to help me quickly change "Set scale..." values, when > handling with different scaled images. It is very specific for my set up, > but should be easy enough to edit it to other needs (although you have to > edit the code directly). It is similar to Microscope_Scale plugin. > > Basically, it is a dialog where you choose your equipment (e.g. compound > scope model, stereoscope... - in this case more than 1 equipment) and a > second dialog with an array of magnifications available to be selected > (specific of that chosen equipment). However, when I first thought about > this macro I considered it as a one-dialog process, where the selection of > the equipment array would change the second array on the run, within the > same dialog. So, I wonder: > > 1- Is it possible to make this "2 dialog" into a 1 dynamic dialog, where the > first array defines what is being shown in the second array, before hitting > "ok"? > > 2- Any hints and improvements in the code and/or functionality are really > welcome! > > I'm using it as a toolset, so just copy-paste and save it as a .txt > (or download > it<http://marcus.ib.usp.br/nelas/mestrado/wp-content/uploads/quick-set-scale.txt>) > into the "/ImageJ/macros/toolsets" folder, and restart imagej. > > http://marcus.ib.usp.br/nelas/mestrado/wp-content/uploads/quick-set-scale.txt > > macro "Unused Tool-1 - " {} // leave slot between text tool and magnifying > > glass unused > > > > // Quick Set Scale v0.99 - 15/10/2007 > > // Copyleft - Bruno C. Vellutini [[hidden email]] > > // Macro specific for Compound Microscope Zeiss Axioplan2 and Stereoscope > > Zeiss Stemi SV11 APO > > // with photos taken with a Nikon Coolpix 4500 camera (max zoom) > > // If you are using this macro you need to input your own values > > // specific for your scope and camera set up > > > > macro "Quick Set Scale Action Tool - > > C037L1cfcL1a1eLfafeL8b8dL5b5dLbbbdT0707qT4707uT8707iTa707cTe707k" { > > Dialog.create("Quick Set Scale"); > > // Write the name of the equipments you want to quickly set scale in > > the array below > > Dialog.addChoice("Equipment:", newArray("Microscópio Zeiss Axioplan2", > > "Lupa Zeiss Stemi SV11 APO")); > > Dialog.show(); > > equip = Dialog.getChoice(); > > // Options for Axioplan2 > > if (equip=="Microscópio Zeiss Axioplan2") { > > Dialog.create("Microscópio Zeiss"); > > // Write the magnifications available for your equipment > > Dialog.addChoice("Objective:", newArray("2.5x", "10x", "20x", > > "40x", "100x")); > > Dialog.show(); > > scale = Dialog.getChoice(); > > // Input distance values for each magnification > > if (scale=="2.5x") { > > run("Set Scale...", "distance=1 known=2.0450 pixel=1 > > unit=micron global"); > > } > > if (scale=="10x") { > > run("Set Scale...", "distance=1 known=0.5277 pixel=1 > > unit=micron global"); > > } > > if (scale=="20x") { > > run("Set Scale...", "distance=1 known=0.2571 pixel=1 > > unit=micron global"); > > } > > if (scale=="40x") { > > run("Set Scale...", "distance=1 known=0.1333 pixel=1 > > unit=micron global"); > > } > > if (scale=="100x") { > > run("Set Scale...", "distance=1 known=0.05255 pixel=1 > > unit=micron global"); > > } > > } > > // End of Axioplan2 > > // Options for Stereoscope. Same rules, different values. > > if (equip=="Lupa Zeiss Stemi SV11 APO") { > > Dialog.create("Lupa Zeiss"); > > Dialog.addChoice("Objective:", newArray("0.6x", "0.8x", "1.0x", " > > 1.2x", "1.6x", "2.0x", "2.5x", "3.2x", "4.0x", "5.0x", "6.6x")); > > Dialog.show(); > > scale = Dialog.getChoice(); > > if (scale=="0.6x") { > > run("Set Scale...", "distance=1 known=5.788712012 pixel=1 > > unit=micron global"); > > } > > if (scale=="0.8x") { > > run("Set Scale...", "distance=1 known=4.246284501 pixel=1 > > unit=micron global"); > > } > > if (scale=="1.0x") { > > run("Set Scale...", "distance=1 known=3.318620781 pixel=1 > > unit=micron global"); > > } > > if (scale=="1.2x") { > > run("Set Scale...", "distance=1 known=2.631509697 pixel=1 > > unit=micron global"); > > } > > if (scale=="1.6x") { > > run("Set Scale...", "distance=1 known=2.087682672 pixel=1 > > unit=micron global"); > > } > > if (scale=="2.0x") { > > run("Set Scale...", "distance=1 known=1.680672269 pixel=1 > > unit=micron global"); > > } > > if (scale=="2.5x") { > > run("Set Scale...", "distance=1 known=1.353784505 pixel=1 > > unit=micron global"); > > } > > if (scale=="3.2x") { > > run("Set Scale...", "distance=1 known=1.06835324 pixel=1 > > unit=micron global"); > > } > > if (scale=="4.0x") { > > run("Set Scale...", "distance=1 known=0.850340136 pixel=1 > > unit=micron global"); > > } > > if (scale=="5.0x") { > > run("Set Scale...", "distance=1 known=0.661371287 pixel=1 > > unit=micron global"); > > } > > if (scale=="6.6x") { > > run("Set Scale...", "distance=1 known=0.506072874 pixel=1 > > unit=micron global"); > > } > > } > > // End of Stereoscope > > } > > > > > cheers! > > Bruno > > -- > Bruno C. Vellutini > [organelas.com] > > Centro de Biologia Marinha (CEBIMar) > Universidade de São Paulo > Av. Manoel H. do Rego km 131,5 > 11600-000 São Sebastião, SP, Brasil > http://www.usp.br/cbm/ > |
Free forum by Nabble | Edit this page |