Macros - UU-cellbiology/BigTrace GitHub Wiki
The plugin is scriptable in two ways:
- using ImageJ/FIJI macro environment via extension interface (see IJ macro usage below);
- and using groovy scripts (see Groovy scripting paragraph below);
IJ macro usage
A set of BigTrace commands/functions are available using "Ext." namespace.
To start, you always need to run BigTrace on some image file and then call the function, for example:
run("Open 3D image", "open=C:/path_to/my_file.tif"); //open my_file.tif in BigTrace
Ext.btLoadROIs("C:/path_to/Rois_btrois.csv", "Clean"); //load ROIs from file
//run other commands ...
//open a new file in the same BigTrace instance
Ext.btOpenNext("C:/path_to/my_next_file.tif");
//run other commands ...
Ext.btClose(); //close BT
If you want to open a new (next) file in the same BigTrace instance, use Ext.btOpenNext command.
If you would use run("Open 3D image", "open=...), it will make a new BigTrace instance.
An example of batch processing files macro is available here.
The description of available commands is shown below.
If you want new ones to be implemented or tweak existing ones, please reach out.
Settings
Ext.btShapeInterpolation (String sShapeInterpolation, Integer nSmoothWindow)
Specifies current ROI Shape Interpolation.
The first string parameter should be either "Voxel", "Smooth" or "Spline".
The second integer parameter specifies the smoothing window.
Ext.btIntensityInterpolation (String sIntInterpolation)
Sets current intensity interpolation.
A single string parameter with possible values of "Neighbor", "Linear", or "Lanczos".
Ext.btSetActiveChannel (Integer nActiveChannel)
Specifies the channel used for tracing and measurements (channel numbering starts from 1).
Ext.btSetMeasurements (String sListMeasurements)
Specifies which parameters are measured. The list of all options is here.
The string must contain some of the parameter names shown in dialog/described on wiki,
the upper/lower case or separator does not matter (example "Volume;SD of intensity; Length").
Ext.btSetTracingThickness (Double sigmaX, Double sigmaY, Double sigmaZ)
Sets the approximate thickness of curves in each dimension for semi-auto, one-click and full-auto tracings (in pixels!).
Those are the values set for General tracing parameters.
Ext.btSetTracingROI (Boolean bEnable, Double dCoeff, String sMethod)
Sets the diameter of ROIs created by semi-, one-click and full-auto tracing routines
using values of "tracing thickness". Basically, the same as in General tracing parameters panel (see for more details).
ThebEnablestring can have values "true" and "false", activating this feature.
dCoeffvariable specifies a multiplication factor used to calculate the diameter
usingsMethod("MAX", "AVG" or "MIN") from tracing SD thickness along all the dimensions (see above).
Ext.btSetOneClickParameters (Integer nVertexPlacementPointN, Double dDirectionality, Boolean sOCIntensityStop, Double dMinIntensityThreshold)
Sets parameters for one-click tracing.
nVertexPlacementPointNis a "distance" between intermediate vertex placement (pixels, >=3). Specifies how often intermediate points (vertices) will be placed on the curve during auto-tracing.
dDirectionalityis the value for the directionality constraint.
sOCIntensityStopis logical ("true" or "false"), whether to stop tracing if the current curve passes through
a voxel with intensity belowdMinIntensityThreshold.
Commands
Ext.btOpenNext (String sFilename)
Removes currently loaded image from BigTrace and loads a new one. Also deletes all existing ROIs. The full path and filename on the new image must be provided in
sFilename.
btRunFullAutoTrace (Double nMinIntensity, Integer nMinNumPoints, Integer nFirstFrame, Integer nLastFrame)
Launches Full auto tracing with provided parameters values:
nMinIntensityis the minimum intensity to start tracing curve;
nMinNumPointsspecifies the minimum number of points in a curve;
nFirstFrameandnLastFrame(optional) specify the time range. When omitted, all time points are traced.
Additional parameters can be set up using settings function above.
Ext.btStraighten (Integer nStraightenAxis, String sOutputFolder, String sShape)
This command runs straighten function on all visible ROIs in the list.
It takes an integer and two strings as arguments:
Ext.btStraighten(1, "C:/path_to_store_output/", "Round");
ThenStraightenAxisinteger specifies the axis of the output, which becomes the centerline of an ROI curve.
The value of 0 corresponds to the X axis, 1 to Y, and 2 to Z.
Note that the output depends on the Intensity Interpolation and ROI Shape Interpolation,
which can be specified by the two functions above.
The string argumentsOutputFolderis the path to the folder for the output.
ThesShape(optional) string argument specifies the shape of the extracted volume around the centerline,
it could be either "Square" (default) or "Round".
Ext.btMeasureAndSave (String sFile)
Measures all present ROIs and stores results in CSV format in the provided file (sFile supposed to have path and filename). The measurements can be specified by calling
Ext.btSetMeasurements.
Ext.btClose ()
Closes the current session of BigTrace (if there is one). It is called
macroCloseBTin groovy interface.
ROIs IO
Ext.btLoadROIs (String sFile, String sMode)
Takes two string arguments as input:
Ext.btLoadROIs("C:/path_to/Rois_btrois.csv","Clean");
The firstsFileparameter is the full path to ROIs csv file. The secondsModeparameter can be "Clean", i.e. delete all ROIs and load new ones from the file.
Or it can be "Append", so the newly loaded ROIs will be added to existing ones.
Ext.btSaveROIs (String sFile, String sMode)
Takes two string arguments as input, for example:
Ext.btSaveROIs("C:/path_to/Rois_btrois.csv","CSV");
The firstsFileparameter is the full path + filename for saving.
The secondsMode(optional) parameter can be "BigTrace" (default), "CSV", or "SWC".
Appearance
Ext.btSetDisplayRangeGamma (Double minIntensity, Double maxIntensity, Double dGamma, Integer nChannel)
Sets parameters of first two sliders in the Brightness and color (and opacity), responsible for the intensity to LUT mapping. The
minIntensityandmaxIntensityspecify the first range slider values. The (optional)dGammacorresponds to the gamma value of the second slider. In case of a multichannel image, the optionalnChannelparameter applies the provided values to the specified channel (numeration starts from 1). If omitted, settings are applied to all channels.
Ext.btSetAlphaRangeGamma (Double minAlpha, Double maxAlpha, Double dGammaAlpha, Integer nChannel)
Sets parameters of last two sliders in the Brightness and color (and opacity), responsible for the intensity to opacity mapping. The
minAlphaandmaxAlphaspecify the alpha range slider values. The (optional)dGammaAlphacorresponds to the gamma value of the last slider. In case of a multichannel image, the optionalnChannelparameter applies the provided values to the specified channel (numeration starts from 1). If omitted, settings are applied to all channels.
Groovy scripting
Alternatively, BigTrace can be scripted in groovy.
You need to invoke a BigTrace instance and its btMacro variable gets access to macro commands.
The commands are the same as in IJ macro described above, only instead of the bt prefix you should use the macro prefix.
All functions with macro prefix are documented in BigTraceMacro.java file.
An example of a simple groovy script:
import bigtrace.BigTrace
BT = new BigTrace();
BT.run("/home/path_to/myfile.tif"); //open first image
BT.btMacro.macroLoadROIs("/home/path_to/ROI_file_bt.csv", "Clean");
BT.btMacro.macroRunFullAutoTrace(230., 10, 0, 0);
BT.btMacro.macroSaveROIs("/home/path_to_save/rois.csv", "CSV");
BT.btMacro.macroOpenNext("/home/path_to/next_file.tif"); // open another image in the same instance
BT.btMacro.macroClose();
And here is a full example of a groovy script for batch processing of many files.