Commit af175b20 authored by Saad Jbabdi's avatar Saad Jbabdi
Browse files

tidying

parent a27e8595
......@@ -157,10 +157,12 @@ def main():
parser = argparse.ArgumentParser(
"Select zone of interest in an image"
)
parser.add_argument('--overwrite', action='store_true', help='Overwrite output directory if it exists')
required = parser.add_argument_group('Required arguments')
required.add_argument("-i","--input", required=True, help="Input file name of main image including extension.")
required.add_argument("-o","--output_folder", required=True, help="Name of output folder.")
required.add_argument("-i", "--input", required=True, help="Input file name of main image including extension.")
required.add_argument("-o", "--output_folder", required=True, help="Name of output folder.")
optional = parser.add_argument_group('Optional arguments')
optional.add_argument("--overwrite", action='store_true', help='Overwrite output directory if it exists')
args = parser.parse_args()
# DO ALL IMPORTS AFTER PARSING
......
Cell Counting Project
-- Install Instructions
git clone https://git.fmrib.ox.ac.uk/saad/CellCounting.git
cd CellCounting
pip install .
-- Howto?
......@@ -2,7 +2,7 @@
---
## Install Instructions
## Installation Instructions
```
git clone https://git.fmrib.ox.ac.uk/saad/CellCounting.git
......@@ -16,38 +16,116 @@ pip install .
Most of the tools have a wrapper script that can be called from the command line. Below are examples of how to use these command line tools:
- Building a cell database
### 1. Building a cell database
This is done in three steps.
* select_zones.py :
First, a high resolution whole brain slide is loaded to a basic visualiser. The visualiser allows the user to zoom in and out and to change the contrast. Crucially, it allows the user to select sub-regions of the image for subsequent analyses. These subregions will typically contain some cells, but also the user could select regions with background and/or artefact that the DL model needs to learn to distinguish from cells.
First, a high resolution whole brain slide is loaded to a basic visualer. The visualiser allows the user to zoom in and out and to change the contrast. Crucially, it allows the user to select sub-regions of the image for subsequent analyses. These subregions will typically contain some cells, but also the user could select regions with background and/or artefact that the DL model needs to learn to distinguish from cells.
select_zones.py
* split_zones.py :
Required arguments:
-i INPUT, --input INPUT
Input file name of main image including extension.
-o OUTPUT_FOLDER, --output_folder OUTPUT_FOLDER
Name of output folder.
Second, each of the selected zones get subdivided into smaller square images that will be used for cell clicking. These images will typically be 256x256 but that is up to the user.
* click_cells.py :
split_zones.py
Optional arguments:
-w WIDTH, --width WIDTH
Width of sub-images. default=128.
-t HEIGHT, --height HEIGHT
Height of sub-images. default=128
--overwrite Overwrite existing slicings?
Required arguments:
-i INPUT_FOLDER, --input_folder INPUT_FOLDER
Input folder name
Third, the lengthy process of cell clicking begins, where the user loads a folder containing a bunch of these small square images and click whenever there are cells.
* create_db.py :
click_cells.py
-i INPUT_FOLDER, --input_folder INPUT_FOLDER
Input folder (_splitted).
-o OUTPUT_CELL_COORDINATES, --output_cell_coordinates OUTPUT_CELL_COORDINATES
Output file name.
--shuffle Load sub-images in random order.
--append Append results to output file.
--empty_zone Entire zone is empty
Finally (yeah there are four steps) one can build a cell database containing smaller (64x64) images alongside information on the number of cells contained in each subimage.
create_db.py
usage: Create DB from clicked textfiles [-h] outfile file [file ...]
### 2. Building and applying cell counting model
This is done in two steps. First a CNN can be train on a number of pre-built cell databases. Then the model can be applied to an image.
This script allows the user to train a model:
train_model.py
usage: train_model.py [-h] -d <str>npz [<str>npz ...] -o <str> [--use_gpu]
[--epochs <int>] [--batch_size <int>] [--split <float>]
[--model <str>] [--load_model <str>.h5] [--augment]
[--verbose]
Required arguments:
-d <str>npz [<str>npz ...], --data <str>npz [<str>npz ...]
input databases
-o <str>, --out <str>
output basename
Optional arguments:
--use_gpu try to use GPU
--epochs <int> number of training epochs (default=100)
--batch_size <int> batch size (default=32)
--split <float> train/test split (default=0.1)
--model <str> choose model (default:convnet_1)
--load_model <str>.h5
load pretrained model
--augment use data augmentation (default=False)
--verbose spit out verbose info
The script allows to run a pre-trained model on an image:
- building a cell counting model
* train_model.py
forward_density.py
usage: forward_density.py [-h] [-o <str>] [-s <int>] [--gpu <bool>]
[--downsample <int>] [--prob_ratio <float>] -m <str>
<str>.tif
A script is available for training a DL model on pre built databases.
optional arguments:
-h, --help show this help message and exit
-o <str>, --out <str>
output basename (default derived from infile)
-s <int>, --stride <int>
stride (default: width of model input images)
--gpu <bool> use GPU if True (default), use CPU if False
--downsample <int> downsampling factor (default=1. Set to x to get an
output that is 1/x times the input along each
dimension)
--prob_ratio <float> probability ratio. cells detected if p(cell)/p(no
cell) > prob_ratio.
- running the forward model
Required arguments:
-m <str>, --model_folder <str>
model folder (must contain model.h5 file and
image_normalise sub-folder)
<str>.tif input image file
* forward_density.py
This script runs a pretrained forward DL model on an image and outputs densities.
......@@ -6,9 +6,10 @@ setup(name='FSL_CellCounting',
version='1.0',
description='A small set of tools for cell counting',
author=['Saad Jbabdi','Oiwi Parker Jones'],
author_email=['saad@fmrib.ox.ac.uk','oiwi@fmrib.ox.ac.uk'],
url='<someGitLabURL',
author_email=['saad@fmrib.ox.ac.uk'],
url='https://git.fmrib.ox.ac.uk/saad/CellCounting.git',
packages=['CellCounting','CellCounting.click_cells','CellCounting.models','CellCounting.utils'],
package_data={'CellCounting.databases': ['celldb1.npz','celldb2.npz','celldb3.npz']},
scripts=['CellCounting/click_cells/select_zones.py',
'CellCounting/click_cells/split_zones.py',
'CellCounting/click_cells/click_cells.py',
......@@ -16,6 +17,6 @@ setup(name='FSL_CellCounting',
'CellCounting/models/train_model.py',
'CellCounting/models/forward_density.py',
'CellCounting/utils/image_info.py',
'CellCounting/utils/cell_report.py']
'CellCounting/utils/cell_report.py','CellCounting/utils/tile.py']
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment