Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Macklin-Lab/imagej-microscopy-scripts

Repository files navigation

Macklin lab macros and scripts for Fiji/ImageJ

Welcome to the Macklin lab macros, scripts, and other microscopy processing fun!

This repository contains a series of short ImageJ/Fiji plugins and scripts that perform tedious image manipulation tasks common in our lab. This central README contains documentation for using all of the plugins. If you find problems or would like to make improvements, please fork the repository and submit a pull request. If you don’t want to modify the code, you can also email me (Nick) at:

nicholas.m.george@ucdenver.edu

This repository is licensed under the Mozilla Public License 2.0. Free software license (https://choosealicense.com/licenses/mpl-2.0/, https://www.gnu.org/licenses/license-list.en.html#MPL-2.0) Please feel free to use the provided code and incorporate it into your work, but please give us a shout out if you do and share the source code of your changes.

make your own

If you know a little bit of a scripting language, I am working on a guide for working with Java from a script in ImageJ here. Please let me know if it helps or if you want any improvements!

Installation

I made an update site (search Lab-utility-plugins) for these plugins. Now, to install you simply add the update site to Fiji.

Quick install: Open Fiji, and under the Help menu click Update. Once Fiji finishes checking for updates do the following:

  1. Click Manage update sites
  2. Scroll and find Lab-utility-plugins and check the box.
  3. Click Close
  4. Click Apply changes
  5. Restart Fiji

Summarized below: img/install-simple.png

Please ensure that you have the latest Fiji downloaded and installed on your computer. Fiji (batteries included ImageJ) will be the only requirement for this set of plugins. You will now get updates automatically.

The plugins will be in the “Plugin” menu all the way at the bottom. On Mac OSX it looks like this: img/plugin-location.png

Note:

I use ImageJ script parameters https://imagej.net/Script_Parameters for UI design with these Jython (python on the JVM) scripts. Scrip parameters are awesome. Let me know if you want other options set.

composite quick key

A very simple but useful script that changes the display state of the active image to composite if it is color or greyscale, and to color if it is composite. I recommend binding this function to a keyboard shortcut for best quick results. Plugins>Shortcuts>Add Shortcut… Then select the key and the file composite quick key and you should be all set!

blind-files

This plugin blinds files– that’s it. It uses the Jython implementation of universally unique identifiers (UUIDs) to generate the new, unique blinded names for your files, and then simply copies them to a newly created directory.

When you launch it, you will see the following interface: img/blind-files-interface.png

Inputs

  1. Select the folder containing the images you want to blind.
  2. file ending of the files you want to blind.
    • Note Sometimes folders contain other files that you don’t want to blind as part of your analysis. For example, I typically have a metadata file along with the tif’s that I don’t need to blind. For this reason, I filter based on file ending– though there is no technical reason why you need to do that. If you want other file types supported, please let me know. I can also just add an empty field for you to enter your file endings of choice, but for now I think this works.

An example input directory may look like this: img/blind-files-input.png

Outputs

  1. The plugin will make a new folder in your chosen folder called blinded and will copy your images with new random names into it.
  2. In the original folder you will find a KEY.csv, which contains a column with the old names and a column with the new names.
  3. Inside the new blinded directory you will find your photos and a blinded-key.csv file with the blinded names on it as a list. The blinded-key is just so you can then write notes or whatever next to the blinded names, then you can easily merge it with KEY.csv in excel or whatever when you want to un-blind the results.

This plugin does not modify the original files, it only copies and renames the files. For this reason, I haven’t had the need to un-blind the images, as you have keys and retain the originals. If you want to unblind them too, I can add that but let me know why.

Below is a picture of the folder structure after running this plugin. img/blind-files-output.png

tif-convert

Under active development!

This script is meant to use Fiji and bioformats to convert images from many different proprietary vendor types to the easy to work with tif format.

Supported image types

  • Zeiss czi
  • Zeiss lsm
  • Nikon nd2
  • Olympus oib
  • Leica lif

Not yet supported but planned

  • Slidebook sld
  • tiled lif’s lif
  • Volocity mvd2

Basically anything Bioformats can open. Let me know what you need.

Inputs

  1. a directory of files with one of the currently supported file endings.

The UI for this scipt is very minimal. You simply get a choose a folder dialogue. Here is a picture of an example folder with all the supported file types in it: img/tif-convert-input.png

Outputs

  1. a new directory called converted-tif
  2. tif files with formatted names in the new directory.

Note

I do a little text processing of image names in this one in order to clean stuff up (i.e. remove spaces and the old .XXX format). If you have specific naming concerns, especially in the archive formats (.lif) please let me know and I can modify it to be more generic or suit your needs.

Below is what your folder will look like after running it. img/tif-convert-output.png

Planned features

  • Leica tiled images

Right now, if you want separate tiles saved this script won’t work. It will continually overwrite the individual tiles. The tiled image is fine, just the individual tiles aren’t converted correctly.

Batch projector

img/batch-project.png

Very simple script that will batch project your images using one of the offered imageJ methods. This will format the names nicely and save them in a sub directory as well.

NOTE If you are doing something like fluorescence intensity measurements on projected images, you need to project with SUM projection rather than max projection. See: http://forum.imagej.net/t/measuring-fluorescence-intensity-on-a-z-stack/7485 and https://www.ncbi.nlm.nih.gov/pubmed/17210054 There are numerous other caveats to fluorescence intensity as well… more here in the future.

take-roi

Under active development! Sometimes you want to apply a single ROI to a directory full of images. That’s what this plugin started as, but I am developing it to add a few other useful features as well.

Inputs

  1. a directory of images
  2. a file type
  3. an ROI
    • This MUST be an ROI generated by the ROI manager and saved as .roi

Currently, the interface looks like so: img/take-roi-interface.png

Outputs

  1. A subfolder called cropped with the cropped images.

New features:

  1. random ROI, same for each image
  2. Random series of ROIs from each image.
  3. Systematic random sampling ROIs

Other script ideas?

Don’t waste your time by repeating yourself (follow DRY– don’t repeat yourself). We can work together to reduce boring work so you can spend more time with the important stuff (you know, reading, doing experiments, and beer. definitely beer). Let me know if you run into any problems or have ideas for other scripts.

Write your own

If you know a little bit of a scripting language, I am working on a guide for working with Java from a script in ImageJ here. Please let me know if it helps or if you want any improvements!

split-channels

in progress working on this one (2018-07-03), suggestions welcome.

Planned features:

  1. batch split image channels, format names appropriately
  2. Save image channels to their own appropriately named folders

Inputs

  1. image directory
  2. list of channel names (optional)

Outputs

  1. directory for each channel and single channel images in each

lif-tiles

!Don’t use this…! I have this here so that I can eventually merge it with tif-convert.

This is an experimental script that will convert and save all the individual tiles in a lif archive containing a tiled image in their own appropriately named directory. This is a very rough script I wrote in a hurry. I would NOT recommend using it yet. I plan to merge it with tif-convert but have not gotten the chance yet. Let me know if you need this functionality and I will fix it.

CHANGELOG

2018-10-22

  • updated blind-files_.py to accept other common microscopy file endings per #1
  • added console logging to blind-files_.py and tif-convert.py

2019-06-14

added composite quick key. A quick shortcut for changing the display state of an image.

About

Welcome to the Macklin lab macros, scripts, and other microscopy processing fun!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages