Skip to main content

Bridge for controlling Zapit from Python

Project description

zapit-Python-Bridge

This code is still under development. It is in no way ready for use. This bridge uses matlab.engine to communicate with MATLAB.

Example

Until it's on PiPy you should first cd to code dir and

pip install -e .

Then in iPython:

import zapit_python_bridge.bridge as zpb
from importlib import reload

# Create an instance of the bridge object
hZP = zpb.bridge()

# Interact
hZP.send_samples()
hZP.stop_opto_stim


hZP.send_samples(conditionNum=2,laserOn=0)
hZP.stop_opto_stim()

If you need to reload the module for development purposes, you must first delete the running class instance or it will hang when it next tries to connect:

In [1]: hZP.release_matlab()
Disconnecting from MATLAB

In [2]: reload(zpb)
Out[2]: <module 'zapit_python_bridge.bridge' from 'D:zapit-python-bridge\\zapit_python_bridge\\bridge.py'>

In [3]: hZP = zpb.bridge()
Attempting MATLAB connection...
Connected!

Minimal example for running an exeperiment

See examples directory

python minimal_experiment_example.py

Connecting to the zapit session: minimal example

In MATLAB:

 >> matlab.engine.shareEngine('zapit')

In iPython:

import matlab.engine
eng = matlab.engine.connect_matlab('zapit')

Make sure you have set up and calibrated everything in Zapit. Now in Python you can do:

hZP = eng.workspace['hZP']
hZPview = eng.workspace['hZPview']
eng.eval('hZP.stimConfig.plotChanSamples(2)',nargout=0)

# OR
SC = eng.subsref(hZP, {'type':'.','subs':'stimConfig'})
eng.plotChanSamples(SC, 1, nargout=0)


eng.sendSamples(hZP,  nargout=0)
eng.stopOptoStim(hZP,  nargout=0)

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

zapit-Python-Bridge-0.1.2.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

zapit_Python_Bridge-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file zapit-Python-Bridge-0.1.2.tar.gz.

File metadata

  • Download URL: zapit-Python-Bridge-0.1.2.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for zapit-Python-Bridge-0.1.2.tar.gz
Algorithm Hash digest
SHA256 53bfcba45d9206b29f5b90d164361e35f0e67b7e1cadc6c7e44031d509c6e1d3
MD5 f4cf6d1d19900c12d686ec11f7877043
BLAKE2b-256 8364047db43fb931cd46650eeda7da89f0b0a1696bbb125d4edd5e01bf30f427

See more details on using hashes here.

File details

Details for the file zapit_Python_Bridge-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for zapit_Python_Bridge-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 846d9c34ef8747bb289bcef5d099b89594626a73a4141d4ca509b685c35eb33a
MD5 958770101b7228dbf919e03ce1c8842b
BLAKE2b-256 201454ef6698419da2d6dc470858d9ab39d6e8562743deabb1c43fddd5e12805

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