diff --git a/Microscope Meas. - Calibration instructions.pdf b/Microscope Meas. - Calibration instructions.pdf deleted file mode 100644 index 52a30c8..0000000 Binary files a/Microscope Meas. - Calibration instructions.pdf and /dev/null differ diff --git a/README.md b/README.md index d8d3c2c..7c72b5b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Microscope-Measurement-Tools -Microscope Measurement plugin for [FIJI](http://fiji.sc). +Microscope Measurement plugin for [FIJI](http://fiji.sc) This set of [FIJI](http://fiji.sc) plugins provides a quick way to save distance/length calibrations for various microscopes/objectives in a simple text file, and then draw calibrated distances onto your images. @@ -19,7 +19,7 @@ The "Draw Measurement" plugin then allows you to draw a line with the calibrated 1. Download and install the [scientific image analysis program FIJI](http://fiji.sc) 1. Download the most recent [Microscope Tools Release from Github](https://github.com/Elaniobro/Microscope-Measurement-Tools/releases/tag/v2.4) 1. Extract/Unzip the file you downloaded from Github called: `Microscope-Measurment-tools` - 1. Move the folder into the FIJI plugins directory on your MacOS + 1. Move the folder contents (or just the plugins and macros directories) into the FIJI directory (Fiji.app). When prompted, choose to overwrite the file StartupMacros.fiji.ijm **note** _MacOS may prevent you from opening an unverified application follow steps below to open_ @@ -30,55 +30,60 @@ The "Draw Measurement" plugin then allows you to draw a line with the calibrated ## ⚖️ Calibration 1. Take photos of a known measurment sample with your microscope, at each magnification you want to calibrate 1. Open FIJI -1. Open an image file taken at the desired maginification with a measurment marker. e.g. Open a photo of your micrometer slide taken with your 40x objective -1. Zoom in on the photo to view the micrometer scale +1. Open an image file taken at the desired maginification with a measurment marker. e.g. Open a photo of a micrometer slide +1. Zoom in on the photo to view the scale 1. Draw a line `ROI` (Region Of Interest) along the calibration measurment feature. e.g. along the micrometer 1. Navigate to and select `Analyze > Set Scale` 1. The "Distance in Pixels" will already be set by your line ROI -1. Type in the "Known Distance" from your measurement feature, mine is 5μm -1. Record the resulting "Scale" value, e.g. 31.1716 pixel/unit, where unit is cm, mm, μm, etc -1. The "Scale" value will be used in your `Microscope_Calibrations_user_settings.py` file, so recored both a name and the scale value. e.g: - ``` - Swift 350T 4x: 0.9058 px/μm - Swift 350T 10x: 1.81 px/μm - Swift 350T 40X: 12.5455 px/μm - Swift 350T 100X: 31.1716 px/μm - ``` - **_these are just dummy values_** -1. Open up `/Applications/Fiji.app/plugins/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py` in your IDE (Integrated Deelopment Environment) -1. Edit the `names` list to reflect the name of each calibration on line 21: - ``` - names = [ - 'Swift 350T 4x', - 'Swift 350T 10x', - 'Swift 350T 40x', - 'Swift 350T 100x', - ] - ``` -1. Edit the `cals` list to reflect the corresponding `pixel-per-unit` calibration for each setting, from your previous records, on line 30: - ``` - cals = [ - 0.9058, - 1.81, - 12.5455, - 31.1716, - ] - ``` -1. Quit FIJI -1. Re-start the FIJI application. This will allow the application to register the changes you made to the plugin -**note** _for any subsquent changes, you will have to save the file, quit the application and re-open it to see the changes_ -1. Open an image -1. Run `Analyze > Microscope Measurment Tools > Choose Microscope Calibration` and see a pop-up window that shows the new names and calibration values you set in `Microscope_Calibrations_user_settings.py`. -1. You may also apply the same scale and scale bar to all images you have open, but selecting the checkboxes. Doing so will open another pop-up, where you can see how the scale will look. In the example below, the bar is set to 10μm, white text and placed in the lower right corner - +1. Type in the "Known Distance" from your measurement feature +1. (Optional) Check 'Global' to apply this same scale to all images opened during this session +1. (Optional) Add the scale as a preset that can be accessed at Plugins\Analyze\Microscope Measurement Tools\Choose Microscope Calibration (F1) + 1. Record the resulting "Scale" value, e.g. 31.1716 pixel/unit, where unit is cm, mm, μm, etc + 1. The "Scale" value will be used in your `Microscope_Calibrations_user_settings.py` file, so recored both a name and the scale value. e.g: + ``` + Swift 350T 4x: 0.9058 px/μm + Swift 350T 10x: 1.81 px/μm + Swift 350T 40X: 12.5455 px/μm + Swift 350T 100X: 31.1716 px/μm + ``` + **_these are just dummy values_** + 1. Open up `/Fiji.app/plugins/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py` in your preferred text editor or python IDE + 1. Edit the `names` list to reflect the name of each calibration on line 21: + ``` + names = [ + 'Swift 350T 4x', + 'Swift 350T 10x', + 'Swift 350T 40x', + 'Swift 350T 100x', + ] + ``` + 1. Edit the `cals` list to reflect the corresponding `pixel-per-unit` calibration for each setting, from your previous records, on line 30: + ``` + cals = [ + 0.9058, + 1.81, + 12.5455, + 31.1716, + ] + ``` + 1. Save the file, and delete the file "Microscope_Calibrations_user_settings$py.pyclass" (if present) + 1. Quit FIJI + 1. Re-start the FIJI application. This will allow the application to register the changes you made to the plugin + **note** _for any subsquent changes, you will have to repeat the last three steps to see the changes_ ## 📈 Usage -Three files are included, which will show up in your FIJI "Analyze" menu: +Several files are included, which will show up at Plugins\Analyze\Microscope Measurement Tools. Shortcuts are also added to the tool bar. + **Choose_Microscope_Calibration.py** - + *Opens the "Choose Calibration" window, for setting the measurement scale to a preconfigured value.* + + *Opens the "Choose Calibration" window, for setting the measurement scale to a preconfigured value (hotkey F1)* + **Draw_Measurement_-_Line.py** - + *Converts a Line ROI into a drawn annotation with the measurement length indicated.* + + *Converts a Line ROI into a drawn annotation with the measurement length indicated* ++ **Draw_Rectangle_Long_Length.py** + + *Adds a drawn annotation of the length of a rectangle ROI along the long side (hotkey 'q')* ++ **Draw_Rectangle_Short_Length.py** + + *Adds a drawn annotation of the length of a rectangle ROI along the short side (hotkey 'g')* ++ **Draw_Rectangle_Length_x_Width.py** + + *Adds a drawn annotation of the length and width of a rectangle ROI (hotkey 'u')* + **Microscope_Calibrations_user_settings.py** + *User-editable Settings file that contains your pre-configured scale calibrations, along with settings for drawing annotations (background/text color etc.)* @@ -86,12 +91,11 @@ Three files are included, which will show up in your FIJI "Analyze" menu: View the [How-To Calibrate an Ocular Micrometer](https://www.youtube.com/watch?v=HaqgCtA-ioI&t=738s) ## 📐 Making + Drawing measurements -Select the Menu Item `Plugins > Analyze > Microscope Measurement Tools > Choose Microscope Calibration`, and select your microscope/objective from the resulting list. The pixel scale will be applied. +(Recommended) Set a scale either manually using the procedure outlined in the 'Calibration' Section, or from the presets by going to `Plugins > Analyze > Microscope Measurement Tools > Choose Microscope Calibration` (F1) -You can now drag a Line (or other type of ROI) on any feature, and the FIJI toolbar will show you the measurement dynamically. Other FIJI functions can now also be used for calibrated measurements (areas etc.). - -To draw this measurement on your image, drag the Line to the desired location, and select the menu item `Plugins > Analyze > Microscope Measurement Tools > Draw Measurement - Line` +You can now drag a Line or Rectangle (or other type of ROI) on any feature, and the FIJI toolbar will show you the measurement dynamically. Other FIJI functions can now also be used for calibrated measurements (areas etc.). +To draw this measurement on your image, drag the Line or Rectangle at the desired location, and select the desired measurement from `Plugins > Analyze > Microscope Measurement Tools`, click the toolbar icon, or type the hotkey (details for each measurement option are in 'Usage' section) ## 🔧 Custom Calibration Functions A custom function can be added to the list of available calibrations (as opposed to a static scale value). A sub-folder is included showing an example of how to do this. The example is for a JEOL SEM (scanning electron microscope), and the example function will determine the scale of the SEM image by parsing an accompanying text file. diff --git a/macros/StartupMacros.fiji.ijm b/macros/StartupMacros.fiji.ijm new file mode 100644 index 0000000..7ad78f6 --- /dev/null +++ b/macros/StartupMacros.fiji.ijm @@ -0,0 +1,301 @@ +// "StartupMacros" +// The macros and macro tools in this file ("StartupMacros.txt") are +// automatically installed in the Plugins>Macros submenu and +// in the tool bar when ImageJ starts up. + +// About the drawing tools. +// +// This is a set of drawing tools similar to the pencil, paintbrush, +// eraser and flood fill (paint bucket) tools in NIH Image. The +// pencil and paintbrush draw in the current foreground color +// and the eraser draws in the current background color. The +// flood fill tool fills the selected area using the foreground color. +// Hold down the alt key to have the pencil and paintbrush draw +// using the background color or to have the flood fill tool fill +// using the background color. Set the foreground and background +// colors by double-clicking on the flood fill tool or on the eye +// dropper tool. Double-click on the pencil, paintbrush or eraser +// tool to set the drawing width for that tool. +// +// Icons contributed by Tony Collins. + +// Global variables +var pencilWidth=1, eraserWidth=10, leftClick=16, alt=8; +var brushWidth = 10; //call("ij.Prefs.get", "startup.brush", "10"); +var floodType = "8-connected"; //call("ij.Prefs.get", "startup.flood", "8-connected"); + +// The macro named "AutoRunAndHide" runs when ImageJ starts +// and the file containing it is not displayed when ImageJ opens it. + +// macro "AutoRunAndHide" {} + +function UseHEFT { + requires("1.38f"); + state = call("ij.io.Opener.getOpenUsingPlugins"); + if (state=="false") { + setOption("OpenUsingPlugins", true); + showStatus("TRUE (images opened by HandleExtraFileTypes)"); + } else { + setOption("OpenUsingPlugins", false); + showStatus("FALSE (images opened by ImageJ)"); + } +} + +UseHEFT(); + +// The macro named "AutoRun" runs when ImageJ starts. + +macro "AutoRun" { + // run all the .ijm scripts provided in macros/AutoRun/ + autoRunDirectory = getDirectory("imagej") + "/macros/AutoRun/"; + if (File.isDirectory(autoRunDirectory)) { + list = getFileList(autoRunDirectory); + // make sure startup order is consistent + Array.sort(list); + for (i = 0; i < list.length; i++) { + if (endsWith(list[i], ".ijm")) { + runMacro(autoRunDirectory + list[i]); + } + } + } +} + +var pmCmds = newMenu("Popup Menu", + newArray("Help...", "Rename...", "Duplicate...", "Original Scale", + "Paste Control...", "-", "Record...", "Capture Screen ", "Monitor Memory...", + "Find Commands...", "Control Panel...", "Startup Macros...", "Search...")); + +macro "Popup Menu" { + cmd = getArgument(); + if (cmd=="Help...") + showMessage("About Popup Menu", + "To customize this menu, edit the line that starts with\n\"var pmCmds\" in ImageJ/macros/StartupMacros.txt."); + else + run(cmd); +} + +macro "Abort Macro or Plugin (or press Esc key) Action Tool - CbooP51b1f5fbbf5f1b15510T5c10X" { + setKeyDown("Esc"); +} + +var xx = requires138b(); // check version at install +function requires138b() {requires("1.38b"); return 0; } + +var dCmds = newMenu("Developer Menu Tool", +newArray("ImageJ Website","News", "Documentation", "ImageJ Wiki", "Resources", "Macro Language", "Macros", + "Macro Functions", "Startup Macros...", "Plugins", "Source Code", "Mailing List Archives", "-", "Record...", + "Capture Screen ", "Monitor Memory...", "List Commands...", "Control Panel...", "Search...", "Debug Mode")); + +macro "Developer Menu Tool - C037T0b11DT7b09eTcb09v" { + cmd = getArgument(); + if (cmd=="ImageJ Website") + run("URL...", "url=http://rsbweb.nih.gov/ij/"); + else if (cmd=="News") + run("URL...", "url=http://rsbweb.nih.gov/ij/notes.html"); + else if (cmd=="Documentation") + run("URL...", "url=http://rsbweb.nih.gov/ij/docs/"); + else if (cmd=="ImageJ Wiki") + run("URL...", "url=http://imagejdocu.tudor.lu/imagej-documentation-wiki/"); + else if (cmd=="Resources") + run("URL...", "url=http://rsbweb.nih.gov/ij/developer/"); + else if (cmd=="Macro Language") + run("URL...", "url=http://rsbweb.nih.gov/ij/developer/macro/macros.html"); + else if (cmd=="Macros") + run("URL...", "url=http://rsbweb.nih.gov/ij/macros/"); + else if (cmd=="Macro Functions") + run("URL...", "url=http://rsbweb.nih.gov/ij/developer/macro/functions.html"); + else if (cmd=="Plugins") + run("URL...", "url=http://rsbweb.nih.gov/ij/plugins/"); + else if (cmd=="Source Code") + run("URL...", "url=http://rsbweb.nih.gov/ij/developer/source/"); + else if (cmd=="Mailing List Archives") + run("URL...", "url=https://list.nih.gov/archives/imagej.html"); + else if (cmd=="Debug Mode") + setOption("DebugMode", true); + else if (cmd!="-") + run(cmd); +} + +var sCmds = newMenu("Stacks Menu Tool", + newArray("Add Slice", "Delete Slice", "Next Slice [>]", "Previous Slice [<]", "Set Slice...", "-", + "Convert Images to Stack", "Convert Stack to Images", "Make Montage...", "Reslice [/]...", "Z Project...", + "3D Project...", "Plot Z-axis Profile", "-", "Start Animation", "Stop Animation", "Animation Options...", + "-", "MRI Stack (528K)")); +macro "Stacks Menu Tool - C037T0b11ST8b09tTcb09k" { + cmd = getArgument(); + if (cmd!="-") run(cmd); +} + +var luts = getLutMenu(); +var lCmds = newMenu("LUT Menu Tool", luts); +macro "LUT Menu Tool - C037T0b11LT6b09UTcb09T" { + cmd = getArgument(); + if (cmd!="-") run(cmd); +} +function getLutMenu() { + list = getLutList(); + menu = newArray(16+list.length); + menu[0] = "Invert LUT"; menu[1] = "Apply LUT"; menu[2] = "-"; + menu[3] = "Fire"; menu[4] = "Grays"; menu[5] = "Ice"; + menu[6] = "Spectrum"; menu[7] = "3-3-2 RGB"; menu[8] = "Red"; + menu[9] = "Green"; menu[10] = "Blue"; menu[11] = "Cyan"; + menu[12] = "Magenta"; menu[13] = "Yellow"; menu[14] = "Red/Green"; + menu[15] = "-"; + for (i=0; iMacros\n" + + "menu when Fiji starts.\n" + + "\n" + + "More information is available at:\n" + + ""; + dummy = call("fiji.FijiTools.openEditor", title, text); +} + +macro "Save As JPEG... [j]" { + quality = call("ij.plugin.JpegWriter.getQuality"); + quality = getNumber("JPEG quality (0-100):", quality); + run("Input/Output...", "jpeg="+quality); + saveAs("Jpeg"); +} + +macro "Save Inverted FITS" { + run("Flip Vertically"); + run("FITS...", ""); + run("Flip Vertically"); +} + +macro "Draw Rectangle Long Length Action Tool - L030bLf3fbL07f7" { + run("Draw Rectangle Long Length"); +} + +macro "Draw Rectangle Short Length Action Tool - L303eLc0ceL37c7" { + run("Draw Rectangle Short Length"); +} + +macro "Draw Rectangle Length x Width Action Tool - R00ffT3c07LT7c07,T9c07W" { + run("Draw Rectangle Length x Width"); +} + +macro "Choose Microscope Calibration Action Tool - T0d14kT9d14X" { + run("Choose Microscope Calibration"); +} + +macro "Draw Rectangle Long Length [q]" { + run("Draw Rectangle Long Length"); +} + +macro "Draw Rectangle Short Length [g]" { + run("Draw Rectangle Short Length"); +} + +macro "Draw Rectangle Length x Width [u]" { + run("Draw Rectangle Length x Width"); +} + +macro "Choose Microscope Calibration [f1]" { + run("Choose Microscope Calibration"); +} \ No newline at end of file diff --git a/Analyze/Microscope Measurement Tools/Choose_Microscope_Calibration.py b/plugins/Analyze/Microscope Measurement Tools/Choose_Microscope_Calibration.py similarity index 94% rename from Analyze/Microscope Measurement Tools/Choose_Microscope_Calibration.py rename to plugins/Analyze/Microscope Measurement Tools/Choose_Microscope_Calibration.py index 084bcf4..04cac37 100644 --- a/Analyze/Microscope Measurement Tools/Choose_Microscope_Calibration.py +++ b/plugins/Analyze/Microscope Measurement Tools/Choose_Microscope_Calibration.py @@ -1,214 +1,214 @@ -''' Choose_Microscope_Calibration.py -Plugin for FIJI, to enable custom scaling for various microscope objectives. - -Reads user settings from `Microscope_Calibrations_user_settings.py` -including user-calibrations and names for various microscope objectives. -This function will popup a menu of all available microscope cals listed in the settings file, and then apply that scaling (and unit) to the image. -User can optionally apply the scaling to all open images, and/or run the "Scale Bar..." command afterwards. - -Based off Microscope_Scale.java & Correct_3d_drift.py - - -v2.2 -Demis D. John, Univ. of California Santa Barbara, 2019-04-12 -''' - -mc_DEBUG = False # Print debugging info to the console? - -## Import some modules: -from ij import IJ, ImagePlus, WindowManager -from ij.gui import GenericDialog, YesNoCancelDialog - -import sys, os - - - - -# add the path to this script, so we can find the user-settings -libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # path to Fiji folder -#print libpth -libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') - - -try: - sys.path.index( libpth ) # see if search-path is already added -except ValueError: - # path wasn't included yet, so add it: - sys.path.append( libpth ) -#sys.path.append('/Applications/Fiji.app/plugins/Scripts/Plugins/Demis/') -#print sys.path - -# microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: -import Microscope_Calibrations_user_settings as cal # imports `names`, `cals`, `units` under namespace `cal.names` etc. - - - - -# the run() function is called at the end of this script: -def run(): - '''This is the main function run when the plugin is called.''' - - #print cal.names, cal.cals, cal.units - - - imp = IJ.getImage() # get the current Image as ImagePlus object - - # Show "Choose Calibration" dialog: - CalIdx, SetGlobalScale, AddScaleBar = uScopeCalDialog(cal) - - if CalIdx == None: return # User cancelled - exit - - newcal = imp.getCalibration().copy() # make a copy of current calibration object - - if isinstance( cal.names[CalIdx], str ): - '''It's just a regular calibration setting''' - calName = cal.names[CalIdx] - if mc_DEBUG: print("Calibration is Regular String/text") - newPixelPerUnit = float( cal.cals[CalIdx] ) - newUnit = cal.units[CalIdx] - newAspect = float( cal.aspect_ratio[CalIdx] ) - - newPixelWidth = 1. / newPixelPerUnit - newPixelHeight = newPixelWidth * newAspect - else: - ''' Assume we'll be loading a custom function/class ''' - if mc_DEBUG: print("Calibration is a custom function.") - # call the class' `classObj.cal( ImagePlusObject )` function to get the scale value: - try: - calObject = cal.names[CalIdx] - calName = calObject.name - newPixelPerUnit = calObject.cal( imp ) - except AttributeError: - raise ValueError('This calibration Name value is invalid, please check your Settings.py file!/n/tFor Calibration Number %i, got: `'%(CalIdx) + str(cal.names[CalIdx]) + '`. Expected a String or a Class instance with ".cal()" method, but got type ' + str( type(cal.names[CalIdx]) ) + ' with no ".cal()" method.' ) - #end try - - newUnit = calObject.unit - newAspect = calObject.aspect_ratio - - newPixelWidth = 1. / newPixelPerUnit - newPixelHeight = newPixelWidth * newAspect - #end if(cal.name is a string or function) - print "Chose `", calName, "` : ", newPixelPerUnit, " px/", newUnit - - #end if CalIdx - - # the following translated from "Microscope_Scale.java": - newcal.setUnit( newUnit ) - newcal.pixelWidth = newPixelWidth - newcal.pixelHeight = newPixelHeight - - - if SetGlobalScale: - '''Apply to all images''' - imp.setGlobalCalibration(newcal) - winlist = WindowManager.getIDList(); - #print "winlist=", winlist - if (winlist==None): return # exit if no images open - for win in winlist: - #(int i=0; i 20 cals, use dropdown list, otherwise use radio buttons''' - if len(cal.names) > 20: - Radio=False - # Drop-Down list: - gd.addChoice(" Calibration:", CalStr, CalStr[0] ) # default = 1st (#0) - - else: - Radio=True - gd.addRadioButtonGroup(" Calibration:", CalStr, len(CalStr), 1, CalStr[0]) - #addRadioButtonGroup(label, [String items], rows, columns, String:defaultItem) - #end if(cal>20) - - gd.addCheckbox("Apply Scale to all open images?", False) - gd.addCheckbox("Add Scale Bar to this image?", False) - gd.addMessage("These calibrations can be altered by editing the file: \nFiji.app/plugins/Scripts/Plugins/Analyze/...\n\tMicroscope Measurement Tools/...\n\tMicroscope_Calibrations_user_settings.py") - - gd.showDialog() - - - if gd.wasCanceled(): - return None, None, None # return None's if user cancels - - if Radio: - ChosenCal = gd.getNextRadioButton() - # Find the index to the chosen radio button w/ [list].index(): - CalIdx = CalStr.index( ChosenCal ) - else: - ChosenCal = gd.getNextChoiceIndex() - CalIdx = ChosenCal # the index to the choice - - SetGlobalScale = gd.getNextBoolean() - AddScaleBar = gd.getNextBoolean() - - - - #if mc_DEBUG: print( ChosenCal,CalIdx, SetGlobalScale ) - #if mc_DEBUG: print( "end uScopeCalDialog()." ) - return CalIdx, SetGlobalScale, AddScaleBar -#end uScopeCalDialog() - - -run() # Run the script function! - - +''' Choose_Microscope_Calibration.py +Plugin for FIJI, to enable custom scaling for various microscope objectives. + +Reads user settings from `Microscope_Calibrations_user_settings.py` +including user-calibrations and names for various microscope objectives. +This function will popup a menu of all available microscope cals listed in the settings file, and then apply that scaling (and unit) to the image. +User can optionally apply the scaling to all open images, and/or run the "Scale Bar..." command afterwards. + +Based off Microscope_Scale.java & Correct_3d_drift.py + + +v2.2 +Demis D. John, Univ. of California Santa Barbara, 2019-04-12 +''' + +mc_DEBUG = False # Print debugging info to the console? + +## Import some modules: +from ij import IJ, ImagePlus, WindowManager +from ij.gui import GenericDialog, YesNoCancelDialog + +import sys, os + + + + +# add the path to this script, so we can find the user-settings +libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # path to Fiji folder +#print libpth +libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') + + +try: + sys.path.index( libpth ) # see if search-path is already added +except ValueError: + # path wasn't included yet, so add it: + sys.path.append( libpth ) +#sys.path.append('/Applications/Fiji.app/plugins/Scripts/Plugins/Demis/') +#print sys.path + +# microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: +import Microscope_Calibrations_user_settings as cal # imports `names`, `cals`, `units` under namespace `cal.names` etc. + + + + +# the run() function is called at the end of this script: +def run(): + '''This is the main function run when the plugin is called.''' + + #print cal.names, cal.cals, cal.units + + + imp = IJ.getImage() # get the current Image as ImagePlus object + + # Show "Choose Calibration" dialog: + CalIdx, SetGlobalScale, AddScaleBar = uScopeCalDialog(cal) + + if CalIdx == None: return # User cancelled - exit + + newcal = imp.getCalibration().copy() # make a copy of current calibration object + + if isinstance( cal.names[CalIdx], str ): + '''It's just a regular calibration setting''' + calName = cal.names[CalIdx] + if mc_DEBUG: print("Calibration is Regular String/text") + newPixelPerUnit = float( cal.cals[CalIdx] ) + newUnit = cal.units[CalIdx] + newAspect = float( cal.aspect_ratio[CalIdx] ) + + newPixelWidth = 1. / newPixelPerUnit + newPixelHeight = newPixelWidth * newAspect + else: + ''' Assume we'll be loading a custom function/class ''' + if mc_DEBUG: print("Calibration is a custom function.") + # call the class' `classObj.cal( ImagePlusObject )` function to get the scale value: + try: + calObject = cal.names[CalIdx] + calName = calObject.name + newPixelPerUnit = calObject.cal( imp ) + except AttributeError: + raise ValueError('This calibration Name value is invalid, please check your Settings.py file!/n/tFor Calibration Number %i, got: `'%(CalIdx) + str(cal.names[CalIdx]) + '`. Expected a String or a Class instance with ".cal()" method, but got type ' + str( type(cal.names[CalIdx]) ) + ' with no ".cal()" method.' ) + #end try + + newUnit = calObject.unit + newAspect = calObject.aspect_ratio + + newPixelWidth = 1. / newPixelPerUnit + newPixelHeight = newPixelWidth * newAspect + #end if(cal.name is a string or function) + print "Chose `", calName, "` : ", newPixelPerUnit, " px/", newUnit + + #end if CalIdx + + # the following translated from "Microscope_Scale.java": + newcal.setUnit( newUnit ) + newcal.pixelWidth = newPixelWidth + newcal.pixelHeight = newPixelHeight + + + if SetGlobalScale: + '''Apply to all images''' + imp.setGlobalCalibration(newcal) + winlist = WindowManager.getIDList(); + #print "winlist=", winlist + if (winlist==None): return # exit if no images open + for win in winlist: + #(int i=0; i 20 cals, use dropdown list, otherwise use radio buttons''' + if len(cal.names) > 20: + Radio=False + # Drop-Down list: + gd.addChoice(" Calibration:", CalStr, CalStr[0] ) # default = 1st (#0) + + else: + Radio=True + gd.addRadioButtonGroup(" Calibration:", CalStr, len(CalStr), 1, CalStr[0]) + #addRadioButtonGroup(label, [String items], rows, columns, String:defaultItem) + #end if(cal>20) + + gd.addCheckbox("Set as global?", True) + gd.addCheckbox("Add Scale Bar to this image?", False) + gd.addMessage("These calibrations can be altered by editing the file: \nFiji.app/plugins/Analyze/...\n\tMicroscope Measurement Tools/...\n\tMicroscope_Calibrations_user_settings.py") + + gd.showDialog() + + + if gd.wasCanceled(): + return None, None, None # return None's if user cancels + + if Radio: + ChosenCal = gd.getNextRadioButton() + # Find the index to the chosen radio button w/ [list].index(): + CalIdx = CalStr.index( ChosenCal ) + else: + ChosenCal = gd.getNextChoiceIndex() + CalIdx = ChosenCal # the index to the choice + + SetGlobalScale = gd.getNextBoolean() + AddScaleBar = gd.getNextBoolean() + + + + #if mc_DEBUG: print( ChosenCal,CalIdx, SetGlobalScale ) + #if mc_DEBUG: print( "end uScopeCalDialog()." ) + return CalIdx, SetGlobalScale, AddScaleBar +#end uScopeCalDialog() + + +run() # Run the script function! + + diff --git a/Analyze/Microscope Measurement Tools/Draw_Measurement_-_Line.py b/plugins/Analyze/Microscope Measurement Tools/Draw_Measurement_-_Line.py similarity index 97% rename from Analyze/Microscope Measurement Tools/Draw_Measurement_-_Line.py rename to plugins/Analyze/Microscope Measurement Tools/Draw_Measurement_-_Line.py index c50a08e..ea637bf 100644 --- a/Analyze/Microscope Measurement Tools/Draw_Measurement_-_Line.py +++ b/plugins/Analyze/Microscope Measurement Tools/Draw_Measurement_-_Line.py @@ -1,277 +1,277 @@ -'''Draw Measurement - Line.py -Part of the "Microscope Measurement Tools" scripts -by Demis D. John, Praevium Research Inc., 2015-05-25 - -Draw a Line & Length of the Line along the currently selected Line ROI. - -''' - -#print "hello outside!" - -## Import some modules: -from ij import IJ, ImagePlus, WindowManager #, gui -from ij.gui import GenericDialog, YesNoCancelDialog - -from java.awt import Color as jColor # for setting color -from java.awt import Font as jFont # for setting text font - -import sys, os - - - - -# add the path to this script, so we can find the user-settings -libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # split-off the "/jars/lib" part -#print libpth -libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') -# hard-coded path, within the Fiji directory. - -try: - sys.path.index( libpth ) # see if search-path is already added -except ValueError: - # path wasn't included yet, so add it: - sys.path.append( libpth ) -#sys.path.append('/Applications/Fiji.app/plugins/Scripts/Analyze/Microscope Measurement Tools/') -#print sys.path - -# microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: -import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. - -#print os.path.abspath(sets.__file__) -#print dir(sets) -#print sets.cals # see what calibrations have been set - - -# the run() function is called at the end of this script: -def run(): - '''This is the main function run when the plugin is called.''' - - #print dir(IJ) - ip = IJ.getProcessor() - - imp = IJ.getImage() # get the current Image, which is an ImagePlus object - #print "imp=", type(imp), imp - #print dir(imp) - - roi = imp.getRoi() # get the drawn ROI - #print "roi=", roi, roi.getClass() - - - # check ROI type - if roi==None: - gd = GenericDialog("Draw Measurement - Line") - gd.addMessage("Please draw a straight-line first!") - gd.showDialog() - return - #raise Exception( "Please draw a line ROI first!" ) - if roi.getTypeAsString() != "Straight Line": - gd = GenericDialog("Draw Measurement - Line") - gd.addMessage("Please draw a straight-line first!") - gd.showDialog() - return - #raise Exception( "Not a Line ROI! (type="+roi.getTypeAsString()+")" ) - - - - - p1 = [ int(roi.x1d), int(roi.y1d) ] # point 1 (x,y) - p2 = [ int(roi.x2d), int(roi.y2d) ] # point 2 - print "DrawMeas(): Line Points: p1=", p1, " & p2=", p2 - pm = midpoint(p1, p2) # get midpoint coord - - - # set ROI params from settings: - ''' Using new method - used ip.drawLine instead of roi.draw, since roi.draw didn't always apply the line thickness. Would be best to use the ROI method, in case other types of ROI's could be annotated. - - roi.setStrokeWidth( sets.linethickness ) - roi.setStrokeColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) - - #roi.drawPixels( ip ) # draw along the ROI - only draws outline unfortunately - ip.drawRoi(roi) # draw the ROI on the image - ''' - - ip.setLineWidth( int(sets.linethickness) ) - ip.setColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) - - #ip.draw(roi) # changed to ip.drawLine() - ip.drawLine( int(roi.x1d), int(roi.y1d), int(roi.x2d), int(roi.y2d) ) - - - - - '''Draw text annotation''' - unit = imp.getCalibration().getUnit().encode('utf-8') # get the unit as UTF-8 (for \mu) - if len(unit) == 3 : unit=unit[1:] # strip weird char at start of \mu - print "Draw_Meas(): Unit (raw) = `", unit,"`", type(unit), - - - # format of measurement text (eg. 3 decimal points): - lenstr = "%0.3f" % roi.getLength() + " %s" % (unit) # string to print as length - print "DrawMeas(): Line length= %s" % lenstr - #print "x,y=", p2[0], p2[1] - - '''determine position of text from line coords, eg "bottom right" or "top left" etc. ''' - # y-coord: - if p2[1] > p1[1]: - posstr = 'bottom' - else: - posstr = 'top' - - # x-coord: - if p2[0] > p1[0]: - posstr += ' right' - else: - posstr += ' left' - - - drawText( lenstr, p2[0], p2[1], position=posstr ) - - imp.updateAndDraw() #update the image - - # to do: - # Add dialogue for user to alter draw options? Or just from settings file? - -#end run() - - -""" java.awt.Font: Font(String name, int style (0=plain?), int size) """ -""" -class ImageProcessor: - drawString(java.lang.String s, int x, int y) - Draws a string at the specified location using the current fill/draw value. - drawString(java.lang.String s, int x, int y, java.awt.Color background) - Draws a string at the specified location with a filled background. -""" -'''ImageProcessor: - drawRoi(Roi roi): Draws the specified ROI on this image using the stroke width, stroke color and fill color defined by roi.setStrokeWidth, roi.setStrokeColor() and roi.setFillColor(). -''' - - - -def midpoint( p1, p2 ): - ''' return the midpoint as [x,y] list. - Takes two points, also as a pair of [x,y] lists. - ''' - - x1 = min( p1[0], p2[0] ) - y1 = min( p1[1], p2[1] ) - x2 = max( p1[0], p2[0] ) - y2 = max( p1[1], p2[1] ) - - xm = (x2-x1)/2. + x1 - ym = (y2-y1)/2. + y1 - - return [int(xm), int(ym)] -#end midpoint() - - - -def drawText( text, x, y, position='bottom right' ): - '''Draw a text string at the specified coordinates & relative position, ensuring text doesn't go over the edge of the image. - - Parameters: - ----------- - text : string - The text string to write on the image. - - x, y : int - The coordinates at which to draw the text. - - position : { 'bottom right', 'top right', 'top left', 'bottom left' }, case-insensitive, optional - Where to draw the text, with respect to the coordinates given. - Synonyms for 'bottom right' are 'br'. This is the default. - Synonyms for 'top right' are 'tr'. - Synonyms for 'bottom left' are 'bl'. - Synonyms for 'top left' are 'tl'. - ''' - print "drawText(): original (x,y)=(%i,%i)"%( x, y ) - - - # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: - import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. - - ip = IJ.getProcessor() # Image Processor - imp = IJ.getImage() # get the current Image, which is an ImagePlus object - - - '''Acquire arguments''' - position = position.strip().lower() - if position == 'bottom right' or position == 'br': - pos = 'br' - elif position == 'bottom left' or position == 'bl': - pos = 'bl' - elif position == 'top left' or position == 'tl': - pos = 'tl' - elif position == 'top right' or position == 'tr': - pos = 'tr' - else: - raise ValueError( 'drawText(): Invalid `position` argument: "%s".'%(position) ) - - - - - '''Setup text annotation''' - # set font: - ip.setFont( jFont('SansSerif', 0, sets.textsize) ) - ip.setColor( jColor( float(sets.textcolor[0]), float(sets.textcolor[1]), float(sets.textcolor[2]), float(sets.textcolor[3]) ) ) - - - - - '''determine text position''' - margin = 6 # space in pixels away from edge of image - spacer = 4 # space in pixels to add between point & text - strw = ip.getStringWidth(text) - strh = ip.getFontMetrics().getHeight() - imgw = ip.getWidth() - imgh = ip.getHeight() - - ''' - print "strw =", strw - print "strh =", strh - print "imgw =", imgw - print "imgh =", imgh - ''' - - - # set coords (x,y) based on `position` argument - ''' By default, text is horizontally centered at point (x), and vertically above the point (y). We then modify these default coords. ''' - - if pos[0] == 'b': - y = y + spacer + strh # moves down - elif pos[0] == 't': - y = y - spacer - - if pos[1] == 'r': - x = x + spacer # moves right - elif pos[1] == 'l': - x = x - spacer - int(strw) - - print "drawText(): %s "%(pos) + "(x,y)=(%i,%i)"%( x, y ) - - '''Correct for edge of image''' - if y - strh < 0: - y = 0 + strh + margin - elif y > imgh : - y = imgh - margin - - if (x) < 0: - x = 0 + margin - elif (x + strw) > imgw: - x = imgw - strw - margin - - print "drawText(): final (x,y)=(%i,%i)"%( x, y ) - - - if sets.textbackgroundcolor: - ip.drawString( text, x, y, jColor( float(sets.textbackgroundcolor[0]), float(sets.textbackgroundcolor[1]), float(sets.textbackgroundcolor[2]), float(sets.textbackgroundcolor[3]) ) ) # write the text w/ BG color - else: - ip.drawString( text, x, y ) # write the text alone - - imp.updateAndDraw() #update the image -#end drawText() - - - -run() # Finally, Run the script function! - +'''Draw Measurement - Line.py +Part of the "Microscope Measurement Tools" scripts +by Demis D. John, Praevium Research Inc., 2015-05-25 + +Draw a Line & Length of the Line along the currently selected Line ROI. + +''' + +#print "hello outside!" + +## Import some modules: +from ij import IJ, ImagePlus, WindowManager #, gui +from ij.gui import GenericDialog, YesNoCancelDialog + +from java.awt import Color as jColor # for setting color +from java.awt import Font as jFont # for setting text font + +import sys, os + + + + +# add the path to this script, so we can find the user-settings +libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # split-off the "/jars/lib" part +#print libpth +libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') +# hard-coded path, within the Fiji directory. + +try: + sys.path.index( libpth ) # see if search-path is already added +except ValueError: + # path wasn't included yet, so add it: + sys.path.append( libpth ) +#sys.path.append('/Applications/Fiji.app/plugins/Scripts/Analyze/Microscope Measurement Tools/') +#print sys.path + +# microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: +import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + +#print os.path.abspath(sets.__file__) +#print dir(sets) +#print sets.cals # see what calibrations have been set + + +# the run() function is called at the end of this script: +def run(): + '''This is the main function run when the plugin is called.''' + + #print dir(IJ) + ip = IJ.getProcessor() + + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + #print "imp=", type(imp), imp + #print dir(imp) + + roi = imp.getRoi() # get the drawn ROI + #print "roi=", roi, roi.getClass() + + + # check ROI type + if roi==None: + gd = GenericDialog("Draw Measurement - Line") + gd.addMessage("Please draw a straight-line first!") + gd.showDialog() + return + #raise Exception( "Please draw a line ROI first!" ) + if roi.getTypeAsString() != "Straight Line": + gd = GenericDialog("Draw Measurement - Line") + gd.addMessage("Please draw a straight-line first!") + gd.showDialog() + return + #raise Exception( "Not a Line ROI! (type="+roi.getTypeAsString()+")" ) + + + + + p1 = [ int(roi.x1d), int(roi.y1d) ] # point 1 (x,y) + p2 = [ int(roi.x2d), int(roi.y2d) ] # point 2 + print "DrawMeas(): Line Points: p1=", p1, " & p2=", p2 + pm = midpoint(p1, p2) # get midpoint coord + + + # set ROI params from settings: + ''' Using new method - used ip.drawLine instead of roi.draw, since roi.draw didn't always apply the line thickness. Would be best to use the ROI method, in case other types of ROI's could be annotated. + + roi.setStrokeWidth( sets.linethickness ) + roi.setStrokeColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) + + #roi.drawPixels( ip ) # draw along the ROI - only draws outline unfortunately + ip.drawRoi(roi) # draw the ROI on the image + ''' + + ip.setLineWidth( int(sets.linethickness) ) + ip.setColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) + + #ip.draw(roi) # changed to ip.drawLine() + ip.drawLine( int(roi.x1d), int(roi.y1d), int(roi.x2d), int(roi.y2d) ) + + + + + '''Draw text annotation''' + unit = imp.getCalibration().getUnit().encode('utf-8') # get the unit as UTF-8 (for \mu) + if len(unit) == 3 : unit=unit[1:] # strip weird char at start of \mu + print "Draw_Meas(): Unit (raw) = `", unit,"`", type(unit), + + + # format of measurement text (eg. 3 decimal points): + lenstr = "%0.3f" % roi.getLength() + " %s" % (unit) # string to print as length + print "DrawMeas(): Line length= %s" % lenstr + #print "x,y=", p2[0], p2[1] + + '''determine position of text from line coords, eg "bottom right" or "top left" etc. ''' + # y-coord: + if p2[1] > p1[1]: + posstr = 'bottom' + else: + posstr = 'top' + + # x-coord: + if p2[0] > p1[0]: + posstr += ' right' + else: + posstr += ' left' + + + drawText( lenstr, p2[0], p2[1], position=posstr ) + + imp.updateAndDraw() #update the image + + # to do: + # Add dialogue for user to alter draw options? Or just from settings file? + +#end run() + + +""" java.awt.Font: Font(String name, int style (0=plain?), int size) """ +""" +class ImageProcessor: + drawString(java.lang.String s, int x, int y) + Draws a string at the specified location using the current fill/draw value. + drawString(java.lang.String s, int x, int y, java.awt.Color background) + Draws a string at the specified location with a filled background. +""" +'''ImageProcessor: + drawRoi(Roi roi): Draws the specified ROI on this image using the stroke width, stroke color and fill color defined by roi.setStrokeWidth, roi.setStrokeColor() and roi.setFillColor(). +''' + + + +def midpoint( p1, p2 ): + ''' return the midpoint as [x,y] list. + Takes two points, also as a pair of [x,y] lists. + ''' + + x1 = min( p1[0], p2[0] ) + y1 = min( p1[1], p2[1] ) + x2 = max( p1[0], p2[0] ) + y2 = max( p1[1], p2[1] ) + + xm = (x2-x1)/2. + x1 + ym = (y2-y1)/2. + y1 + + return [int(xm), int(ym)] +#end midpoint() + + + +def drawText( text, x, y, position='bottom right' ): + '''Draw a text string at the specified coordinates & relative position, ensuring text doesn't go over the edge of the image. + + Parameters: + ----------- + text : string + The text string to write on the image. + + x, y : int + The coordinates at which to draw the text. + + position : { 'bottom right', 'top right', 'top left', 'bottom left' }, case-insensitive, optional + Where to draw the text, with respect to the coordinates given. + Synonyms for 'bottom right' are 'br'. This is the default. + Synonyms for 'top right' are 'tr'. + Synonyms for 'bottom left' are 'bl'. + Synonyms for 'top left' are 'tl'. + ''' + print "drawText(): original (x,y)=(%i,%i)"%( x, y ) + + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + + '''Acquire arguments''' + position = position.strip().lower() + if position == 'bottom right' or position == 'br': + pos = 'br' + elif position == 'bottom left' or position == 'bl': + pos = 'bl' + elif position == 'top left' or position == 'tl': + pos = 'tl' + elif position == 'top right' or position == 'tr': + pos = 'tr' + else: + raise ValueError( 'drawText(): Invalid `position` argument: "%s".'%(position) ) + + + + + '''Setup text annotation''' + # set font: + ip.setFont( jFont('SansSerif', 0, sets.textsize) ) + ip.setColor( jColor( float(sets.textcolor[0]), float(sets.textcolor[1]), float(sets.textcolor[2]), float(sets.textcolor[3]) ) ) + + + + + '''determine text position''' + margin = 6 # space in pixels away from edge of image + spacer = 4 # space in pixels to add between point & text + strw = ip.getStringWidth(text) + strh = ip.getFontMetrics().getHeight() + imgw = ip.getWidth() + imgh = ip.getHeight() + + ''' + print "strw =", strw + print "strh =", strh + print "imgw =", imgw + print "imgh =", imgh + ''' + + + # set coords (x,y) based on `position` argument + ''' By default, text is horizontally centered at point (x), and vertically above the point (y). We then modify these default coords. ''' + + if pos[0] == 'b': + y = y + spacer + strh # moves down + elif pos[0] == 't': + y = y - spacer + + if pos[1] == 'r': + x = x + spacer # moves right + elif pos[1] == 'l': + x = x - spacer - int(strw) + + print "drawText(): %s "%(pos) + "(x,y)=(%i,%i)"%( x, y ) + + '''Correct for edge of image''' + if y - strh < 0: + y = 0 + strh + margin + elif y > imgh : + y = imgh - margin + + if (x) < 0: + x = 0 + margin + elif (x + strw) > imgw: + x = imgw - strw - margin + + print "drawText(): final (x,y)=(%i,%i)"%( x, y ) + + + if sets.textbackgroundcolor: + ip.drawString( text, x, y, jColor( float(sets.textbackgroundcolor[0]), float(sets.textbackgroundcolor[1]), float(sets.textbackgroundcolor[2]), float(sets.textbackgroundcolor[3]) ) ) # write the text w/ BG color + else: + ip.drawString( text, x, y ) # write the text alone + + imp.updateAndDraw() #update the image +#end drawText() + + + +run() # Finally, Run the script function! + diff --git a/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Length_x_Width.py b/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Length_x_Width.py new file mode 100644 index 0000000..c69d0a1 --- /dev/null +++ b/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Length_x_Width.py @@ -0,0 +1,211 @@ +''' +Draw_Rectangle_Long_Length.py +by Will Sides 2020-03-04 + +Contribution to the "Microscope Measurement Tools" scripts +by Demis D. John, Praevium Research Inc., 2015-05-25 + +Draws the long dimension of a rectangle or rotated rectangle +Draws extension lines defined by short side width of the rectangle + +This comment is just to test git +''' + +from ij import IJ, ImagePlus, WindowManager +from ij.gui import GenericDialog + +from java.awt import Color as jColor # for setting color +from java.awt import Font as jFont # for setting text font + +import sys, os + +# add the path to this script, so we can find the user-settings +libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # split-off the "/jars/lib" part +#print libpth +libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') +# hard-coded path, within the Fiji directory. + +try: + sys.path.index( libpth ) # see if search-path is already added +except ValueError: + # path wasn't included yet, so add it: + sys.path.append( libpth ) + +# Settings should be in the file 'DA_user_settings.py`: +import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + +# the run() function is called at the end of this script: +def run(): + '''This is the main function run when the plugin is called.''' + + ip = IJ.getProcessor() #Construct a image processor + + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # Warn the user if no calibration has been set + cal = imp.getCalibration() + unit = cal.getUnit().encode('utf8') # get the unit as UTF-8 (for \mu) + if len(unit) == 3 : unit=unit[1:] # strip weird char at start of \mu + if unit=='pixel': + gd = GenericDialog("No Calibration") + gd.addMessage("Warning - no calibration set") + gd.setCancelLabel("Continue anyway") + gd.setOKLabel("Cancel") + gd.showDialog() + if gd.wasOKed(): + return + + # check ROI exists + roi = imp.getRoi() # get the drawn ROI + if roi==None: + showInvalidROIDialog('Draw a rectangle first!') + return + + # Check the ROI is a rectangle or rotated rectangle + roiType=roi.getTypeAsString() + print ('ROI type: ' + roiType) + if roiType not in ["Rectangle", "Freehand"]: + showInvalidROIDialog('Invalid shape - please draw a rectangle') + return + + # Get the x,y, coordinates of the 4 corners of the rectangle + x=roi.getFloatPolygon().xpoints + y=roi.getFloatPolygon().ypoints + + # Calculate the side lengths + l0=((x[0]-x[1])**2+(y[0]-y[1])**2)**0.5 + l1=((x[1]-x[2])**2+(y[1]-y[2])**2)**0.5 + l2=((x[2]-x[3])**2+(y[2]-y[3])**2)**0.5 + l3=((x[3]-x[0])**2+(y[3]-y[0])**2)**0.5 + + # Rotated rectangles come back as generic 'Freehand' types, so we have to get creative to allow only rectangles (true parallelograms are also valid) + if (len(x) != 4) or (len(y) != 4) or (abs(l0 - l2) > 0.01) or (abs(l1 - l3) > 0.01): + showInvalidROIDialog('Invalid shape - please draw a rectangle') + return + + # Calculate the coordinates in physical units + calX=[] + for i in x: + calX.append(cal.getX(i)) + calY=[] + for i in y: + calY.append(cal.getX(i)) + + # Define the lines to draw as tuples: (x,y,x',y') + topLine=(x[1],y[1],x[2],y[2]) + bottomLine=(x[3],y[3],x[0],y[0]) + calLength=((calX[0]-calX[1])**2+(calY[0]-calY[1])**2)**0.5 # length in physical units + rightLine=(x[0],y[0],x[1],y[1]) + leftLine=(x[2],y[2],x[3],y[3]) + calWidth=((calX[1]-calX[2])**2+(calY[1]-calY[2])**2)**0.5 # width in physical units + + # Determine the pixel coordinates to place the text label, in the center of the center-line + textPointLength = ((leftLine[0]+leftLine[2])*0.5,(leftLine[1]+leftLine[3])*0.5,) + textPointWidth = ((topLine[0]+topLine[2])*0.5,(topLine[1]+topLine[3])*0.5,) + + # format of measurement text: + lenstr = "%0.1f" % calLength + " %s" % (unit) # string to print + widstr = "%0.1f" % calWidth + " %s" % (unit) # string to print + + drawLines( [topLine, leftLine, bottomLine, rightLine] ) + drawText( lenstr, textPointLength, align='c' ) + drawText( widstr, textPointWidth, align='c' ) + +#end run() + +def drawLines( lines ): + ''' + Draws the given lines on the image according to user settings + + Parameters: + ----------- + lines : + List of lines to draw, each defined as a tuple of pixel coordinates: (x,y,x',y') + ''' + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # Set Line drawing settings + ip.setLineWidth( int(sets.linethickness) ) + ip.setColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) + + # Draw the lines + for line in lines: + ip.drawLine( *[int(n) for n in line] ) + + imp.updateAndDraw() #update the image + +#end annotateHeight() + +def drawText( text, xy, align='c' ): + ''' + Draw a text string at the specified coordinates & relative position, ensuring text doesn't go over the edge of the image. + + Parameters: + ----------- + text : + The text to draw + + xy : + The center (pixel) coordinates of the text + ''' + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # set font: + ip.setFont( jFont('SansSerif', 0, sets.textsize) ) + ip.setColor( jColor( float(sets.textcolor[0]), float(sets.textcolor[1]), float(sets.textcolor[2]), float(sets.textcolor[3]) ) ) + ip.setJustification( 1) # Justification: 0, 1, 2 = left, center, right + + # get image size and label sizes + imgw, imgh = ip.getWidth(), ip.getHeight() + margin = 6 # space in pixels away from edge of image + + # get label size and position + strw = ip.getStringWidth(text) + strh = ip.getFontMetrics().getHeight() + if align == 'rm': + xtext, ytext = xy[0] - ( strw * 0.5) , xy[1] + ( strh * 0.5 ) + elif align == 'cb': + xtext, ytext = xy[0] , xy[1] + else: + xtext, ytext = xy[0], xy[1] + (strh * 0.5) + + # Correct for edge of image + if ytext - strh < 0: + ytext = 0 + strh + margin + elif ytext > imgh : + ytext = imgh - margin + + if (xtext - (strw * 0.5)) < 0: + xtext = (strw * 0.5) + margin + elif (xtext + (strw * 0.5)) > imgw: + xtext = imgw - (strw * 0.5) - margin + + # Draw the text + if sets.textbackgroundcolor: + ip.drawString( text, int(xtext), int(ytext), jColor( float(sets.textbackgroundcolor[0]), float(sets.textbackgroundcolor[1]), float(sets.textbackgroundcolor[2]), float(sets.textbackgroundcolor[3]) ) ) # write the text w/ BG color + else: + ip.drawString( text, int(xtext), int(ytext) ) # write the text alone + + imp.updateAndDraw() #update the image + +#end drawText() + +def showInvalidROIDialog( message ): + # Shows the user a pop-up error message + gd = GenericDialog("ROI Error") + gd.addMessage(message) + gd.showDialog() +#end showInvalidROIDialog + +run() # Finally, Run the script function! + diff --git a/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Long_Length.py b/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Long_Length.py new file mode 100644 index 0000000..01de69f --- /dev/null +++ b/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Long_Length.py @@ -0,0 +1,206 @@ +''' +Draw_Rectangle_Long_Length.py +by Will Sides 2020-03-04 + +Contribution to the "Microscope Measurement Tools" scripts +by Demis D. John, Praevium Research Inc., 2015-05-25 + +Draws the long dimension of a rectangle or rotated rectangle +Draws extension lines defined by short side width of the rectangle +''' + +from ij import IJ, ImagePlus, WindowManager +from ij.gui import GenericDialog + +from java.awt import Color as jColor # for setting color +from java.awt import Font as jFont # for setting text font + +import sys, os + +# add the path to this script, so we can find the user-settings +libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # split-off the "/jars/lib" part +#print libpth +libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') +# hard-coded path, within the Fiji directory. + +try: + sys.path.index( libpth ) # see if search-path is already added +except ValueError: + # path wasn't included yet, so add it: + sys.path.append( libpth ) + +# Settings should be in the file 'DA_user_settings.py`: +import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + +# the run() function is called at the end of this script: +def run(): + '''This is the main function run when the plugin is called.''' + + ip = IJ.getProcessor() #Construct a image processor + + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # Warn the user if no calibration has been set + cal = imp.getCalibration() + unit = cal.getUnit().encode('utf8') # get the unit as UTF-8 (for \mu) + if len(unit) == 3 : unit=unit[1:] # strip weird char at start of \mu + if unit=='pixel': + gd = GenericDialog("No Calibration") + gd.addMessage("Warning - no calibration set") + gd.setCancelLabel("Continue anyway") + gd.setOKLabel("Cancel") + gd.showDialog() + if gd.wasOKed(): + return + + # check ROI exists + roi = imp.getRoi() # get the drawn ROI + if roi==None: + showInvalidROIDialog('Draw a rectangle first!') + return + + # Check the ROI is a rectangle or rotated rectangle + roiType=roi.getTypeAsString() + print ('ROI type: ' + roiType) + if roiType not in ["Rectangle", "Freehand"]: + showInvalidROIDialog('Invalid shape - please draw a rectangle') + return + + # Get the x,y, coordinates of the 4 corners of the rectangle + x=roi.getFloatPolygon().xpoints + y=roi.getFloatPolygon().ypoints + + # Calculate the side lengths + l0=((x[0]-x[1])**2+(y[0]-y[1])**2)**0.5 + l1=((x[1]-x[2])**2+(y[1]-y[2])**2)**0.5 + l2=((x[2]-x[3])**2+(y[2]-y[3])**2)**0.5 + l3=((x[3]-x[0])**2+(y[3]-y[0])**2)**0.5 + + # Rotated rectangles come back as generic 'Freehand' types, so we have to get creative to allow only rectangles (true parallelograms are also valid) + if (len(x) != 4) or (len(y) != 4) or (abs(l0 - l2) > 0.01) or (abs(l1 - l3) > 0.01): + showInvalidROIDialog('Invalid shape - please draw a rectangle') + return + + # Calculate the coordinates in physical units + calX=[] + for i in x: + calX.append(cal.getX(i)) + calY=[] + for i in y: + calY.append(cal.getX(i)) + + # Test which side is the 'long' side to draw + if l0 > l1: + # Define the lines to draw as tuples: (x,y,x',y') + topLine=(x[1],y[1],x[2],y[2]) # first 'short' side + bottomLine=(x[3],y[3],x[0],y[0]) # the other 'short' side + centerLine=((x[1]+x[2])*0.5,(y[1]+y[2])*0.5,(x[3]+x[0])*0.5,(y[3]+y[0])*0.5) # Connecting the 'short' sides through the middle, parallel to the long side + calLength=((calX[0]-calX[1])**2+(calY[0]-calY[1])**2)**0.5 # length of the 'long' side in physical units + else: + topLine=(x[0],y[0],x[1],y[1]) + bottomLine=(x[2],y[2],x[3],y[3]) + centerLine=((x[0]+x[1])*0.5,(y[0]+y[1])*0.5,(x[2]+x[3])*0.5,(y[2]+y[3])*0.5) + calLength=((calX[1]-calX[2])**2+(calY[1]-calY[2])**2)**0.5 + + # Determine the pixel coordinated to place the text label, in the center of the center-line + textCenterPoint = ((centerLine[0]+centerLine[2])*0.5,(centerLine[1]+centerLine[3])*0.5) + + # format of measurement text: + lenstr = "%0.1f" % calLength + " %s" % (unit) # string to print + + drawLines( [topLine, bottomLine, centerLine] ) + drawText( lenstr, textCenterPoint ) + +#end run() + +def drawLines( lines ): + ''' + Draws the given lines on the image according to user settings + + Parameters: + ----------- + lines : + List of lines to draw, each defined as a tuple of pixel coordinates: (x,y,x',y') + ''' + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # Set Line drawing settings + ip.setLineWidth( int(sets.linethickness) ) + ip.setColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) + + # Draw the lines + for line in lines: + ip.drawLine( *[int(n) for n in line] ) + + imp.updateAndDraw() #update the image + +#end annotateHeight() + +def drawText( text, xy ): + ''' + Draw a text string at the specified coordinates & relative position, ensuring text doesn't go over the edge of the image. + + Parameters: + ----------- + text : + The text to draw + + xy : + The center (pixel) coordinates of the text + ''' + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # set font: + ip.setFont( jFont('SansSerif', 0, sets.textsize) ) + ip.setColor( jColor( float(sets.textcolor[0]), float(sets.textcolor[1]), float(sets.textcolor[2]), float(sets.textcolor[3]) ) ) + ip.setJustification( 1) # Justification: 0, 1, 2 = left, center, right + + # get image size and label sizes + imgw, imgh = ip.getWidth(), ip.getHeight() + margin = 6 # space in pixels away from edge of image + + # get label size and position + strw = ip.getStringWidth(text) + strh = ip.getFontMetrics().getHeight() + xtext, ytext = xy[0], xy[1] + (strh * 0.5) + + # Correct for edge of image + if ytext - strh < 0: + ytext = 0 + strh + margin + elif ytext > imgh : + ytext = imgh - margin + + if (xtext - (strw * 0.5)) < 0: + xtext = (strw * 0.5) + margin + elif (xtext + (strw * 0.5)) > imgw: + xtext = imgw - (strw * 0.5) - margin + + # Draw the text + if sets.textbackgroundcolor: + ip.drawString( text, int(xtext), int(ytext), jColor( float(sets.textbackgroundcolor[0]), float(sets.textbackgroundcolor[1]), float(sets.textbackgroundcolor[2]), float(sets.textbackgroundcolor[3]) ) ) # write the text w/ BG color + else: + ip.drawString( text, int(xtext), int(ytext) ) # write the text alone + + imp.updateAndDraw() #update the image + +#end drawText() + +def showInvalidROIDialog( message ): + # Shows the user a pop-up error message + gd = GenericDialog("ROI Error") + gd.addMessage(message) + gd.showDialog() +#end showInvalidROIDialog + +run() # Finally, Run the script function! + diff --git a/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Short_Length.py b/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Short_Length.py new file mode 100644 index 0000000..7610568 --- /dev/null +++ b/plugins/Analyze/Microscope Measurement Tools/Draw_Rectangle_Short_Length.py @@ -0,0 +1,206 @@ +''' +Draw_Rectangle_Short_Length.py +by Will Sides 2020-03-04 + +Contribution to the "Microscope Measurement Tools" scripts +by Demis D. John, Praevium Research Inc., 2015-05-25 + +Draws the short dimension of a rectangle or rotated rectangle +Draws extension lines defined by long side width of the rectangle +''' + +from ij import IJ, ImagePlus, WindowManager +from ij.gui import GenericDialog + +from java.awt import Color as jColor # for setting color +from java.awt import Font as jFont # for setting text font + +import sys, os + +# add the path to this script, so we can find the user-settings +libpth = os.path.split( os.path.split( sys.path[0] )[0] )[0] # split-off the "/jars/lib" part +#print libpth +libpth = os.path.join(libpth, 'plugins', 'Analyze', 'Microscope Measurement Tools') +# hard-coded path, within the Fiji directory. + +try: + sys.path.index( libpth ) # see if search-path is already added +except ValueError: + # path wasn't included yet, so add it: + sys.path.append( libpth ) + +# Settings should be in the file 'DA_user_settings.py`: +import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + +# the run() function is called at the end of this script: +def run(): + '''This is the main function run when the plugin is called.''' + + ip = IJ.getProcessor() #Construct a image processor + + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # Warn the user if no calibration has been set + cal = imp.getCalibration() + unit = cal.getUnit().encode('utf8') # get the unit as UTF-8 (for \mu) + if len(unit) == 3 : unit=unit[1:] # strip weird char at start of \mu + if unit=='pixel': + gd = GenericDialog("No Calibration") + gd.addMessage("Warning - no calibration set") + gd.setCancelLabel("Continue anyway") + gd.setOKLabel("Cancel") + gd.showDialog() + if gd.wasOKed(): + return + + # check ROI exists + roi = imp.getRoi() # get the drawn ROI + if roi==None: + showInvalidROIDialog('Draw a rectangle first!') + return + + # Check the ROI is a rectangle or rotated rectangle + roiType=roi.getTypeAsString() + print ('ROI type: ' + roiType) + if roiType not in ["Rectangle", "Freehand"]: + showInvalidROIDialog('Invalid shape - please draw a rectangle') + return + + # Get the x,y, coordinates of the 4 corners of the rectangle + x=roi.getFloatPolygon().xpoints + y=roi.getFloatPolygon().ypoints + + # Calculate the side lengths + l0=((x[0]-x[1])**2+(y[0]-y[1])**2)**0.5 + l1=((x[1]-x[2])**2+(y[1]-y[2])**2)**0.5 + l2=((x[2]-x[3])**2+(y[2]-y[3])**2)**0.5 + l3=((x[3]-x[0])**2+(y[3]-y[0])**2)**0.5 + + # Rotated rectangles come back as generic 'Freehand' types, so we have to get creative to allow only rectangles (true parallelograms are also valid) + if (len(x) != 4) or (len(y) != 4) or (abs(l0 - l2) > 0.01) or (abs(l1 - l3) > 0.01): + showInvalidROIDialog('Invalid shape - please draw a rectangle') + return + + # Calculate the coordinates in physical units + calX=[] + for i in x: + calX.append(cal.getX(i)) + calY=[] + for i in y: + calY.append(cal.getX(i)) + + # Test which side is the 'short' side to draw + if l0 > l1: + # Define the lines to draw as tuples: (x,y,x',y') + topLine=(x[0],y[0],x[1],y[1]) # first 'long' side + bottomLine=(x[2],y[2],x[3],y[3]) # the other 'long' side + centerLine=((x[0]+x[1])*0.5,(y[0]+y[1])*0.5,(x[2]+x[3])*0.5,(y[2]+y[3])*0.5) # Connecting the 'long' sides through the middle, parallel to the short side + calLength=((calX[1]-calX[2])**2+(calY[1]-calY[2])**2)**0.5 # length of the 'short' side in physical units + else: + topLine=(x[1],y[1],x[2],y[2]) + bottomLine=(x[3],y[3],x[0],y[0]) + centerLine=((x[1]+x[2])*0.5,(y[1]+y[2])*0.5,(x[3]+x[0])*0.5,(y[3]+y[0])*0.5) + calLength=((calX[0]-calX[1])**2+(calY[0]-calY[1])**2)**0.5 + + # Determine the pixel coordinated to place the text label, in the center of the center-line + textCenterPoint = ((centerLine[0]+centerLine[2])*0.5,(centerLine[1]+centerLine[3])*0.5) + + # format of measurement text: + lenstr = "%0.1f" % calLength + " %s" % (unit) # string to print + + drawLines( [topLine, bottomLine, centerLine] ) + drawText( lenstr, textCenterPoint ) + +#end run() + +def drawLines( lines ): + ''' + Draws the given lines on the image according to user settings + + Parameters: + ----------- + lines : + List of lines to draw, each defined as a tuple of pixel coordinates: (x,y,x',y') + ''' + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # Set Line drawing settings + ip.setLineWidth( int(sets.linethickness) ) + ip.setColor( jColor(float(sets.linecolor[0]), float(sets.linecolor[1]), float(sets.linecolor[2]), float(sets.linecolor[3])) ) + + # Draw the lines + for line in lines: + ip.drawLine( *[int(n) for n in line] ) + + imp.updateAndDraw() #update the image + +#end annotateHeight() + +def drawText( text, xy ): + ''' + Draw a text string at the specified coordinates & relative position, ensuring text doesn't go over the edge of the image. + + Parameters: + ----------- + text : + The text to draw + + xy : + The center (pixel) coordinates of the text + ''' + + # microscope settings should be in the file `Microscope_Calibrations_user_settings.py`: + import Microscope_Calibrations_user_settings as sets # imports settings under `sets.linecolor`, `sets.linethickness` etc. + + ip = IJ.getProcessor() # Image Processor + imp = IJ.getImage() # get the current Image, which is an ImagePlus object + + # set font: + ip.setFont( jFont('SansSerif', 0, sets.textsize) ) + ip.setColor( jColor( float(sets.textcolor[0]), float(sets.textcolor[1]), float(sets.textcolor[2]), float(sets.textcolor[3]) ) ) + ip.setJustification( 1) # Justification: 0, 1, 2 = left, center, right + + # get image size and label sizes + imgw, imgh = ip.getWidth(), ip.getHeight() + margin = 6 # space in pixels away from edge of image + + # get label size and position + strw = ip.getStringWidth(text) + strh = ip.getFontMetrics().getHeight() + xtext, ytext = xy[0], xy[1] + (strh * 0.5) + + # Correct for edge of image + if ytext - strh < 0: + ytext = 0 + strh + margin + elif ytext > imgh : + ytext = imgh - margin + + if (xtext - (strw * 0.5)) < 0: + xtext = (strw * 0.5) + margin + elif (xtext + (strw * 0.5)) > imgw: + xtext = imgw - (strw * 0.5) - margin + + # Draw the text + if sets.textbackgroundcolor: + ip.drawString( text, int(xtext), int(ytext), jColor( float(sets.textbackgroundcolor[0]), float(sets.textbackgroundcolor[1]), float(sets.textbackgroundcolor[2]), float(sets.textbackgroundcolor[3]) ) ) # write the text w/ BG color + else: + ip.drawString( text, int(xtext), int(ytext) ) # write the text alone + + imp.updateAndDraw() #update the image + +#end drawText() + +def showInvalidROIDialog( message ): + # Shows the user a pop-up error message + gd = GenericDialog("ROI Error") + gd.addMessage(message) + gd.showDialog() +#end showInvalidROIDialog + +run() # Finally, Run the script function! + diff --git a/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.tif b/plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.tif old mode 100755 new mode 100644 similarity index 100% rename from Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.tif rename to plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.tif diff --git a/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.txt b/plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.txt old mode 100755 new mode 100644 similarity index 96% rename from Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.txt rename to plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.txt index 30c82d9..a0db8bb --- a/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.txt +++ b/plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL SEM - etched sidewall 01.txt @@ -1,83 +1,83 @@ -$SEM_DATA_VERSION 1 -$CM_SIGNAL_NAME SEI -$$SM_ADD_IMAGE -$$SM_ADD_CHECKED_CH 1 -$$ADD_CH1_SIGNAL SEI -$$ADD_CH2_SIGNAL SEI -$$ADD_CH3_SIGNAL SEI -$$ADD_CH4_SIGNAL SEI -$CM_CONTRAST 2390 -$CM_BRIGHTNESS 544 -$$SM_MIX_IMAGE -$CM_ACCEL_VOLT 1.00 -$SM_ARRIVAL_EMI 0.00 -$SM_GB_GUN_VOLT 3.00 -$SM_GB_BIAS_VOLT 2.00 -$$SM_WD 2.77 -$CM_MAG 50000 -$$SM_COLUMN_MODE GB_HIGH -$$SM_OL_APERTURE 9 -$$SM_CL_COARSE 14 -$$SM_CL_FINE 25 -$$SM_GUN_ALI_TILT 0 0 -$$SM_CL_STIG 0 0 -$$SM_OL_STIG 68 162 -$$SM_OL_STIG_CENTER 0 0 0 0 -$$SM_OLAP_ALI 0 0 -$$SM_PROBE_NO 6 -$$SM_PROBE_FINE 25 -$$SM_ACL_ALI -2 -1 -$$SM_COLUMN_CENTER 0 0 -$$SM_EF_ALI 0 0 -$$SM_SCAN_ROTATION 298.80 -$$SM_WD_CORRECT 0 -$$SM_INTEG_NO 1 -$$CM_SCAN_MODE 3 -$$CM_SCAN_SPEED 9 -$$CM_INSTRUMENT_SCAN_SPEED 9 -$$SM_R_FILTER_MODE 0 -$$SM_SEI_COLLECTOR 0 -$$SM_R_FILTER_INDEX 101 -$$SM_DET_SE1_MODE_NUMBER 0 -$$SM_DET_TTL_MODE_NUMBER 0 -$$SM_DET_SE2_MODE_NUMBER 0 -$$SM_TTL_COLLECTOR_VOLTAGE 0.00 -$$SM_SED_FILTER_MODE 0 -$$SM_UED_FILTER_MODE 0 -$$SM_UED_FILTER_VALUE 0.00 -$$SM_ACB_MODE 1 -$$SM_ACB_CONTRAST 3.36 -$$SM_ACB_BRIGHTNESS -5.54 -$CM_SIGNAL SEI -$CM_STAGE_POS -0.169 1.289 7.4 360.0 0.0 0 -$SM_EMI_CURRENT 46.20 -$$SM_PROBE_CURRENT 0.00 -$SM_PENNING_VAC 9.634e-005 -$SM_PRESSURE_AT_LOW_VACUUM 0.000 -$SM_VACUUM_MODE_FOR_SPECIMEN_CHAMBER 0 -$CM_FORMAT JEOL-SEM -$CM_VERSION 1.0 -$CM_COMMENT -$CM_DATE 2010/10/01 -$CM_TIME 08:44:19 -$CM_OPERATOR Blumenthal -$CM_INSTRUMENT 7600F -$$SM_MICRON_BAR 53 -$$SM_MICRON_MARKER 100nm -$CM_FRAME_SIZE 0 0 +$SEM_DATA_VERSION 1 +$CM_SIGNAL_NAME SEI +$$SM_ADD_IMAGE +$$SM_ADD_CHECKED_CH 1 +$$ADD_CH1_SIGNAL SEI +$$ADD_CH2_SIGNAL SEI +$$ADD_CH3_SIGNAL SEI +$$ADD_CH4_SIGNAL SEI +$CM_CONTRAST 2390 +$CM_BRIGHTNESS 544 +$$SM_MIX_IMAGE +$CM_ACCEL_VOLT 1.00 +$SM_ARRIVAL_EMI 0.00 +$SM_GB_GUN_VOLT 3.00 +$SM_GB_BIAS_VOLT 2.00 +$$SM_WD 2.77 +$CM_MAG 50000 +$$SM_COLUMN_MODE GB_HIGH +$$SM_OL_APERTURE 9 +$$SM_CL_COARSE 14 +$$SM_CL_FINE 25 +$$SM_GUN_ALI_TILT 0 0 +$$SM_CL_STIG 0 0 +$$SM_OL_STIG 68 162 +$$SM_OL_STIG_CENTER 0 0 0 0 +$$SM_OLAP_ALI 0 0 +$$SM_PROBE_NO 6 +$$SM_PROBE_FINE 25 +$$SM_ACL_ALI -2 -1 +$$SM_COLUMN_CENTER 0 0 +$$SM_EF_ALI 0 0 +$$SM_SCAN_ROTATION 298.80 +$$SM_WD_CORRECT 0 +$$SM_INTEG_NO 1 +$$CM_SCAN_MODE 3 +$$CM_SCAN_SPEED 9 +$$CM_INSTRUMENT_SCAN_SPEED 9 +$$SM_R_FILTER_MODE 0 +$$SM_SEI_COLLECTOR 0 +$$SM_R_FILTER_INDEX 101 +$$SM_DET_SE1_MODE_NUMBER 0 +$$SM_DET_TTL_MODE_NUMBER 0 +$$SM_DET_SE2_MODE_NUMBER 0 +$$SM_TTL_COLLECTOR_VOLTAGE 0.00 +$$SM_SED_FILTER_MODE 0 +$$SM_UED_FILTER_MODE 0 +$$SM_UED_FILTER_VALUE 0.00 +$$SM_ACB_MODE 1 +$$SM_ACB_CONTRAST 3.36 +$$SM_ACB_BRIGHTNESS -5.54 +$CM_SIGNAL SEI +$CM_STAGE_POS -0.169 1.289 7.4 360.0 0.0 0 +$SM_EMI_CURRENT 46.20 +$$SM_PROBE_CURRENT 0.00 +$SM_PENNING_VAC 9.634e-005 +$SM_PRESSURE_AT_LOW_VACUUM 0.000 +$SM_VACUUM_MODE_FOR_SPECIMEN_CHAMBER 0 +$CM_FORMAT JEOL-SEM +$CM_VERSION 1.0 +$CM_COMMENT +$CM_DATE 2010/10/01 +$CM_TIME 08:44:19 +$CM_OPERATOR Blumenthal +$CM_INSTRUMENT 7600F +$$SM_MICRON_BAR 53 +$$SM_MICRON_MARKER 100nm +$CM_FRAME_SIZE 0 0 $CM_TITLE JEOL SEM - etched sidewall 01 -$CM_LABEL OCPN -$CM_OFFSET 0 0 -$CM_FULL_SIZE 1280 960 -$AN_CURSOR_MEAS_TYPE 0 -$AN_EXPORT_MODE 1 -$CM_COLOR_MODE 0 -$AN_ANNOTATION_MODE 1 -$AN_CURSOR_MEAS $AN_LINE%0 $AN_LINE%1 $AN_LINE%2 $AN_LINE%3 $AN_TEXT%0 $AN_TEXT%1 $AN_TEXT%2 -$AN_LINE%0 440.00000000 0.00000000 440.00000000 959.00000000 65280 1.00000000 0 0 -$AN_LINE%1 840.00000000 0.00000000 840.00000000 959.00000000 65280 1.00000000 0 0 -$AN_LINE%2 0.00000000 280.00000000 1279.00000000 280.00000000 65280 1.00000000 0 0 -$AN_LINE%3 0.00000000 680.00000000 1279.00000000 680.00000000 65280 1.00000000 0 0 -$AN_TEXT%0 5.00000000 874.00000000 215.00000000 910.00000000 "X:" "Courier New" 0 32.00000000 16777215 65793 1 0 -$AN_TEXT%1 220.00000000 874.00000000 430.00000000 910.00000000 "Y:" "Courier New" 0 32.00000000 16777215 65793 1 0 -$AN_TEXT%2 435.00000000 874.00000000 645.00000000 910.00000000 "D:" "Courier New" 0 32.00000000 16777215 65793 1 0 +$CM_LABEL OCPN +$CM_OFFSET 0 0 +$CM_FULL_SIZE 1280 960 +$AN_CURSOR_MEAS_TYPE 0 +$AN_EXPORT_MODE 1 +$CM_COLOR_MODE 0 +$AN_ANNOTATION_MODE 1 +$AN_CURSOR_MEAS $AN_LINE%0 $AN_LINE%1 $AN_LINE%2 $AN_LINE%3 $AN_TEXT%0 $AN_TEXT%1 $AN_TEXT%2 +$AN_LINE%0 440.00000000 0.00000000 440.00000000 959.00000000 65280 1.00000000 0 0 +$AN_LINE%1 840.00000000 0.00000000 840.00000000 959.00000000 65280 1.00000000 0 0 +$AN_LINE%2 0.00000000 280.00000000 1279.00000000 280.00000000 65280 1.00000000 0 0 +$AN_LINE%3 0.00000000 680.00000000 1279.00000000 680.00000000 65280 1.00000000 0 0 +$AN_TEXT%0 5.00000000 874.00000000 215.00000000 910.00000000 "X:" "Courier New" 0 32.00000000 16777215 65793 1 0 +$AN_TEXT%1 220.00000000 874.00000000 430.00000000 910.00000000 "Y:" "Courier New" 0 32.00000000 16777215 65793 1 0 +$AN_TEXT%2 435.00000000 874.00000000 645.00000000 910.00000000 "D:" "Courier New" 0 32.00000000 16777215 65793 1 0 diff --git a/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL_SEM_AutoCal.py b/plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL_SEM_AutoCal.py similarity index 100% rename from Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL_SEM_AutoCal.py rename to plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/JEOL_SEM_AutoCal.py diff --git a/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/Microscope_Calibrations_user_settings.py b/plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/Microscope_Calibrations_user_settings.py similarity index 100% rename from Analyze/Microscope Measurement Tools/MScopeCals - custom function example/Microscope_Calibrations_user_settings.py rename to plugins/Analyze/Microscope Measurement Tools/MScopeCals - custom function example/Microscope_Calibrations_user_settings.py diff --git a/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py b/plugins/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py similarity index 96% rename from Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py rename to plugins/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py index 7665f38..36686ee 100644 --- a/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py +++ b/plugins/Analyze/Microscope Measurement Tools/Microscope_Calibrations_user_settings.py @@ -6,7 +6,7 @@ Make sure the lists `names`, `cals`, `units` and `aspect_ratio` all have the same number of items! -After you edit this file, be sure to delete the corresponding *.pyclass file and restart Fiji for the settings to take effect. +After you edit this file, be sure to delete the corresponding *.pyclass file and restart Fiji for the settings to take effect All of these lists are regular Python Lists, so define them however you prefer to define pythonic lists. You can define them in-line like normal: @@ -81,9 +81,9 @@ opaque white is [1,1,1, 1] """ -linethickness = 5.0 # in pixels -linecolor = [ 0, 0.7, 0, 1.0] -textsize = 50 # text height in pixels, I think +linethickness = 2.0 # in pixels +linecolor = [ 0, 1 , 0, 1.0] +textsize = 18 # text height in pixels, I think textcolor = [ 0, 0, 0, 1.0] textbackgroundcolor = [ 1, 1, 1, 0.4] # background color behind text. #textbackgroundcolor = None # set to None for no background - uncomment this line