Useful Functions for Fiji Macros - stoeter/Fiji-Tools-for-HCS GitHub Wiki

Table of Contents

Useful Functions for Fiji Macros

  • This section lists some useful functions for development of new Fiji macros
  • So far these function are helpful for:
    • handling and listing file/folder lists
    • filtering lists (in Fiji = arrays)
    • finding unique values in lists
  • All function here start with the name 'get' if the function returns a value or array
  • Copy & paste these functions at the and of your macro code and call them within your code
  • For questions, bugs, requests... please contact stoeter at mpi-cbg.de

Fiji functions for files/data input


Find all files from folders and subfolders (getFileListSubfolder)

  • Input:
    • a path that will be searched for files
  • Output:
    • an array with all found files
  • Reports:
    • Log window: number of found files
    • Array window: all files with complete paths that were found
  • Dependencies:
    • directory name (string)
    • display array window (boolean)
  • Example:
myFileList = getFileListSubfolder("/home/myFolder/", true);

Find all folders from a folder (getFolderList)

  • Input:
    • a path that will be searched for folders
  • Output:
    • an array with all found folders
  • Reports:
    • Log window: number of found folders
    • Array window: all folders with complete paths that were found
  • Dependencies:
    • directory name (string)
    • display array window (boolean)
  • Example:
myFolderList = getFolderList("/home/myFolder/", true);

Filter a list of files/paths for a certain file extension (getFileType)

  • Input:
    • a list/array of files/paths
  • Output:
    • a list/array of files with certain extension
  • Reports:
    • Log window: number of found files with certain extension
    • Array window: all files with complete paths with certain extension
  • Dependencies:
    • list of files/paths (array)
    • file extension (string)
    • display array window (boolean)
  • Example:
myFileList = getFileType(myFileList, ".tif", true);

Filter a list of files/paths for a certain string/text inside the path (getFilteredFileList)

  • Input:
    • a list/array of files/paths
  • Output:
    • a filtered list/array of files with/without certain string/text
  • Reports:
    • Log window: number of found files with certain strings/text
    • Array window: filtered files/paths for certain strings/text
  • Dependencies:
    • list of files/paths (array)
    • additive(AND)/subsequent(OR) filtering (boolean)
      • hint: if true (= OR), then e.g. file names containing "H08" or "D04" are in the filtered list
      • hint: if false (= AND), then e.g. file names containing "controls" and "positive" are in the list (but not the negative controls)
    • display array window (boolean)
  • Dependencies (global variables):
    • hints:
      • define text to be filtered in array filterStrings (default = 3, but can be extended)
      • define filter type in array filterTerms ("include" = files containing this string will be kept in the list, "exclude" = files not containing this string will be filtered out of the list, "no filtering" = for this string filter is not applied)
      • possible filter types are: "no filtering", "no filtering", "no filtering" (availableFilterTerms)
      • to create a dialog/user interactivity use the this function in combination with the setDialogImageFileFilter
    • e.g. copy/paste this at the beginning of the macro:
var filterStrings = newArray("","","");                                      //pre-definition of strings to filter
var availableFilterTerms = newArray("no filtering", "include", "exclude");   //dont change this
var filterTerms = newArray("no filtering", "no filtering", "no filtering");  //pre-definition of filter types 
  • Example:
    myFileList = getFilteredFileList(myFileList, false, true);
  • The function: .ijm here

Opens a dialog window to user define the test filters (setDialogImageFileFilter)

  • Input:
    • none
  • Output:
    • none (changes variables)
  • Reports:
    • none
  • Dependencies (global variables):
    • hints:
      • set global variables to have default values
      • see explanation of variables and filter here
    • copy/paste this at the beginning of the macro:
var fileExtension = ".tif";                                                  //pre-definition of extension
var filterStrings = newArray("","","");                                      //pre-definition of strings to filter
var availableFilterTerms = newArray("no filtering", "include", "exclude");   //dont change this
var filterTerms = newArray("no filtering", "no filtering", "no filtering");  //pre-definition of filter types 
var displayFileList = false;                                                 //shall array window be shown? 
  • Example:
    setDialogImageFileFilter();
  • The function: .ijm here

Fiji functions for lists/arrays

Filter a list for a certain string/text (getFilteredList)

  • Input:
    • a list/array
    • string to be found in list values
  • Output:
    • a filtered list/array with certain extension
  • Reports:
    • Log window: number of values in list after filtering
    • Array window: all list values after filtering
  • Dependencies:
    • list of strings (array)
    • filter string (string)
    • display array window (boolean)
  • Example:
myList = getFilteredList(myList, "myText", true);

Find unique values in list (getUniqueArrayValues)

  • Input:
    • a list/array
  • Output:
    • a list/array of unique values
  • Reports:
    • Log window: number of unique values found in list
    • Array window: all unique values
  • Dependencies:
    • list of strings (array)
    • display array window (boolean)
  • Example:
    myUniqueValues = getUniqueArrayValues(myList, true);
  • The function: .ijm here

Find unique wells in file list of CV7000 (getUniqueWellListCV7000)

  • Input:
    • a list/array of files/paths from CV7000
  • Output:
    • a list/array of unique wells
  • Reports:
    • Log window: number of unique values found in list
    • Array window: all unique values
  • Dependencies:
    • list of files/paths from CV7000 (array)
    • display array window (boolean)
  • Example:
myUniqueWells = getUniqueWellListCV7000(myList, true);

Find unique well fields in file list of CV7000 (getUniqueWellFieldListCV7000)

  • Input:
    • a list/array of files/paths from CV7000
  • Output:
    • a list/array of unique well fields (e.g. G10_T0001F001)
  • Reports:
    • Log window: number of unique values found in list
    • Array window: all unique values
  • Dependencies:
    • list of files/paths from CV7000 (array)
    • display array window (boolean)
  • Example:
    myUniqueWellFileds = getUniqueWellFieldListCV7000(myList, true);
  • The function: .ijm here

Find unique channels in file list of CV7000 (getUniqueChannelListCV7000)

  • Input:
    • a list/array of files/paths from CV7000
  • Output:
    • a list/array of unique channels (e.g. C01)
  • Reports:
    • Log window: number of unique values found in list
    • Array window: all unique values
  • Dependencies:
    • list of files/paths from CV7000 (array)
    • display array window (boolean)
  • Example:
    myUniqueChannels = getUniqueChannelListCV7000(myList, true);
  • The function: .ijm here

Issues

  • make them available in Fiji by writing selected function of log or test window for copy paste
  • re-write funtions in java and packages as .jar, then functions can be called easily within the macro and copy/paste becomes obsolete

Latest changes

  • second release 16-03-2015: re-writing functions as individual file that are concatenated by script
    • re-writing of wiki documentation
  • first release 20-01-2015: release of all developed functions so far
⚠️ **GitHub.com Fallback** ⚠️