Skip to content

Commit

Permalink
Merge pull request #91 from oubino/new_working
Browse files Browse the repository at this point in the history
New working
  • Loading branch information
oubino authored Feb 8, 2024
2 parents 12c37b1 + 0b3c258 commit 6c26a22
Show file tree
Hide file tree
Showing 30 changed files with 180 additions and 3,295 deletions.
128 changes: 30 additions & 98 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ For more comprehensive documentation please see https://oubino.github.io/locpix/
#. Segmentation:

#. `Classic segmentation`_ : Use classic method to segment histograms to extract relevant localisations
#. `Cellpose segmentation (no training)`_ : Use Cellpose method to segment histograms to extract relevant localisations with no retraining of Cellpose model
#. `Cellpose segmentation (training)`_ : Use Cellpose method to segment histograms to extract relevant localisations with retraining of Cellpose model
#. `Cellpose segmentation`_ : Use Cellpose method to segment histograms to extract relevant localisations
#. `Ilastik segmentation`_ : Use Ilastik method to segment histograms to extract relevant localisations

#. `Membrane performance`_ : Performance metrics calculation based on the localisations (not the histograms!)
Expand All @@ -36,12 +35,10 @@ will not be accessed again!
Usage configuration
-------------------

Each script can be run with a GUI, but can also be run in headless mode.

In headless mode each script needs a configuration file (.yaml file), which should be
Each script needs a configuration file (.yaml file), which should be
specified using the -c flag.

Each configuration used, whether run in GUI or headless mode will be saved in the project directory.
Each configuration used will be saved in the project directory.

The templates for the configuration files can be found in the `templates folder <https://github.com/oubino/locpix/tree/master/src/locpix/templates>`_.

Expand Down Expand Up @@ -81,13 +78,7 @@ This script preprocesses the input .csv data for later use AND **must be run fir
This script will take in .csv files, and convert them to .parquet files,
while also wrangling the data into our data format.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ preprocess
To run the script without a GUI -i -c and -o flags should be specified
To run the script -i -c and -o flags should be specified

.. code-block:: console
Expand All @@ -98,13 +89,7 @@ Annotate

This script allows for manual segmentation of the localisations.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ annotate
To run the script without a GUI -i and -c flags should be specified
To run the script -i and -c flags should be specified

.. code-block:: console
Expand All @@ -118,13 +103,7 @@ Get markers

This script allows for labelling the localisation image with a marker to represent the cells.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ get_markers
To run the script without a GUI -i and -c flags should be specified
To run the script -i and -c flags should be specified

.. code-block:: console
Expand All @@ -135,106 +114,59 @@ Classic segmentation

Perform classic segmentation on our localisation dataset.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ classic
To run the script without a GUI -i and -c flags should be specified
To run the script -i and -c flags should be specified

.. code-block:: console
(locpix-env) $ classic -i path/to/project/directory -c path/to/config/file
Cellpose segmentation (no training)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Need to activate extra requirements - these are big and not included in initial install.

Note that if you have a GPU this will speed this up.
Cellpose segmentation
^^^^^^^^^^^^^^^^^^^^^

Note we modified Cellpose to fit in with our analysis, therefore you need to install our forked repository - note below will clone the Cellpose repository to wherever you are located
Need to activate extra requirements - these are big and not included in initial install.

If you have a GPU

.. code-block:: console
Note that if you have a GPU this will speed this up.

(locpix-env) $ pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu117
(locpix-env) $ git clone https://github.com/oubino/cellpose
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
Note we modified Cellpose to fit in with our analysis, therefore you need to install our forked repository - note below will clone the Cellpose repository to wherever you are located

If you don't have a GPU

.. code-block:: console
(locpix-env) $ pip install pytorch
(locpix-env) $ git clone https://github.com/oubino/cellpose
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
Perform Cellpose segmentation on our localisation dataset.

To run the script using the GUI, run
If you have a GPU

.. code-block:: console
(locpix-env) $ cellpose_eval
(locpix-env) $ pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu117
(locpix-env) $ git clone https://github.com/oubino/cellpose
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
To run the script without a GUI -i and -c flags should be specified
If you don't have a GPU

.. code-block:: console
(locpix-env) $ cellpose_eval -i path/to/project/directory -c path/to/config/file
(locpix-env) $ pip install pytorch
(locpix-env) $ git clone https://github.com/oubino/cellpose
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
Cellpose segmentation (training)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To evaluate Cellpose model on the localisation dataset without any retraining on your dataset run the script with -i and -c flags specified

Need to activate extra requirements - these are big and not included in initial install.
.. code-block:: console
Note that if you have a GPU this will speed this up.
(locpix-env) $ cellpose_eval -i path/to/project/directory -c path/to/config/file
Note we modified Cellpose to fit in with our analysis, therefore you need to install our forked repository - note below will clone the Cellpose repository to wherever you are located
To retrain first then evaluate we instead

If you have a GPU
Prepare data for training

.. code-block:: console
(locpix-env) $ pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu117
(locpix-env) $ git clone https://github.com/oubino/cellpose
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
(locpix-env) $ train_prep -i path/to/project/directory -c path/to/config/file
If you don't have a GPU
Train cellpose

.. code-block:: console
(locpix-env) $ pip install pytorch
(locpix-env) $ git clone https://github.com/oubino/cellpose
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
Prepare data for training

.. code-block:: console
(locpix-env) $ cellpose_train_prep -i path/to/project/directory -c path/to/config/file
Train cellpose (using their scripts)

.. code-block:: console
(locpix-env) $ python -m cellpose --train --dir path/to/project/directory/cellpose_train/train --test_dir path/to/project/directory/cellpose_train/test --pretrained_model LC1 --chan 0 --chan2 0 --learning_rate 0.1 --weight_decay 0.0001 --n_epochs 10 --min_train_masks 1 --verbose
Evaluate cellpose

.. code-block:: console
(locpix-env) $ cellpose_eval -i path/to/project/directory -c path/to/config/file -u -o cellpose_train_eval
(locpix-env) $ cellpose_train -i path/to/project/directory -ct path/to/config/train_file -ce path/to/config/eval_file
Ilastik segmentation
Expand Down
3 changes: 1 addition & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ This includes the following functionality:
#. :ref:`get-markers` : Labelling histogram with seeds for watershed algorithm
#. Segmentation:
#. :ref:`classic-segmentation` : Use classic method to segment histograms to extract relevant localisations
#. :ref:`cellpose-segmentation-train` : Use Cellpose method to train cellpose to extract relevant localisations
#. :ref:`cellpose-segmentation-eval` : Use Cellpose method to segment histograms to extract relevant localisations
#. :ref:`cellpose-segmentation` : Use Cellpose method to segment histograms to extract relevant localisations
#. :ref:`ilastik-segmentation` : Use Ilastik method to segment histograms to extract relevant localisations
#. :ref:`membrane-performance` : Performance metrics calculation based on the localisations (not the histograms!)

Expand Down
63 changes: 23 additions & 40 deletions docs/source/user_guide/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ will not be accessed again!
Usage configuration
-------------------

Each script can be run with a GUI, but can also be run in headless mode.

In headless mode each script needs a configuration file (.yaml file), which should be
Each script needs a configuration file (.yaml file), which should be
specified using the -c flag.

Each configuration used, whether run in GUI or headless mode will be saved in the project directory.
Each configuration used will be saved in the project directory.

The templates for the configuration files can be found in :ref:`templates`

Expand Down Expand Up @@ -58,13 +56,7 @@ This script preprocesses the input .csv data for later use AND **must be run fir
This script will take in .csv files, and convert them to .parquet files,
while also wrangling the data into our data format.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ preprocess
To run the script without a GUI -i -c and -o flags should be specified
To run the script -i -c and -o flags should be specified

.. code-block:: console
Expand All @@ -78,13 +70,7 @@ Annotate

This script allows for manual segmentation of the localisations.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ annotate
To run the script without a GUI -i and -c flags should be specified
To run the script -i and -c flags should be specified

.. code-block:: console
Expand All @@ -101,13 +87,7 @@ Get markers

This script allows for labelling the localisation image with a marker to represent the cells.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ get_markers
To run the script without a GUI -i and -c flags should be specified
To run the script -i and -c flags should be specified

.. code-block:: console
Expand All @@ -121,13 +101,7 @@ Classic segmentation

Perform classic segmentation on our localisation dataset.

To run the script using the GUI, run

.. code-block:: console
(locpix-env) $ classic
To run the script without a GUI -i and -c flags should be specified
To run the script without -i and -c flags should be specified

.. code-block:: console
Expand Down Expand Up @@ -166,22 +140,31 @@ Cellpose segmentation
(locpix-env) $ cd cellpose
(locpix-env) $ pip install .
Perform Cellpose segmentation on our localisation dataset.
Perform Cellpose segmentation on our without any retraining on your dataset run the script with -i and -c flags specified

To run the script using the GUI, run
.. code-block:: console
.. code-block:: console
(locpix-env) $ cellpose_eval -i path/to/project/directory -c path/to/config/file
(locpix-env) $ cellpose
To retrain first then evaluate we instead

To run the script without a GUI -i and -c flags should be specified
Prepare data for training

.. code-block:: console
.. code-block:: console
(locpix-env) $ train_prep -i path/to/project/directory -c path/to/config/file
Train cellpose

.. code-block:: console
(locpix-env) $ cellpose_train -i path/to/project/directory -ct path/to/config/train_file -ce path/to/config/eval_file
(locpix-env) $ cellpose -i path/to/project/directory -c path/to/config/file
**API**
:py:mod:`locpix.scripts.img_seg.cellpose`
:py:mod:`locpix.scripts.img_seg.train_prep`
:py:mod:`locpix.scripts.img_seg.cellpose_eval`
:py:mod:`locpix.scripts.img_seg.cellpose_train`

Ilastik segmentation
^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading

0 comments on commit 6c26a22

Please sign in to comment.