# How to...?

## How do I pre-process the data?

To pre-process all data from channels 1 to 3 run:

```
preProcessTiles([],'illumChans',1:3)
```

This will calculate average tiles for each section as well as various stats that can be of use later. Once that's finished run:

```
collateAverageImages
```

That will build grand average tiles used for illumination correction of stitched images.

## How do I stitch sub-sets of the data?

Assuming the data have been pre-processed run:

```
>> cd /mnt/myLocalData/mySample

%Stitch all data from channel 1:
stitchSection([],1) 

%Stitch physical section 34, optical section 3 from chan 1:
stitchSection([34,3],1)

%Same thing but stitch the first three channels
for ii=1:3
  stitchSection([34,3],ii)
end


%Stitch all from channel 2 and save original size and 25% size:
stitchSection([34,5], 1, 'stitchedSize', [100,25]) 

% Stitch all channels:
stitchAllChannels
```

## How do I load individual tiles?

Once the `generateTileIndex` function has been run, you can load any raw data tile using the `tileLoad` function. This function can also be used to load all tiles from one optical section. See `help tileLoad`

## Interrogate stitching accuracy?

You may notice that something is not right with your stitching accuracy if you see doubled features such as this:

![](https://2983815501-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MUPFJR1UB3NR7wtvls1%2Fsync%2F69511461a0b290b4a70e86d52e6bfcfe4c64eb6c.jpg?generation=1614295359695784\&alt=media)

An effective way of further exploring tile placement accuracy is to use "chessboard stitching". This is an option in the `stitchSection` command (`chessboard`) that produces chessboard-like RGB images. Here the ID of each tile is printed on the image and overlapping regions are shown in yellow.

![](https://2983815501-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MUPFJR1UB3NR7wtvls1%2Fsync%2Ffe677045bfaa358ba6d40a18ec7cc83a81c41d32.jpg?generation=1614295360218956\&alt=media)

If you are using BakingTray, you can [tweak slightly the Voxel Size parameters in the recipe file](https://github.com/raacampbell/stitchit_docs/tree/0beaf9ad881e98e11cd5caeae579f77d953e24dd/Fine-tuning-positioning-accuracy.md) until you get better results. If you continually need to do this, then the BakingTray settings file itself ought to be updated with these new stitching parameters.

## Correct changing illumination with optical plane?

Use [correctZilluminationInDirectory](https://github1s.com/SainsburyWellcomeCentre/StitchIt/blob/master/code/+stitchit/+artifactCorrection/correctZilluminationInDirectory.m).

## How do I interact with the INI file?

* To see which INI file is being used: `which('stitchitConf.ini')`
* Return the INI file as a MATLAB structure: `myINI=readStitchItINI`
* Print all keys to screen (includes duplicate keys): `stitchItINIkeys`
* Make a local INI file in the current directory: `makeLocalStitchItConf`
* To edit the INI file from the command line you can do: `StitchItSetConfigValue('doPhaseCorrection',1)` and you can confirm it worked by doing: `showStitchItConf` and checking that the value is now 1
