Skip to main content

A Python Library for VISoR Image.

Project description

visor-py

A Python Library for VISoR Image.

Usage

Install Module

pip install visor-py

Import Module

import visor.image as vimg

Examples

  • Read .vsr
import visor.image as vimg

# Open .vsr file with read-only ('r') mode
# img is a visor.Image object 
img = vimg.open_vsr('path/to/VISOR001.vsr', 'r')
print(img.info)
  • Read raw image
import visor.image as vimg
img = vimg.open_vsr('path/to/VISOR001.vsr', 'r')

# Read raw image of slice_1_10x from zarr file
# arr is a visor.Array object
arr = img.read(img_type='raw',
               zarr_file='slice_1_10x.zarr',
               resolution=0)
print(arr.info)
  • Read arrays by named stacks or channels
import visor.image as vimg
img = vimg.open_vsr('path/to/VISOR001.vsr', 'r')
arr = img.read(img_type='raw',
               zarr_file='slice_1_10x.zarr',
               resolution=0)

# Read stack by label
# s1_array is a dask.array, dimensions: c,z,y,x
s1_array = arr.read(stack='stack_1')
print(f's1_array shape: {s1_array.shape}, dimensions: c,z,y,x')

# Read channel by wavelength
# c488_array is a dask.array, dimensions: s,z,y,x
c488_array = arr.read(channel='488')
print(f'c488_array shape: {c488_array.shape}, dimensions: s,z,y,x')

# Read stack and channel
# s1c488_array is a dask.array, dimensions: z,y,x
s1c488_array = arr.read(stack='stack_1', channel='488')
print(f's1c488_array shape: {s1c488_array.shape}, dimensions: z,y,x')
  • Read array by index
import visor.image as vimg
img = vimg.open_vsr('path/to/VISOR001.vsr', 'r')
arr = img.read(img_type='raw',
               zarr_file='slice_1_10x.zarr',
               resolution=0)

# Read by index
# the_array is a dask.array
the_array = arr.array
print(f'the_array shape: {the_array.shape}, dimensions: s,c,z,y,x')
# subarr is a dask.array
subarr = the_array[0,0,:,:,:]
print(f'subarr shape: {subarr.shape}, dimensions: z,y,x')
  • Write .vsr
import visor.image as vimg
import numpy as np
import dask.array as da

# Open .vsr file with write ('w') mode
# img is a visor.Image object 
img = vimg.open_vsr('path/to/VISOR001.vsr', 'w')

# Generate a random array
# new_arr is a dask array
new_arr = da.random.random(size=(2, 2, 4, 4, 4), chunks=(1, 1, 2, 2, 2))

# Metadata
# follow https://visor-tech.github.io/visor-data-schema/
img_info = {}    # info.json
arr_info = {}    # .zattrs
selected = {}    # selected.json

# Write array to .vsr
img.write(arr=new_arr,
          img_type='raw',
          file='slice_1_10x',
          resolution=0,
          img_info=img_info,
          arr_info=arr_info,
          selected=selected)

References

VISoR Image Schema

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

visor_py-2024.12.3.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

visor_py-2024.12.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file visor_py-2024.12.3.tar.gz.

File metadata

  • Download URL: visor_py-2024.12.3.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for visor_py-2024.12.3.tar.gz
Algorithm Hash digest
SHA256 a87658de430dee333c92bfdb303958d0e190a53893d3432c7585ab40d0bb61a0
MD5 e6d76cd0910c49e29ed21eb73fefe1d8
BLAKE2b-256 590f92b1abeb151dea34e12c24150e2ac5c4e0995ee96ef2af64287bb9584c38

See more details on using hashes here.

File details

Details for the file visor_py-2024.12.3-py3-none-any.whl.

File metadata

  • Download URL: visor_py-2024.12.3-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for visor_py-2024.12.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b60a870e6abcd92b4f723707213a29e7761114655910b4ae57223ae370d1d9d
MD5 a99a7a0bd4def8c1d8f628aaf296d15e
BLAKE2b-256 6c17cbfc8dcd41a088f4ea21707cbe5b0aacd25ef8c8307d1f67aa49f3de2634

See more details on using hashes here.

Supported by

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