Skip to content

Commit

Permalink
Merge pull request #341 from RichieHakim/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
RichieHakim authored Oct 25, 2024
2 parents 567b94b + 2face89 commit 72fee2c
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 48 deletions.
64 changes: 29 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,60 +48,39 @@ With ROICaT, you can:
<img src="docs/media/umap_with_labels.png" alt="ROICaT" width="300" align="right" style="margin-left: 20px"/>
</div>

Listed below, we have a suite of tools for running the ROICaT pipelines.
#### First time users:
Try it out using the online app or our Google CoLab notebooks below which can be
run fully remotely without installing anything on your computer.
#### Normal usage:
We recommend using our Jupyter notebooks or command line interface which can be
run locally on any computer.

### TRACKING:
- [Online App](https://huggingface.co/spaces/richiehakim/ROICaT_tracking): Good for first time users. Try it out without installing anything.
- [Interactive
notebook](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/tracking/1_tracking_interactive_notebook.ipynb)
- [Google
CoLab](https://githubtocolab.com/RichieHakim/ROICaT/blob/main/notebooks/colab/tracking/1_tracking_interactive_notebook.ipynb) (not up to date)
notebook](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/tracking/1_tracking_interactive_notebook.ipynb). Or run on google colab: <a target="_blank" href="https://githubtocolab.com/RichieHakim/ROICaT/blob/main/notebooks/tracking/1_tracking_interactive_notebook.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
- [Command line interface script](https://github.com/RichieHakim/ROICaT/blob/main/scripts/run_tracking.sh):
```shell
roicat --pipeline tracking --path_params /path/to/params.yaml --dir_data /folder/with/data/ --dir_save /folder/save/ --prefix_name_save expName --verbose
```

### CLASSIFICATION:
- [Interactive notebook -
Drawing](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/classification/A1_classify_by_drawingSelection.ipynb)
- [Google CoLab -
Drawing](https://githubtocolab.com/RichieHakim/ROICaT/blob/main/notebooks/colab/classification/A1_classify_by_drawingSelection_colab.ipynb) (not up to date)
Drawing](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/classification/A1_classify_by_drawingSelection.ipynb). Or run on google colab: <a target="_blank" href="https://githubtocolab.com/RichieHakim/ROICaT/blob/main/notebooks/classification/A1_classify_by_drawingSelection.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
- [Interactive notebook -
Labeling](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/classification/B1_labeling_interactive.ipynb)
Labeling](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/classification/B1_labeling_interactive.ipynb)
- [Interactive notebook - Train
classifier](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/classification/B2_classifier_train_interactive.ipynb)
classifier](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/classification/B2_classifier_train_interactive.ipynb)
- [Interactive notebook - Inference with
classifier](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/classification/B3_classifier_inference_interactive.ipynb)
classifier](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/classification/B3_classifier_inference_interactive.ipynb)

**OTHER:**
- [Custom data importing
notebook](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/jupyter/other/demo_data_importing.ipynb)
notebook](https://github.com/RichieHakim/ROICaT/blob/main/notebooks/other/demo_data_importing.ipynb)
- Use the API to integrate ROICaT functions into your own code:
[Documentation](https://roicat.readthedocs.io/en/latest/roicat.html).
- Run the full tracking pipeline using `roicat.pipelines.pipeline_tracking` with
default parameters generated from `roicat.util.get_default_paramaters()`.
- Run the full tracking pipeline using the CLI or
`roicat.pipelines.pipeline_tracking` with default parameters generated from
`roicat.util.get_default_paramaters()` saved as a yaml file.
<!-- - Train a new ROInet model using the provided Jupyter Notebook [TODO: link]. -->

# General workflow:
- **Pass ROIs through ROInet:** Images of the ROIs are passed through a neural
network which outputs a feature vector for each image describing what the ROI
looks like.
- **Classification:** The feature vectors can then be used to classify ROIs:
- A simple regression-like classifier can be trained using user-supplied
labeled data (e.g. an array of images of ROIs and a corresponding array of
labels for each ROI).
- Alternatively, classification can be done by projecting the feature vectors
into a lower-dimensional space using UMAP and then simply circling the
region of space to classify the ROIs.
- **Tracking**: The feature vectors can be combined with information about the
position of the ROIs to track the ROIs across imaging sessions/planes.


# Installation
ROICaT works on Windows, MacOS, and Linux. If you have any issues during the
Expand Down Expand Up @@ -157,6 +136,21 @@ git pull
```


# General workflow:
- **Pass ROIs through ROInet:** Images of the ROIs are passed through a neural
network which outputs a feature vector for each image describing what the ROI
looks like.
- **Classification:** The feature vectors can then be used to classify ROIs:
- A simple regression-like classifier can be trained using user-supplied
labeled data (e.g. an array of images of ROIs and a corresponding array of
labels for each ROI).
- Alternatively, classification can be done by projecting the feature vectors
into a lower-dimensional space using UMAP and then simply circling the
region of space to classify the ROIs.
- **Tracking**: The feature vectors can be combined with information about the
position of the ROIs to track the ROIs across imaging sessions/planes.


# TODO:
#### algorithmic improvements:
- [ ] Add in method to use more similarity metrics for tracking
Expand All @@ -175,7 +169,7 @@ git pull
- [x] Make a GUI
- [ ] Finish ROIextractors integration
- [ ] Make a Docker container
- [ ] Make colab demo notebook not require user data
- ~~Make colab demo notebook not require user data~~
- [x] Make a better CLI
#### other:
- [ ] Write the paper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,86 @@
"6. **Save** results\n"
]
},
{
"cell_type": "markdown",
"id": "5895c4ec",
"metadata": {},
"source": [
"##### If running on google colab:"
]
},
{
"cell_type": "markdown",
"id": "876d3c2d",
"metadata": {},
"source": [
"- install roicat\n",
"\n",
"After running the cell below, the runtime will restart."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ad98a5a",
"metadata": {},
"outputs": [],
"source": [
"#@title Install `roicat` if on colab\n",
"using_colab = 'google.colab' in str(get_ipython())\n",
"\n",
"if using_colab:\n",
" !pip uninstall -y tensorflow\n",
" !pip install roicat[classification]"
]
},
{
"cell_type": "markdown",
"id": "3481e943",
"metadata": {},
"source": [
"- mount google drive"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e148bc5e",
"metadata": {},
"outputs": [],
"source": [
"#@title mount gdrive if on colab\n",
"#@markdown Upload your data to Google Drive, then mount the drive and access the cloud directory here.\n",
"#@markdown You can use the sidebar to the left to browse your google drive directories.\n",
"\n",
"using_colab = 'google.colab' in str(get_ipython())\n",
"\n",
"if using_colab:\n",
" from google.colab import drive\n",
" path_gdrive = '/content/gdrive'\n",
" drive.mount(path_gdrive, force_remount=True)"
]
},
{
"cell_type": "markdown",
"id": "e26b82b7",
"metadata": {},
"source": [
"- enable widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "820c2b9a",
"metadata": {},
"outputs": [],
"source": [
"if using_colab:\n",
" from google.colab import output\n",
" output.enable_custom_widget_manager()"
]
},
{
"cell_type": "markdown",
"id": "c4a1f6ef-7075-4cc3-a046-dd170bb957b9",
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion notebooks/colab/tracking/tracking_visualize_results.ipynb

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,131 @@
},
{
"cell_type": "markdown",
"id": "50622a4e",
"id": "ba945b86",
"metadata": {},
"source": [
"# Import libraries"
"##### If running on google colab:"
]
},
{
"cell_type": "markdown",
"id": "900d6343",
"metadata": {},
"source": [
"- install roicat\n",
"\n",
"After running the cell below, the runtime will restart."
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "c2e99d36",
"metadata": {},
"outputs": [],
"source": [
"#@title Install `roicat` if on colab\n",
"using_colab = 'google.colab' in str(get_ipython())\n",
"\n",
"if using_colab:\n",
" !pip uninstall -y tensorflow\n",
" !pip install roicat[tracking]"
]
},
{
"cell_type": "markdown",
"id": "e9824970",
"id": "222a013b",
"metadata": {},
"source": [
"Widen the notebook"
"- mount google drive"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "997af9bd",
"id": "9793b4fc",
"metadata": {},
"outputs": [],
"source": [
"#@title mount gdrive if on colab\n",
"#@markdown Upload your data to Google Drive, then mount the drive and access the cloud directory here.\n",
"#@markdown You can use the sidebar to the left to browse your google drive directories.\n",
"\n",
"using_colab = 'google.colab' in str(get_ipython())\n",
"\n",
"if using_colab:\n",
" from google.colab import drive\n",
" path_gdrive = '/content/gdrive'\n",
" drive.mount(path_gdrive, force_remount=True)"
]
},
{
"cell_type": "markdown",
"id": "f280a589",
"metadata": {},
"source": [
"- enable widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b221ee1b",
"metadata": {},
"outputs": [],
"source": [
"if using_colab:\n",
" from google.colab import output\n",
" output.enable_custom_widget_manager()"
]
},
{
"cell_type": "markdown",
"id": "50622a4e",
"metadata": {},
"source": [
"# Import libraries"
]
},
{
"cell_type": "markdown",
"id": "b9293d82",
"metadata": {},
"source": [
"widen the notebook"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "d5c53190",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<style>.container {width:95% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<style>:root { --jp-notebook-max-width: 100% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# widen jupyter notebook window\n",
"from IPython.display import display, HTML\n",
Expand All @@ -65,7 +170,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 20,
"id": "c4eb1fa5",
"metadata": {},
"outputs": [],
Expand All @@ -87,10 +192,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"id": "db7f4f25",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/media/rich/OS/Users/Richard/Linux_stuff_on_OS/conda_envs/envs/roicat/lib/python3.11/site-packages/kornia/feature/lightglue.py:44: FutureWarning: `torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.\n",
" @torch.cuda.amp.custom_fwd(cast_inputs=torch.float32)\n"
]
}
],
"source": [
"import roicat"
]
Expand Down
2 changes: 1 addition & 1 deletion roicat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

from .__main__ import run_pipeline

__version__ = '1.4.3'
__version__ = '1.4.4'
5 changes: 4 additions & 1 deletion roicat/tracking/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import torch
from tqdm.auto import tqdm
import cv2
import kornia
import matplotlib.pyplot as plt

from .. import helpers, util
Expand Down Expand Up @@ -1709,6 +1708,8 @@ def __init__(
device: str = 'cpu',
verbose: bool = False,
):
import kornia

super().__init__(device=device, verbose=verbose)
self.verbose = verbose

Expand Down Expand Up @@ -2203,6 +2204,8 @@ def __init__(
device: str = 'cpu',
verbose: bool = False,
):
import kornia

super().__init__(device=device, verbose=verbose)
self.verbose = verbose
self.threshold_confidence = threshold_confidence
Expand Down

0 comments on commit 72fee2c

Please sign in to comment.