Skip to content

Commit

Permalink
docs ducks daks
Browse files Browse the repository at this point in the history
  • Loading branch information
mese79 committed Jan 8, 2025
1 parent 15a5f5f commit d5f4b5f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 45 deletions.
44 changes: 7 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ We developed a *napari* plugin to train a *Random Forest* model using extracted
----------------------------------

## Documentation
The plugin documentation is [here](docs/index.md).
You can check the documentation [here](https://juglab.github.io/featureforest/) (⚠️ work in progress!).

## Installation
To install this plugin you need to use [conda] or [mamba] to create a environment and install the requirements. Use the commands below to create the environment and install the plugin:
To install this plugin you need to use [conda] or [mamba] to create an environment and install the requirements. Use commands below to create the environment and install the plugin:
```bash
git clone https://github.com/juglab/featureforest
cd ./featureforest
```
```bash
# for GPU
conda env create -f ./env_gpu.yml
Expand All @@ -26,41 +30,7 @@ conda env create -f ./env_gpu.yml
conda env create -f ./env_cpu.yml
```

#### Note: You need to install `sam-2` which can be installed easily using conda. To install `sam-2` using `pip` please refer to the official [sam-2](https://github.com/facebookresearch/sam2) repository.

### Requirements
- `python >= 3.10`
- `numpy==1.24.4`
- `opencv-python`
- `scikit-learn`
- `scikit-image`
- `matplotlib`
- `pyqt`
- `magicgui`
- `qtpy`
- `napari`
- `h5py`
- `pytorch=2.3.1`
- `torchvision=0.18.1`
- `timm=1.0.9`
- `pynrrd`
- `segment-anything`
- `sam-2`

If you want to install the plugin manually using GPU, please follow the pytorch installation instruction [here](https://pytorch.org/get-started/locally/).
For detailed napari installation see [here](https://napari.org/stable/tutorials/fundamentals/installation).

### Installing The Plugin
If you use the provided conda environment yaml files, the plugin will be installed automatically. But in case you already have the environment setup,
you can just install the plugin. First clone the repository:
```bash
git clone https://github.com/juglab/featureforest
```
Then run the following commands:
```bash
cd ./featureforest
pip install .
```
For more detailed installation guide, check out [here](https://juglab.github.io/featureforest/install/).


## License
Expand Down
4 changes: 2 additions & 2 deletions docs/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ As for the first step, we recommend making a small sub-stack to train a Random F
After the training, you can save the RF model, and later apply it on the entire stack.

## Divide And Conquer
Extracted features saved as an `HDF5` file can take a very large space on disk. In this method, to prevent the disk space overflow, you can divide your large stack into several sub-stacks. Then use the plugin for each, separately.
Although, you can try one trained model over another sub-stack, Random Forest model can not be fine-tuned. By using this method, you can achieve better annotations with the expense of spending more time on training several models.
Extracted features saved as an `HDF5` file can take up a huge space on the disk. In this method, to prevent disk space overflow, you can divide your large stack into several sub-stacks. Then use the plugin for each, separately.
Although, you can try one trained model over another sub-stack, Random Forest model can not be fine-tuned. By using this method, you can achieve better annotations at the expense of spending more time on training several models.
11 changes: 7 additions & 4 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Easy Way!
To install this plugin you need to use [mamba] or [conda] to create a environment and install the requirements. Use the commands below to create the environment and install the plugin:
To install this plugin you need to use [mamba] or [conda] to create a environment and install the requirements. Use commands below to create the environment and install the plugin:
```bash
git clone https://github.com/juglab/featureforest
cd ./featureforest
```
```bash
# for GPU
mamba env create -f ./env_gpu.yml
Expand Down Expand Up @@ -31,9 +35,6 @@ You need to install `sam-2` which can be installed easily using mamba (or conda)
- `segment-anything`
- `sam-2`

If you want to install the plugin manually using GPU, please follow the pytorch installation instruction [here](https://pytorch.org/get-started/locally/).
For detailed napari installation see [here](https://napari.org/stable/tutorials/fundamentals/installation).

## Installing Only The Plugin
If you use the provided conda environment yaml files, the plugin will be installed automatically. But in case you already have the environment setup,
you can just install the plugin. First clone the repository:
Expand All @@ -51,6 +52,8 @@ There is also a [pypi package](https://pypi.org/project/featureforest/) availabl
pip install featureforest
```

If you want to install the plugin manually using GPU, please follow the pytorch installation instruction [here](https://pytorch.org/get-started/locally/). For detailed napari installation see [here](https://napari.org/stable/tutorials/fundamentals/installation).


[conda]: https://conda.io/projects/conda/en/latest/index.html
[mamba]: https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html
48 changes: 46 additions & 2 deletions docs/segmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Segmentation widget is a long widget with several panels, but don't worry we
### Inputs
1. **Input Layer**: To set which napari layer is your input image layer
2. **Feature Storage**: Select your previously extracted features `HDF5` file here.
***Note***: You need to select the storage file for this particular input image, obviously!
***Note***: You need to select the storage file for the selected input image, obviously!
3. **Ground Truth Layer**: To select your *Labels* layer
4. **Add Layer** button: To add a new GT layer to napari layers

Expand All @@ -17,5 +17,49 @@ The Segmentation widget is a long widget with several panels, but don't worry we
- You can have as many *Labels* layer as you want. But **only the selected** one will be used for training the RF model.
- You can also drag & drop your previously saved labels into the napari and select that layer.


## Train Model
![Inputs](assets/segmentation_widget/seg_2.png){width="360" align=left}
![Inputs](assets/segmentation_widget/seg_2.png){width="360" align=right}
### Train Model (Random Forest)
1. **Number of Trees**: To set number of trees (estimators) in the forest
2. **Max depth**: The maximum depth of a tree
3. **Train** button: To extract the training data and train the **RF** model
4. **Load Model** button: Using this, you can load a previously trained and saved model.
5. **Save Model** button: To save the current RF model

!!! tip
- Setting a high value for the `Max depth` would overfit your **RF** model over the training data. So, it won't perform well on test images.
But if you're doing the segmentation over the entire stack (or a single image), you may try higher values.

<div class="clear"></div>

## Prediction
![Inputs](assets/segmentation_widget/seg_3.png){width="360" align=right}
### Prediction
###### Segmentation Layer:
1. **New Layer**: If checked, the segmentation result will show up on a new layer in napari
2. **Layer Dropdown**: You can select which layer should be used as the layer for the segmentation result
3. **Add/Replace Segmentation** option: Based on your choice, this will add new segmentation to the previous result, or completely replace the result (Default).
###### Buttons:
4. **Predict Slice** button: To generate the segmentation mask for the *current* slice
5. **Predict Whole Stack** button: to start the prediction process for the whole loaded stack
6. **Stop** button: Just for your safety!😉 this will stop the prediction process.


## Post-processing
![Inputs](assets/segmentation_widget/seg_4.png){width="360"}

-


## Export
![Inputs](assets/segmentation_widget/seg_5.png){width="360"}

-


## Run Prediction Pipeline
![Inputs](assets/segmentation_widget/seg_6.png){width="360"}

-

5 changes: 5 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@

.admonition>:last-child, html .md-typeset details>:last-child {
font-size: 0.72rem;
}


.clear {
clear: both;
}

0 comments on commit d5f4b5f

Please sign in to comment.