gen_preview#

Generete preview images of given folder.

Assumed folder structure:

folder
|-- 00.nd2
|-- 01.nd2
|-- ...

The script will extract the images of each *.nd2 file and save as a tif image with the same name as the corresponding *.nd2 files.

Syntax

python gen_preview.py nd2Dir
  • nd2Dir – nd2 file directory

  • out_folder – folder to save a tif file with the same name as the nd2 file

Test

python gen_preview.py test_imagesatch_to_tif\day1.nd2 test_imagesatch_to_tif\preview\day1

Edit

  • Dec 12, 2021 – Initial commit

  • Dec 13, 2021 – cp command is not platform independent. Use python native tools shutil.copy instead.

  • Dec 14, 2021 – Now work on single .nd2 file, instead of a folder of tif sequences.

  • Dec 06, 2022 – Now save first and last frames for a single nd2. Change of default behavior!

  • Jan 05, 2023 – Adapt myimagelib import style.

  • Feb 08, 2023 – Rewrite in function wrapper form, to make autodoc work properly. (autodoc import the script and execute it, so anything outside if __name__=="__main__" will be executed, causing problems)

  • Jun 01, 2023 – (i) Use argparse for selecting preview frames, (ii) save preview images in the same folder as the nd2 images.