Skip to content

Commit

Permalink
Change package name to swimtracker (#36)
Browse files Browse the repository at this point in the history
* Change package name to `swimtracker`

* re-organize imports

Package rename from `chlamytracker` to `swimtracker` caused imports to no longer be alphabetized
  • Loading branch information
lanery authored Nov 1, 2024
1 parent 5761ae2 commit 03a8d5a
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 37 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip install -e .

If the installation was successful, the below command will return without error.
```bash
python -c "import chlamytracker"
python -c "import swimtracker"
```


Expand All @@ -39,22 +39,22 @@ This repository is organized into the following top-level directories.
* **notebooks**: Collection of Jupyter notebooks for analyzing motility data, including the code used to generate Figures 4–7 in the pub.
* **resources**: Documentation and files related to the automated microscopy acquisitions. Also includes static files such as PNGs and GIFs used for documentation within the repository.
* **results**: A collection of SVG files output by the Jupyter notebooks for generating Figures 4–7 in the pub.
* **src/chlamytracker**: Source code, scripts, and tests comprising the key functionality of the repository including parallelized image processing, cell tracking, and statistical analysis.
* **src/swimtracker**: Source code, scripts, and tests comprising the key functionality of the repository including parallelized image processing, cell tracking, and statistical analysis.

### Methods

#### Cell tracking
Cell tracking was performed by running the `track_cells.py` script (see the "Scripts" section below for more context) on the full dataset of raw brightfield microscopy time lapses available at https://doi.org/10.6019/S-BIAD1298. As described in [data/README.md](data/README.md), this dataset is comprised of _Chlamydomonas reinhardtii_ cells swimming in either agar microchamber pools (`AMID-04_CC-124_pools`) or microtiter plates (`AMID-05_CC-124_wells`). The following command was run to track cells in microchamber pools:
```bash
python src/chlamytracker/scripts/track_cells.py \
python src/swimtracker/scripts/track_cells.py \
AMID-04_CC-124_pools/S1-Cr3-T/ \
--vessel "pools" \
--pool-radius 50 \
--use-dask
```
The same command was repeated for the next three subdirectories (`S2-Cr3-M`, `S3-Cr4-T`, and `S4-Cr4-M`) by substituting in the name of the subdirectory to the first argument. For tracking cells in microtiter plates, the same script was run with the following optional arguments,
```bash
python src/chlamytracker/scripts/track_cells.py \
python src/swimtracker/scripts/track_cells.py \
AMID-05_CC-124_wells/ \
--vessel "384-well plate"
--use-dask
Expand All @@ -78,20 +78,20 @@ The full dataset underlying the pub is 355 GB and thus has been uploaded to the


## Scripts
There are four scripts located in [`src/chlamytracker/scripts`](src/chlamytracker/scripts), the first three of which are for processing biological image data, while the fourth was only run once to prepare the dataset for uploading to the BioImage Archive.
There are four scripts located in [`src/swimtracker/scripts`](src/swimtracker/scripts), the first three of which are for processing biological image data, while the fourth was only run once to prepare the dataset for uploading to the BioImage Archive.
* `track_cells.py`: Track cells in raw brightfield time-lapse microscopy data.
* `make_movies_of_pools.py`: Render an animation of tracked cells in agar microchamber pools (after cell tracking).
* `make_movies_of_wells.py`: Render an animation of tracked cells in a microtiter plate (after cell tracking).
* `generate_bioimage_archive_file_lists.py`: Generate the lists of files needed for the BioImage Archive upload. (_No longer intended to be used._)

All scripts are configured with [`click`](https://click.palletsprojects.com/en/8.1.x/) such that
```bash
python src/chlamytracker/scripts/{script}.py --help
python src/swimtracker/scripts/{script}.py --help
```
will display a help message that gives a description of what the script does as well as the arguments it accepts and their default values. The three scripts for processing biological image data also accept a `--glob` argument that can be used to filter the set of files to process. For example, to track cells from only one row of wells from a plate, one could run the command.

```bash
python src/chlamytracker/scripts/track_cells.py \
python src/swimtracker/scripts/track_cells.py \
/path/to/directory/of/nd2/files/ \
--glob "WellB*.nd2"
```
Expand All @@ -105,15 +105,15 @@ Microscopy data for the pub is comprised of cells swimming inside one of two dif

To track cells in time-lapse videos of 384- or 1536-well plates, parallelized by [`dask`](https://image.dask.org/en/latest/):
```bash
python src/chlamytracker/scripts/track_cells.py \
python src/swimtracker/scripts/track_cells.py \
/path/to/directory/of/nd2/files/ \
--output-directory /path/to/writeable/storage/location/ \
--use-dask
```

To track cells in time-lapse data of 100 µm diameter agar microchamber pools, using 6 cores in parallel:
```bash
python src/chlamytracker/scripts/track_cells.py \
python src/swimtracker/scripts/track_cells.py \
/path/to/directory/of/nd2/files/ \
--output-directory /path/to/writeable/storage/location/ \
--pool-radius 50 \
Expand All @@ -127,15 +127,15 @@ To provide some sort of visual confirmation that the segmentation and cell track

To create animations of tracked cells in 384- or 1536-well plates at 20 fps:
```bash
python src/chlamytracker/scripts/make_movies_of_wells.py \
python src/swimtracker/scripts/make_movies_of_wells.py \
/path/to/directory/of/nd2/files/ \
--framerate 20
--output-directory /path/to/writeable/storage/location/
```

To create animations of tracked cells in agar microchamber pools at 30 fps:
```bash
python src/chlamytracker/scripts/make_movies_of_pools.py \
python src/swimtracker/scripts/make_movies_of_pools.py \
/path/to/directory/of/nd2/files/ \
--framerate 30
--output-directory /path/to/writeable/storage/location/
Expand Down
8 changes: 4 additions & 4 deletions notebooks/1_compute-summary-motility-metrics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"\n",
"This notebook outputs two CSV files to [`data/`](../data), one for each imaging experiment. The columns of the CSV file are the various motility metrics (total distance, net distance, confinement ratio, etc.), and each row corresponds to the summary motility metrics for one particular cell trajectory. Only the motility metrics for trajectories longer than 20 µm and with a duration lasting more than 10 s are output to the CSV file. Because the time lapses are 20 s, this ensures that cells are not represented more than once.\n",
"\n",
"Note that cell trajectories were originally output by running the script [`../src/chlamytracker/scripts/track_cells.py`](../src/chlamytracker/scripts/track_cells.py).\n",
"Note that cell trajectories were originally output by running the script [`../src/swimtracker/scripts/track_cells.py`](../src/swimtracker/scripts/track_cells.py).\n",
"\n",
"#### Datasets\n",
"The datasets from which the cell trajectories derive are split by vessel type.\n",
Expand All @@ -42,9 +42,9 @@
"from pathlib import Path\n",
"\n",
"import pandas as pd\n",
"from chlamytracker.timelapse import Timelapse\n",
"from chlamytracker.tracking_metrics import TrajectoryCSVParser\n",
"from natsort import natsorted\n",
"from swimtracker.timelapse import Timelapse\n",
"from swimtracker.tracking_metrics import TrajectoryCSVParser\n",
"from tqdm.notebook import tqdm"
]
},
Expand Down Expand Up @@ -715,7 +715,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "tracking",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/3_motility-analysis-in-pools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"from chlamytracker.stats_testing import joint_grid_with_stats, split_violin_plot_with_stats"
"from swimtracker.stats_testing import joint_grid_with_stats, split_violin_plot_with_stats"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/4_compare-motility-in-pools-vs-wells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"from chlamytracker.stats_testing import joint_grid_with_stats, split_violin_plot_with_stats"
"from swimtracker.stats_testing import joint_grid_with_stats, split_violin_plot_with_stats"
]
},
{
Expand Down Expand Up @@ -581,7 +581,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "tracking",
"language": "python",
"name": "python3"
},
Expand Down
6 changes: 3 additions & 3 deletions notebooks/5_pca-of-motility-features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"import numpy as np\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"from chlamytracker.stats_testing import joint_grid_with_stats\n",
"from sklearn.decomposition import PCA"
"from sklearn.decomposition import PCA\n",
"from swimtracker.stats_testing import joint_grid_with_stats"
]
},
{
Expand Down Expand Up @@ -647,7 +647,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "tracking",
"language": "python",
"name": "python3"
},
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools", "setuptools-scm[toml]"]
build-backend = "setuptools.build_meta"

[project]
name = "chlamytracker"
name = "swimtracker"
version = "1.0"
description = "Image analysis workflows for tracking unicellular organisms"
readme = "README.md"
Expand All @@ -14,7 +14,7 @@ authors = [
]

[project.scripts]
extract-pools = "chlamytracker.scripts.extract_pools:main"
extract-pools = "swimtracker.scripts.extract_pools:main"

[tool.ruff]
# The directories to consider when resolving first- vs. third-party imports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import click
import pandas as pd
from chlamytracker import cli_options
from natsort import natsorted
from swimtracker import cli_options

DATA_DIRECTORY = Path(__file__).parents[3] / "data"
SAMPLE_PREP_PARAMETERS_JSON = DATA_DIRECTORY / "experimental_parameters.json"
Expand Down
6 changes: 3 additions & 3 deletions src/chlamytracker/scripts/make_movies_of_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import numpy as np
import pandas as pd
import skimage as ski
from chlamytracker import cli_options
from chlamytracker.tracking_metrics import TrajectoryCSVParser
from chlamytracker.utils import configure_logger, crop_movie_to_content
from napari_animation import Animation
from natsort import natsorted
from swimtracker import cli_options
from swimtracker.tracking_metrics import TrajectoryCSVParser
from swimtracker.utils import configure_logger, crop_movie_to_content
from tqdm import tqdm

logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions src/chlamytracker/scripts/make_movies_of_wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import napari
import nd2
import numpy as np
from chlamytracker import cli_options
from chlamytracker.tracking_metrics import TrajectoryCSVParser
from chlamytracker.utils import configure_logger, crop_movie_to_content
from napari_animation import Animation
from natsort import natsorted
from swimtracker import cli_options
from swimtracker.tracking_metrics import TrajectoryCSVParser
from swimtracker.utils import configure_logger, crop_movie_to_content
from tqdm import tqdm

logger = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions src/chlamytracker/scripts/track_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import click
import numpy as np
import skimage as ski
from chlamytracker import cli_options
from chlamytracker.pool_finder import PoolFinder
from chlamytracker.tracking import Tracker
from chlamytracker.well_processor import WellSegmenter
from natsort import natsorted
from swimtracker import cli_options
from swimtracker.pool_finder import PoolFinder
from swimtracker.tracking import Tracker
from swimtracker.well_processor import WellSegmenter
from tqdm import tqdm

logger = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions src/chlamytracker/stack_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import dask.array as da
import numpy as np
import skimage as ski

from chlamytracker.utils import timeit
from swimtracker.utils import timeit


@timeit
Expand Down
2 changes: 1 addition & 1 deletion src/chlamytracker/tracking_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def compute_summary_statistics(self):
Examples
--------
>>> from chlamytracker.tracking_metrics import TrajectoryCSVParser
>>> from swimtracker.tracking_metrics import TrajectoryCSVParser
>>> csv_file = "WellJ07_tracks.csv"
>>> motility_data = TrajectoryCSVParser(csv_file, framerate=30, pixelsize=0.5)
>>> motility_data.compute_summary_statistics()
Expand Down

0 comments on commit 03a8d5a

Please sign in to comment.