# 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:

![](/files/-MUQV4eqR8lkfaCZnvTR)

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.

![](/files/-MUQV4erSJSkzmfAOTMz)

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stitchit.mouse.vision/new-users/how-do-i.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
