Updated: 2026-06-02
This repository is a remote version of
Drive 8\Alex\4_IJ Macros. Copies of scripts in other places are not maintained and are likley dated.
Still haven't made peace with Groovy's grammar yet. These are just some basic stuff.
-
saveRegions: Export all annotations to .tiffs for downstream analysis.
-
annotatedInfo: Prints in terminal the number of annotation in each image in the project. I made this as a quick way to check which image has been annotated.
-
annotatedInfo_count: Does everything annotatedInfo does, but also count annotations that belongs to two classes of one's choice. (can be more, but only 2 was needed when this was initially made) Export the number of annotations belonging to each class in each image to a csv file.
-clearEnvironment: A snippet for quickly resetting the environment to initial state. Useful for testing. (I usually write this in as a function for longer scripts so that it can be called between each step)
-
Folder_Split_ScaleBar_customizable: General use tool that processes a whole folder of the same type of images. Allow user to choose between brightfield (only adds scalebar) and fluorescent multichannel (splits channel and adds scalebar to a composite image) and customize scalebar features.
-
Single_Split_ScaleBar_customizable: The same thing as the one above but only executes on one file. Good for testing what you want before processing the batch.
-
saveAllOpenImgs: Self explanatory. Save everything that's open to a specified folder with the current window titles, then close all open images. (Good for selecting ROIs in QuPath, then sending them all to IJ and running this to save them.)
-
folderSplitChannel: Splits all multichannel tiffs in a folder and save them to another folder. Intended for preparing single channel images for downstream analysis.
-
QB_quickSB: Intended to be used in the ImageJ script runner in QuPath. Please see accompanied pdf guide for details.
-
saveRegions.groovy: Groovy script to export ROI annotations in Qupath. It will save all annotations as tiffs in
PROJECT_BASE_DIR/Export. Original annoation borders are preserved as overlay. -
renamer.groovy: Batch renamer tool for QP image entries. Usually uses this to trimm the additional image info generated upon importing from a .vsi file.
-
generalPurposeAllOpenFiles_template: A template for creating more scripts that apply a set of actions to all open images.
-
axonCount_v3: Count number of axons and their area sizes in an ROI by NFH signal. V3 improved image sementation method to detect axons more reliably.
-
axonCount_v3_maskMaker: Output segmented binary mask images that axon detection is based on. Used to check segmentation quality or for other downstream analyses.
-
AxonalTDP_single_full: For measuring TDP-43 in white matter tracts in spinal cord. Takes green(c2) TDP and red (c3) NFH. This script looks for a round NHF+ area that is representative of a crossected axon. Current analyze particles parameters are set to 1-200 px; 0.5-1 cir. Measures area and mean.
- Ataxin2Intensity: For measuring intensity of Ataxin-2 and related proteins of interest in neurons. PABP1 and TDP-43 agg co-loc analysis will be added in the future.
-
S1R_SSC_counter_new: For analyzing cell and subcellular features in the S1R project. Input: 3 channel (DAPI, TRTIC, Cy3) tiff with an existing selection overlay. Segments cell body outline with Cy3 (should be smaller than the exisiting overlay) and get mean in TRITC and Cy3. For TRITC and Cy3 channel, also segment individual puncta using Niblack from the auto local threshold plugin. Segmented puncta are then filterd by a z score (curretly z=0) before measurements are generated. Measurements: mean, area, center of mass (x,y). Also outputs an image showing outlines of all segemented features overlayed on the origianl image, but this is currently a bit buggy (ROI that were filtered out and removed from ROI manager are still showing up.) Outputs tiff and csv.
-
S1R_SSC_counter_new_coloc: An addition to the
S1R_SSC_counter_newscript that added additionall colocalization measurements (object based overlap proportions). Outputs tiff and 2 csvs: One is the same results file asS1R_SSC_counter_new, additionally a coloc.csv that contains coloc measurements. -
S1R_data_merge.py: Processes the two csvs (
Results.csvandColoc.csv) by combining their data and organize into a hierachical and (hopefully) easier to interpret structure. Outputs a xlsx file.
-
NPCMeasurementNormalized: Takes folder input. Measures the intensity of c3 at nuclear envelope (defined as a 1px line along the nucleus) and inside the nucleus (for normalization.) Currently needs to manually select desired ROI after segmenting. Output data to a spreadsheet at a path of choice.
-
CRM_neurons_new: Takes folder input and output measurements to an .xslx in downloads folder (designed for multiple folders that belongs to the same dataset, fixed output to avoid having to specify output every time a diff folder is processed.) Needs manual selection of target cell nucleus after auto thresholding, then measures CRM (XPO-1) intensity at the nucleus and cytoplasm (defined by the 1.5px "doughnut" around the nucleus, for the lack of better ways to reliably define cytoplasm.) Data is saved to account for the special file naming scheme in generation of the source tiff images. It also adds the cell CRM type classification (which was stored in the tiff file name) into measurement results for ease of organization. Each case (input folder) is saved as a separate sheet in the same xslx file.
-
CRM_MicroGlia_new: The microglia version of the script above. Fully automated. Nucleus is segmented and those with bad IBA1 overlap (<50%) is removed, then only the largest object is kept (remove random nuc fragments that might got included on the edge). Measures CRM intensity at nucelus and cytoplasm (created by subtracting nucleus region from full IBA1 ROI.) Improved log function compared to the neuron version.
These scripts are either 1) not working as intended or 2) have better alternatives in the list above. They are included here purely for documentation purposes.
-
S1R_cellArea_SSCCountArea
(obsolete)Replaced by S1R_SSC_counter_new: Analyzes the S1R channel. For measuring 1) cell area and 2) individual SSC count/area/mean in each cell. Outputs an annotated merged image of the detected cell border/SSC borders for manual review and a csv of all measurements. Works most of the time but there are about 10% of cases where the segmentation fails, esp SSCs. -
MicroGliaXPO
(obsolete)Replaced by CRM_MicroGlia_new: For a given input folder, detects all nuclei that have overlap with microglia marker IBA1, segment these regions and measure the XPO (c2, green) intensity in these regions. Export measurements to an excel sheet at a specified output folder. Measurement from diff files will be saved as adjacent columns in the same spreadsheet. Also saves a binary tiff of the region being measured from each input file in the output folder. -
CRMnuc
(obsolete)Replaced by CRM_neurons_new: Measures the intensity of C2 in the nucleus and the cytoplasm area immediately surrounding it. The later is measured for calculating N/C fraction. Currently this only works with one image open. -
BFscalebar50_allOpenFiles
(obsolete): Adds a horizontol 50 μm 20 px black scale bar with 30pt text to the bottom right of each image and flatten it, then closes the orignal images. -
BFscalebar50_notext_allOpenFiles
(obsolete): Same but doesn't have text. -
BFscalebar50_single
(obsolete): Only processes the currently selected image. Use this if the allOpenFiles versions are buggy. -
BFscalebar100
(obsolete): The 100μm version of BFscalebar50. Note that this also only processes the currently selected image. -
scalebar100split
(obsolete): Scale bar script for multichannel images. Split the channels and add a white 100μm scale bar (20px, bottom right, 30px text) to the composite RGB image. This script is intended for creating images for presentation, NOT analysis. What this means is that it changes individual channel files to RGB color mode. Currently needs to manually save the files after they are created. -
removeholes and removeholes_manual
(broken): Was an attempt at a quick way to segment the area containing tissue vs background using QuPath' IJ script runner. Couldn't find a way to process the image so that the foreground can be consistently and correctly detected when the beginning signal levels vary. Tried circumventing this issue by prompting manual thresholding from user ("manual") but it keeps breaking in QP's IJ instance for some reason.