Skip to content

Developer notes

Rob Campbell edited this page Mar 13, 2017 · 9 revisions

Overall processing pipeline

Each sample is contained in its own directory. Before processing, the directory structure should look like this:

sampleDir/
sampleDir/acquisitionSettingsFile
sampleDir/rawData/chan1/...
sampleDir/rawData/chan2/...
sampleDir/rawData/chanN/...

The key principle of StitchIt is that the raw data are left untouched but are loaded using the tileLoad function which is able to apply corrections and transformations on the fly. The sequence of operations that produces stitched images is as follows:

  • generateTileIndex determines the location of each tile in the final 3-D stack. This step is especially important for TissueVision data.
  • preProcessTiles calculates things such as the average tile for background image subtraction and other statistics. An average image is calculated for each section, optical section, channel, and odd/even row in the tile pattern (these latter can be optionally averaged together). Calculating the average on a per-section basis allows the process to be conducted incrementally during acquisition at the expense of a small increase in the size of the raw data directory.
  • collateAverageImages produces grand average images over all sections and saves these.
  • The tileLoad function can be used to load individual tiles or all tiles from a single optical plane.
  • stitchSection uses tileLoad to load an optical plane into RAM then it assembles that optical plane into a stitched section. This is saved to a directory called stitchedImages_100/chanN. (The "_100" indicates full-sized, 100%, images).

Adding new variables to the INI file

The INI file reader, readStitchItINI, reads both the user's INI file and the default INI file that comes with StitchIt. If you wish to add a new variable then all existing INI files out in the wild won't have this variable. To get around this problem, all you have to do is define your new variable in the default INI file stitchitConf_DEFAULT.ini and set it to a sensible value. e.g. If you new variable is used to enable/disable adding a smiley face on top of each stitched section, then obviously set this behavior to be disabled since most people won't want this. You can then add this variable to your own personal INI file and enable it.

Stub functions and working with different microscopes

StitchIt is designed to be able to cope with different microscope systems. As a result, you should avoid writing functions that assume a particular microscope system is being used. The most simple way of avoiding this is to include switch statements in your code:

switch determineStitchItSystemType

    case 'TissueCyte'
        % Do TissueCyte stuff

    case 'BakingTray'
        % Do BakingTray stuff

    case 'Z_SlideScanner'
        % Do Zeiss slide-scanner stuff

end

However, this would quickly become annoying and it would be hard to figure out which functions have microscope-specific code. StitchIt has a better solution. Certain functions are abstract. e.g. if you run tileLoad, a stub function in code/SystemFunctionStubs is run. This function determines which imaging system is being used and then calls a system-specific version of tileLoad based on this.

For an example of how the system works see the directoryBaseName stub function. This uses returnSystemSpecificClass to identify which acquisition system is being used and return correct class: Either the BakingTray directoryBaseName or the TissueCyte directoryBaseName. This process is transparent to the user. If they type help directoryBaseName they see the doc text from the stub function. If you modify these system-specific files (e.g. to fix bugs or add features) you will usually have to run clear classes before your changes come into effect. Adding the ability to handle data from a new imaging system is just a matter of writing a new set of system-specific functions, since everything else should work without modification.

If you add a new system-specific method it is good form to add it to the abstract class micSys. Note the existence of the class definition files tissuecyte and bakingtray.