Hoffman2:Scripts:gen movie.py: Difference between revisions

From Center for Cognitive Neuroscience
Jump to navigation Jump to search
Line 30: Line 30:


  /u/project/ccn/apps/scripts/gen_movie.py -i /path/to/T1w_brain.nii.gz -o /path/to/output/ --win "0.05 0.995" --bin 100
  /u/project/ccn/apps/scripts/gen_movie.py -i /path/to/T1w_brain.nii.gz -o /path/to/output/ --win "0.05 0.995" --bin 100
In this example, the script will read the input file from /path/to/T1w_brain.nii.gz and create a "movie" folder under /path/to/output/ and generate a movie file from the input file under movie/ folder, named as mri_movie.mp4. So you will find the output file at /path/to/output/movie/mri_movie.mp4.

Revision as of 01:32, 16 August 2024

Purpose

To convert a 3D MRI image in nifti format to a movie.

Setup Environment

To use this script, you need to load Anaconda module first and use conda environment ccn_py37
ccn_py37 contains nibabel which is need to read nifti files. ffmpeg is also needed for this script to run.

 module load anaconda3
 conda activate /u/project/CCN/apps/conda/rh7/ccn_py37
 module load ffmpeg/5.0.1

Usage/Help

To see the usage of this script

./gen_movie.py --help usage: gen_movie.py [-h] -i INPUT [-o OUTDIR] [-b BIN] [-w WIN]

optional arguments:

 -h, --help            show this help message and exit
 -i INPUT, --input INPUT
                       Full path to input nii file
 -o OUTDIR, --outdir OUTDIR
                       Output directory for movie file
 -b BIN, --bin BIN     Number of bins used in histogram. i.e. 100
 -w WIN, --win WIN     Window range. i.e. "0.05 0.995"

Example:

/u/project/ccn/apps/scripts/gen_movie.py -i /path/to/T1w_brain.nii.gz -o /path/to/output/ --win "0.05 0.995" --bin 100

In this example, the script will read the input file from /path/to/T1w_brain.nii.gz and create a "movie" folder under /path/to/output/ and generate a movie file from the input file under movie/ folder, named as mri_movie.mp4. So you will find the output file at /path/to/output/movie/mri_movie.mp4.