Skip to main content

This is a package that connects ImSwitch's REST API to the rest of the world (e.g. jupyter lab)

Project description

ImSwitchClient Documentation

ImSwitchClient is a Python package designed to connect to the ImSwitch REST API, enabling remote control of ImSwitchUC2 functionalities directly from Jupyter Notebooks. This client facilitates easy integration with the ImSwitch ecosystem, offering programmable access to various features like laser control, stage manipulation, and image acquisition.

PyPI Version

Features

Installation

To install ImSwitchClient, use the following pip command:

pip install imswitchclient

Quick Start Example

This example demonstrates basic usage of ImSwitchClient for moving a positioner and acquiring an image.

import imswitchclient.ImSwitchClient as imc 
import numpy as np
import matplotlib.pyplot as plt
import time

# Initialize the client
client = imc.ImSwitchClient()

# Retrieve the first positioner's name and current position
positioner_names = client.positionersManager.getAllDeviceNames()
positioner_name = positioner_names[0]
currentPositions = client.positionersManager.getPositionerPositions()[positioner_name]
initialPosition = (currentPositions["X"], currentPositions["Y"])

# turn on illumination
mLaserName = client.lasersManager.getLaserNames()[0]
client.lasersManager.setLaserActive(mLaserName, True)
client.lasersManager.setLaserValue(mLaserName, 512)

for ix in range(10):
    for iy in range(10):
        # Define and move to a new position
        newPosition = (initialPosition[0] + ix*50, initialPosition[1] + iy*50)
        client.positionersManager.movePositioner(positioner_name, "X", newPosition[0], is_absolute=True, is_blocking=True)
        client.positionersManager.movePositioner(positioner_name, "Y", newPosition[1], is_absolute=True, is_blocking=True)
        
        # Acquire and display an image
        #time.sleep(0.5)  # Allow time for the move
        lastFrame = client.recordingManager.snapNumpyToFastAPI()
        plt.imshow(lastFrame)
        plt.show()
        
        # Return the positioner to its initial position
        client.positionersManager.movePositioner(positioner_name, "X", initialPosition[0], is_absolute=True, is_blocking=True)
        client.positionersManager.movePositioner(positioner_name, "Y", initialPosition[1], is_absolute=True, is_blocking=True)

Contributing

Contributions to ImSwitchClient are welcome! Please refer to the project's GitHub repository for contribution guidelines: https://github.com/openUC2/imswitchclient/.

License

ImSwitchClient is licensed under the MIT License. For more details, see the LICENSE file in the project repository.

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

imswitchclient-0.1.2.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

imswitchclient-0.1.2-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file imswitchclient-0.1.2.tar.gz.

File metadata

  • Download URL: imswitchclient-0.1.2.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for imswitchclient-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fd16467013778f23c1fb680c2958e00ae411d38d120ae8cf50eb77528d79e226
MD5 439f369b7776b5d5661844c1c3236783
BLAKE2b-256 cd96ac785b2792731d9917ca77e1fe39df5db65c460db75624f3e2de274decea

See more details on using hashes here.

File details

Details for the file imswitchclient-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for imswitchclient-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 04973800d44c84fa2705b9f19d63d4e39b43eca1600232ee6995ba33c5d49790
MD5 9b1dee9896cde57c221ac6db705e1cb3
BLAKE2b-256 5ff6eb292f039df08b9c9a0765db0d891d9e813e0639501615285892cc4fcd93

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