Skip to content, Skip to search

Changes

Frequently Asked Questions

3,144 bytes added, 11:28, 15 March 2013
Development: Add entry on getting the source for a command
Thread.currentThread().setContextClassLoader(IJ.getClassLoader());
</source>
 
== How do I see the source code for a command? ==
 
Fiji is open source; as such, it is possible to inspect the source code for any command, in the interest of transparency and reproducibility.
 
Here are several ways to do so:
 
# '''Using the Command Finder:'''
#* Press L for the Command Finder.
#* Type the name of the command.
#* Press the down arrow to select it.
#* Click the Source button.
#* This will open the source from the [http://imagej.net/source/ ImageJ web site online source].
#* Note: this method is very convenient, but only works for core ImageJ sources, not Fiji-specific code.
# '''Using fiji.sc's search:'''
#* Using the Command Finder, locate your command, taking note of the Class column's value.
#** E.g., if we type "make binary" we see that the class is <code>ij.plugin.Thresholder</code>.
#* In your browser, type the name of the class followed by ".java"; e.g.: <code>fiji.sc/Thresholder.java</code>
#* This will automatically perform a search throughout all code known to fiji.sc for that source file. If there are multiple matches, you will see them all. Clicking on a match opens it in the [http://fiji.sc/cgi-bin/gitweb.cgi fiji.sc gitweb interface].
#* Note: this method does a broad search and can find many things, but only Java code. If you want to search for a script instead, you will need to take note of the script argument:
#** For example, in Command Finder, if you type "scale to dpi" you will see that the "Class" is something like: ''Javascript.Refresh_Javascript_Scripts(".../Fiji.app/plugins//Scripts/Image/Adjust/Scale_to_DPI.js''
#** You can find this code by typing: <code>fiji.sc/Scale_to_DPI.js</code>
#** Scripts written in other languages work similarly.
# '''Using GitHub:'''
#* Using the Command Finder, locate your command, taking note of the Class column's value.
#** E.g., if we type "make binary" we see that the class is <code>ij.plugin.Thresholder</code>.
#* Open the relevant project in GitHub:
#** For "ij." classes, go to: https://github.com/fiji/ImageJA
#** For "fiji." and many other package prefixes, go to: https://github.com/fiji/fiji
#* Press the T key, and type the name of the file you are looking for.
#** In the example above, this is Thresholder.java.
#* You should end up with a hit like: https://github.com/fiji/ImageJA/blob/master/src/main/java/ij/plugin/Thresholder.java.
#* This method requires that you know in which repository the code lives. However, you can combine it with the '''fiji.sc search''' method above to figure out which repository, then load the code on GitHub, if desired.
# '''Using the "Open Source for Menu Item" command:'''
#* Run Plugins > Scripting > Open Source for Menu Item.
#** Unfortunately, you must select this from the menu, not using the Command Finder.
#* Run the command whose source you want to see.
#** E.g., Process > Binary > Make Binary.
#** Again, select it from the menu directly, not using the Command Finder.
#* This will open the source using the [http://fiji.sc/cgi-bin/gitweb.cgi fiji.sc gitweb interface].
 
In the future, we plan to make this easier by having one single easy command for viewing the source code.
= Community =
Bureaucrat, emailconfirmed, incoming, administrator, uploaders
12,247
edits