python-microscope / microscope

Python library for control of microscope devices, supporting hardware triggers and distribution of devices over the network for performance and flexibility.
https://www.python-microscope.org
GNU General Public License v3.0
67 stars 39 forks source link

Example scripts #163

Open iandobbie opened 3 years ago

iandobbie commented 3 years ago

We should include the example scripts from the microscope paper as hints to help people utilise the package.

Initial suggestions ofr simple experiment:

`

Python script to do a simple time lapse experiment with microsocpe

copyright ian.dobbie@bioch..ox.ac.uk 2020

#

import microscope.testsuite.devices as testdevices import numpy as np import time

cam=testdevices.TestCamera() cam.initialize() cam.enable()

setup time laspe details

repeats=10 interval=30 data=np.zeros(tuple(list(cam.get_sensor_shape())+[repeats])) timestamp=np.zeros((repeats))

loop over time lapse

for i in range(repeats): data[:,:,i],timestamp[i]=cam.grab_next_data() time.sleep(interval)

#write out image?

`

iandobbie commented 3 years ago

complex example could include

Z-stacks Multi-channel (filter wheel or multiple cameras) multi position time lapse with interleaved AO

iandobbie commented 3 years ago

Updated it a bit, added file writing

`#Python script to do a simple time lapse experiment with python-microsocpe

copyright ian.dobbie@bioch..ox.ac.uk 2020

#

import microscope.testsuite.devices as testdevices import numpy as np import time import tifffile

cam=testdevices.TestCamera() cam.initialize() cam.enable()

setup time laspe details

filename="timelapse.tif" repeats=10 interval=1 data=np.zeros((cam.get_sensor_shape())) timestamp=np.zeros((repeats))

loop over time lapse

for i in range(repeats): data[:,:],timestamp[i]=cam.grab_next_data() tifffile.imwrite(filename, data, append=True) time.sleep(interval)

`