Skip to main content

A simple module for testing used at Bliq Photonics

Project description

BliqTools

Cross-platform Python tools to manipulate any type of images and data from Bliq microscopes (and general). Used by Bliq programmers internally and by the community. For now, fairly limited with only tools for unittesting and limited tools for nirvana files and folders, but the goal is to add more and more this project public.

Project objectives

  1. To collect often-used tools in a single package, easy to install.
  2. To make manipulation of images task-oriented by removing the boiler-plate, generic code.
  3. To let the community look at the code, and tailor it to their needs.

Installing

Python 3.12 is the version used for development, and setuptools have evolved away from setup.py. The best method to install bliqtools is pip:

pip install bliqtools

or install from source:

cd bliqtools/ # In root directory of project (with setup.cfg file)
python3 -m pip install .

This will install with the current version of Python. You can then use it in scripts with:

from bliqtools.testing import *

Tools for unittesting

In bliqtools.testing, you will find these functions. You can also run the tests that are incorporated directly into the file by running it.

  1. Progress is a simple class used with contextlib that can provide reasonable feedback. The user provides total number of iterations and calls next() every iterations.
        with Progress(self.total, description="Volume creation") as progress:
            for i,j,k in self.index_list:
                tile = self.tile(i,j,k)
                volume[i-1,j-1,k-1,:,:] = tile
                progress.next()
  1. TimeIt is a simple class to time a small section of code:
        with TimeIt(f"Get layers (single)"):
            stitcher.get_layers()
  1. Debuggable can be used as a parent class to get useful debugging functions, like _dump_internals() or to see what variables have changed between calls.
    def test_base_stitcher_still_working(self):
        stitcher = Stitcher(self.valid_root_dir, overlap=0.2, channel="Grayscale")
        self.assertIsNotNone(stitcher)
        # stitcher._save_state()
        stitcher.array_from_tiff_dirs()
        stitcher.make_z_stack()
        stitcher._dump_internals()

will print:

-- begin test_base_stitcher_still_working (/Users/dccote/GitHub/Stitching/stitcher.py @line 276)

   no_c_directory [<class 'str'>                           ] : /Users/dccote/Downloads/Test_maps
   app_directory  [<class 'NoneType'>                      ] : None
   overlap        [<class 'float'>                         ] : 0.2
   dtype          [<class 'numpy.dtypes.UInt8DType'>       ] : uint8
   channel        [<class 'str'>                           ] : Grayscale
   channels       [<class 'NoneType'>                      ] : None
   start_memory   [<class 'int'>                           ] : 8276803584
   save_name      [<class 'NoneType'>                      ] : None
   array_paths    [<class 'list'>                          ] : []
   sorted_files   [<class 'list'>                          ] : len=945
   use_zarr_arrays[<class 'bool'>                          ] : False
   og_arrays      [<class 'NoneType'>                      ] : None
   z_stacks       [<class 'numpy.ndarray'>                 ] : shape=(5, 740, 2780)

-- end test_base_stitcher_still_working (/Users/dccote/GitHub/Stitching/stitcher.py @line 276)
  1. MemoryMonitor can monitor memory in a separate thread during a long calculation to provide insight on performance. It will print out the time and memory available when done:
        with MemoryMonitor(self.id()) as monitor:
            stitcher = ArrayStitcher(volume_kji=volume)
            with TimeIt(f"Save Zarr {volume_shape}"):
                stitcher.save("/tmp/test-zarr.tif")

and can be used to provide a graph of memory available vs time:

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bliqtools-1.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

bliqtools-1.1.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file bliqtools-1.1.1.tar.gz.

File metadata

  • Download URL: bliqtools-1.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for bliqtools-1.1.1.tar.gz
Algorithm Hash digest
SHA256 37aab33c26458635d4871f08b43d09538d3a8fc4588a5ed2023bf57104f1c942
MD5 6583c96343b9b3e5ed355d7ba1b7d5d9
BLAKE2b-256 e42ef7a35279fbf03e835f4208ababb4b8a5bd83ab56f7ae3ee4958aa0041598

See more details on using hashes here.

File details

Details for the file bliqtools-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: bliqtools-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for bliqtools-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8056f6a09098ccf441e9a70fe83797e87a10dc69d4ca7a1b3f9f88893622130e
MD5 3a1efe9129b5e07efc1afc86b92f5dc5
BLAKE2b-256 1038385f862530150f56eebf03201966a8086f8d7c2b883be8228fcc3aa06736

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page