cylinder-time-lapse automates the creation of timelapse videos from image datasets. This repository provides easy-to-run Jupyter notebooks for generating MP4 videos from image files, making it accessible to researchers and developers.
- User-Friendly: Accessible Jupyter notebooks designed for researchers with varying technical backgrounds.
- Configurable: Customizable input/output paths, resolution, playback speed, and overwrite conditions.
- Efficient Workflow: Automated generation of H5 and MP4 files for large datasets.
- Cross-Platform Compatibility: Works on Windows, macOS, and Linux.
- Scalable: Handles large image datasets efficiently.
-
Navigate to the desired directory
cd path/on/your/computer
-
Clone the repository
git clone https://github.com/Salk-Harnessing-Plants-Initiative/cylinder-time-lapse.git
-
Navigate into the repository
cd cylinder-time-lapse
-
Create the Conda environment
mamba env create -f env.yml
-
Activate the environment
mamba activate time_lapse_videos
-
Start Jupyter Lab
jupyter lab
-
Run the notebooks
- Start by creating the H5 files, then use them to generate MP4 videos.
-
Organize Files
- Files must be organized by genotype → timepoint → replicate.
- Each replicate folder should be named using the format
R<replicate_identifier>
.
-
Configure the Notebook
- Adjust the source and destination directories in the notebook as needed. Example:
base_src_dir = "Arabidopsis" # Source directory base_dst_dir = "output_directory/h5s" # Destination directory
- Adjust the source and destination directories in the notebook as needed. Example:
The input image files should be structured in a hierarchical directory format as follows. The directory structure is configurable based on the provided script variables:
<base_src_dir>/
└── <genotype>/
└── <timepoint>/
└── <replicate>/
└── <image>.png
The following variables allow you to customize the structure:
- Base Source Directory (
base_src_dir
): The root folder containing all genotypes (example:Sorghum
). - Destination Directory (
base_dst_dir
): Output folder for H5 files (example:Sorghum_time_lapse_videos_20240808/h5s_preds_by_frame
). - Genotypes (
genotypes
): Configurable range of genotype identifiers (example:1-6
). - Timepoints (
days
): Configurable range of timepoints in days (example:1-14
). - Number of Images per Timepoint (
img_numbers
): Configurable range of images per replicate (example:1-72
). - Overwrite Option (
overwrite
): WhenTrue
, existing files will be overwritten.
Here’s an example based on the example configuration:
Sorghum/
├── 1/
│ ├── 1d/
│ │ └── R1/
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── ...
│ │ └── 72.png
│ ├── 2d/
│ │ └── R1/
│ │ ├── 1.png
│ │ ├── ...
│ │ └── 72.png
│ └── 14d/
│ └── R1/
│ ├── 1.png
│ ├── ...
│ └── 72.png
├── 2/
│ ├── 1d/
│ │ └── R2/
│ │ ├── 1.png
│ │ ├── ...
│ │ └── 72.png
│ └── 14d/
│ └── R2/
│ ├── 1.png
│ ├── ...
│ └── 72.png
└── 6/
├── 1d/
│ └── R6/
│ ├── 1.png
│ ├── ...
│ └── 72.png
└── 14d/
└── R6/
├── 1.png
├── ...
└── 72.png
- Genotype Directories (
<genotype>
): Numbered numerically according to thegenotypes
range. - Timepoint Folders (
<timepoint>
): Use the<day>d
format for days (e.g.,1d
,14d
) based on thedays
range. - Replicate Folders (
<replicate>
): Named asR<replicate_identifier>
for each replicate. - Image Files (
<image>.png
): Numbered sequentially according to theimg_numbers
range (e.g.,1.png
to72.png
).
If you modify the variables as shown below:
base_src_dir = "Arabidopsis"
genotypes = range(1, 4) # 1 to 3
days = range(1, 10) # 1 to 9
img_numbers = range(1, 51) # 1 to 50
The structure will adjust accordingly:
Arabidopsis/
├── 1/
│ ├── 1d/
│ │ └── R1/
│ │ ├── 1.png
│ │ ├── ...
│ │ └── 50.png
...
└── 3/
├── 9d/
└── R1/
├── 1.png
├── ...
└── 50.png
Ensure the directory structure matches the configuration parameters for the scripts to run correctly.
-
Input Configuration
- Specify the location of the H5 files (output from the previous step).
-
Customization Options
- Adjust resolution and playback speed using the
decimation
andslowdown_factor
overwrite = True decimation = 2 # Factor used to coarsen the video slowdown_factor = 5 # must be integer >= 1
This is used in
render_plant_from_h5
img = img[::decimate, ::decimate] # Decimation factor for resolution out_video = np.repeat(out_video, slowdown_factor, axis=0) # Slowdown factor for playback
- Adjust resolution and playback speed using the
We welcome contributions to this project! To contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes and push to your fork.
- Open a pull request.
For bug reports or feature requests, please use the Issues page.
This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.
For questions or support, please contact:
Elizabeth Berrigan
- Salk Harnessing Plants Initiative: For providing support and resources for this project.
- Contributors: Thanks to all contributors for their invaluable work.
- Open Source Tools: This project relies on many open-source libraries and tools.