Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
nvladimus committed Jul 2, 2021
2 parents 359ae44 + 7b2ed63 commit fdbcc0f
Show file tree
Hide file tree
Showing 45 changed files with 2,805 additions and 2,164 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__
/**/.ipynb_checkpoints
**/*.ipynb_checkpoints/
venv/
mesoSPIM/test/fixtures/
*.log
*.bin
.idea
Expand All @@ -16,14 +17,9 @@ prototypes/python-essentials/temp\.tif
mesoSPIM/src/devices/stages/galil/gclib/gclib\.py
mesoSPIM/src/devices/stages/galil/gclib\.py
mesoSPIM/src/devices/stages/galil/gclib/__init__\.py


mesoSPIM/config/etl_parameters/*
mesoSPIM/config/*
!mesoSPIM/config/demo_config.py

mesoSPIM/config/etl_parameters/*.*
!mesoSPIM/config/etl_parameters/ETL-parameters.csv
mesoSPIM/src/mesoSPIM_DemoSerial\.py
mesoSPIM/src/devices/zoom/dynamixel\.zip

mesoSPIM/acq/
Expand Down
54 changes: 53 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
## Latest version
* :gem: Support of multiple PI single-axis controllers, thanks to #52 by @drchrisch.
Note the changes in config file: single multi-axis controller (C-884) is initialized by `'PI_1controllerNstages'`,
while multiple single-axis controllers (C-663) by `'PI_NcontrollersNstages'`.

## Version [0.1.5]
* :gem: Improved Tiling Wizard:
* buttons `x-start, x-end, y-start, y-end` added for easier navigation:
no need to search for corners of imaginary box around the sample.
* `left, then right` illuminations can be created automatically for each tile: no need for manual duplication
and changing the illumination directions in the Acquisition Manager.

* :gem: Improved saving options in Fiji/BigStitcher H5 format:
* `laser`, `illumination`, `angle` attributes are saved in the BigStitcher XML file.
* (optional) downsampling and compression are supported.
* :gem: Image window got `Adjust levels` button for automatic intensity adjustment.
* :gem: Image window got optional `Box overlay` to help measure sample dimensions.
* :mag: Tests for tiling and serial communication are created.
* :bug: **Bugfix:** long-standing `permission denied` issues with serial communication
to filter wheel and zoom servo are fixed.
The fix opens serial ports once and keeps them open during the session.
The root cause was due to laser control software polling serial ports regularly, thus blocking access to them.

## Version [0.1.4]
### Features & updates
* :warning: **Config files need to be updated** Please note: Updating to this version requires updating your microscope configuration file. Please copy the new configuration options from the `demo.cfg` file into your config files.
* :warning: :gem: **New handling of config files** - If there is a single config file (without a 'demo' prefix in the filename and apart from the `demo_config.py`-file) in the config folder, the software will automatically load this file. Otherwise, the config selection GUI is opened. This is especially helpful when operating a mesoSPIM with multiple users. Thanks to @raacampbell for this feature!
* :gem: **New: Writing HDF5** - If all rows in the acquistion manager contain the same file name (ending in `.h5`), the entire acquisition list will be saved in a single hdf5 file and a XML created automatically. Both can then be loaded into [Bigstitcher](https://imagej.net/BigStitcher) for stitching & multiview fusion.
For this, the `npy2bdv` package by @nvladimus needs to be installed via `python -m pip install npy2bdv`
* :gem: **New: Dark mode** - If the `dark_mode` option in the config file is set to `True`, the user interface appears in a dark mode. For this, the `qdarkstyle` package needs to be installed via `python -m pip install qdarkstyle`.
* :gem: **New: Camera and Acquisition Manager Windows can be reopened** - A new menu allows the camera and acquisition manager windows to be reopened in case they get closed. The same menu bar allows exiting the program as well.
* :gem: **New: Disabling arrow buttons** - To allow mesoSPIM configurations with less than 5 motorized stages, the arrow buttons in the main window can now be disabled in the configuration file. Typical examples are a mesoSPIM without a rotation stage or a mesoSPIM using only a single motorized z-stage. This feature can also be useful if the serial connection to the stages is too slow and pressing the arrow buttons leads to incorrect movements.
* :gem: **Interactive IPython console** - If the software is launched via `python mesoSPIM-control.py -C`, an interactive IPython console is launched for debugging. Feature by @raacampbell.
* :gem: **Command-line demo mode option** - If the software is launched via `python mesoSPIM-control.py -D`, it launches automatically into demo mode. Feature by @raacampbell.
* :gem: **New: Support for PCO cameras** - PCO cameras with lightsheet mode are now supported. For this the `pco` Python package needs to be installed via `python -m pip install pco`. Currently, the only tested camera is the PCO panda 4.2 bi with lightsheet firmware.
* :gem: **New: Support for Sutter Lambda 10B Filter Controller** Thanks to Kevin Dean @AdvancedImagingUTSW, Sutter filter wheels are now supported.
* :gem: **New: Support for Physik Instrumente stepper motor stages in a XYZ configuration** Thanks to @drchrisch, a mesoSPIM configuration ('PI_xyz') using stepper motor stages for sample movement is now supported. Please note that this is currently not supporting focus movements or sample rotations.
* :gem: **New: Support for Physik Instrumente C-863 controller in a single-stage config** To allow setting up a simplified mesoSPIM using only a single motorized z-stage (all other stages need to be manually operated), the combination of the C-863 motor controller and L-509 stage is now supported ('PI_z')
* :sparkles: **Improvement:** **Disabling movement buttons in the GUI** By modifying the `ui_options` dictionary in the configuration file, the X,Y,Z, focus, rotation, and load/unload buttons can be disabled. This allows modifing the UI for mesoSPIM setups which do not utilize the full set of 5 axes. Disabled buttons are greyed out.
* :sparkles: **Improvement:** **Updated multicolor tiling wizard** The tiling wizard now displays the FOV size and calculates the X and Y FOV offsets using a percentage setting. For this, the pixel size settings in the configuration file need to be set correctly.
* :sparkles: **Improvement:** **Physik Instrumente stages now report their referencing status after startup in the logfile** This allows for easier diagnosis of unreferenced stages during startup. Feature by @raacampbell.
* :bug: **Bugfix:** Binning was not working properly with all cameras.
* :bug: **Bugfix:** Removed unnecessary imports.
* :bug: **Bugfix:** Laser power setting `max_laser_voltage` was always 10V, ignoring the config file. This can damage some lasers that operate on lower command voltage.

### Contributors
* Fabian Voigt (@ffvoigt)
* Nikita Vladimirov (@nvladimus)
* Kevin Dean (@AdvancedImagingUTSW)
* Christian Schulze (@drchrisch)
* Rob Campbell (@raacampbell)

## Version [0.1.3] - March 13, 2020
* :warning: **Depending on your microscope configuration, this release breaks backward compatibility with previous configuration files. If necessary, update your configuration file using `demo_config.py` as an example.**
* :warning: **There are new startup parameters in the config file - make sure to update your config files accordingly**. For example, `average_frame_rate` has been added.
Expand Down Expand Up @@ -27,7 +79,7 @@ to f_start and at z_end, the detection path focus is at z_end. This allows imagi
* :bug: **Bugfix #34:** Fixed: Last frame in a stack is blank due to an off-by-one error
* :bug: **Bugfix #35:** Fixed: Software crashes when one folder (to save data in) in the acquisition list does not exist

---
--

## Version [0.1.2] - August 19th, 2019
* **New:** Logging is now supported. Logfiles go in the `log` folder.
Expand Down
73 changes: 48 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you are updating `mesoSPIM-control` from a previous version: Please have a cl

### Prerequisites
* Windows 7 or Windows 10
* Python >3.6
* Python >=3.6

#### Device drivers
* [Hamamatsu DCAM API](https://dcam-api.com/) when using Hamamatsu Orca Flash 4.0 V2 or V3 sCMOS cameras. To test camera functionality, [HCImage](https://dcam-api.com/hamamatsu-software/) can be used.
Expand All @@ -24,26 +24,31 @@ If you are updating `mesoSPIM-control` from a previous version: Please have a cl
* [Robotis DynamixelSDK](https://github.com/ROBOTIS-GIT/DynamixelSDK/releases) for Dynamixel Zoom servos. Make sure you download version 3.5.4 of the SDK.

#### Python
mesoSPIM-control is usually running with [Anaconda](https://www.anaconda.com/download/) using a >3.6 Python. For a clean python install, the following packages are necessary (part of Anaconda):

* csv
* traceback
* pprint
* numpy
* scipy
* ctypes
* importlib
* PyQt5 (if there are problems with PyQt5 such as `ModuleNotFoundError: No module named 'PyQt5.QtWinExtras` after starting `mesoSPIM-control`, try reinstalling PyQt5 by: `python -m pip install --user -I PyQt5` and `python -m pip install --user -I PyQt5-sip`)

In addition (for Anaconda), the following packages need to be installed:
* nidaqmx (`python -m pip install nidaqmx`)
* indexed (`python -m pip install indexed`)
* serial (`python -m pip install pyserial`)
* pyqtgraph (`python -m pip install pyqtgraph`)
* pywinusb (`python -m pip install pywinusb`)
* PIPython (part of the Physik Instrumente software collection. Unzip it, `cd` to the directory with the Anaconda terminal as an admin user, then install with `python setup.py install`. Test install with test installation with `import pipython`). You can also download PIPython [here](https://github.com/royerlab/pipython)
* tifffile (`python -m pip install tifffile`)
* ([PyVCAM when using Photometrics cameras](https://github.com/Photometrics/PyVCAM)
mesoSPIM-control is usually running with [Anaconda](https://www.anaconda.com/download/) using a >=3.6 Python.
##### Anaconda
(optional) Create and activate a Python 3.6 environment from Anaconda prompt (you can use any name instead of `py36`):
```
conda create -n py36 python=3.6
conda activate py36
```
The step above is optional because the latest Python 3.8 is backward compatible with Python 3.6 code.

Many libraries are already included in Anaconda.
Install mesoSPIM-specific libraries:
```
pip install -r requirements-anaconda.txt
```

##### Clean python
For a clean (non-Anaconda) python interpreter, install all required libraries:
```
pip install -r requirements-clean-python.txt
```

##### Additional libraries
Camera libraries are not hosted on PyPi and need to be installed manually:
* [PyVCAM when using a Photometrics camera](https://github.com/Photometrics/PyVCAM)
* pco (`python -m pip install pco`) when using a PCO camera ([Link](https://pypi.org/project/pco/)). A Version ≥0.1.3 is recommended.

#### Preparing python bindings for device drivers
* For PI stages, copy `C:\ProgramData\PI\GCSTranslator\PI_GCS2_DLL_x64.dll` in the main mesoSPIM folder: `PI_GCS2_DLL_x64.dll`
Expand All @@ -63,12 +68,30 @@ At time of writing that means the master trigger out (`PXI6259/port0/line1`) sho
Use BNC T connectors to split each analog output line to both lasers.
* You will need to set the ThorLabs shutter controllers to run on TTL input mode.

#### Run the software.
## Launching
#### From Anaconda prompt
```
conda activate py36
python mesoSPIM_Control.py
```
After launch, it will prompt you for a configuration file. Please choose a file
with demo devices (e.g. `DemoStage`) for testing.
The software will now start. If you have multiple configuration files you will be prompted to choose one.

#### From start_mesoSPIM.bat file
Open the `start_mesoSPIM.bat` file in text editor and configure Anaconda and `py36` path to your own.
Once done, launch mesoSPIM by double-clicking the file.
Optionally, create a Windows shortcut (via right-click menu) and place it e.g. on your desktop.
Using shortcut saves a lot of time.

#### Starting with interactive console
You may also run the software with an interactive IPython console for de-bugging:
```
python mesoSPIM_Control.py -C
```
For example, executing `mSpim.state.__dict__` in this console will show the current mesoSPIM state.

## Troubleshooting
If there are problems with PyQt5 such as `ModuleNotFoundError: No module named 'PyQt5.QtWinExtras` after starting
`mesoSPIM-control`, try reinstalling PyQt5 by: `python -m pip install --user -I PyQt5` and `python -m pip install --user -I PyQt5-sip`)

#### Documentation for users
## Documentation for users
For instructions on how to use mesoSPIM-control, please check out the documentation [here](https://github.com/mesoSPIM/mesoSPIM-powerpoint-documentation).
78 changes: 42 additions & 36 deletions mesoSPIM/config/demo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
(The extension has to be .py).
'''

'''
Dark mode: Renders the UI dark
'''
ui_options = {'dark_mode' : True, # Dark mode: Renders the UI dark if enabled
'enable_x_buttons' : True, # Here, specific sets of UI buttons can be disabled
'enable_y_buttons' : True,
'enable_z_buttons' : True,
'enable_f_buttons' : True,
'enable_rotation_buttons' : True,
'enable_loading_buttons' : True,
}

'''
Waveform output for Galvos, ETLs etc.
'''
Expand Down Expand Up @@ -186,9 +198,12 @@
and safety limits. The rotation position defines a XYZ position (in absolute coordinates)
where sample rotation is safe. Additional hardware dictionaries (e.g. pi_parameters)
define the stage configuration details.
All positions are absolute.
'stage_type' options: 'DemoStage', 'PI_1controllerNstages' (former 'PI'), 'PI_NcontrollersNstages'
'''

stage_parameters = {'stage_type' : 'DemoStage', # 'DemoStage' or 'PI' or other configs found in mesoSPIM_serial.py
stage_parameters = {'stage_type' : 'DemoStage', # 'DemoStage'. 'PI_1controllerNstages', 'PI_NcontrollersNstages', see below
'startfocus' : -10000,
'y_load_position': -86000,
'y_unload_position': -120000,
Expand All @@ -198,54 +213,40 @@
'y_min' : -160000,
'z_max' : 99000,
'z_min' : -99000,
'f_max' : 99000,
'f_min' : -99000,
'f_max' : 10000,
'f_min' : -10000,
'theta_max' : 999,
'theta_min' : -999,
'x_rot_position': 0,
'y_rot_position': -121000,
'z_rot_position': 66000,
}

'''
Depending on the stage hardware, further dictionaries define further details of the stage configuration
For a standard mesoSPIM V4 with PI stages, the following pi_parameters are necessary (replace the
serialnumber with the one of your controller):
''''
If 'stage_type' = 'PI_1controllerNstages' (vanilla mesoSPIM V5 with single 6-axis controller):
pi_parameters = {'controllername' : 'C-884',
'stages' : ('M-112K033','L-406.40DG10','M-112K033','M-116.DG','M-406.4PD','NOSTAGE'),
'stages' : ('L-509.20DG10','L-509.40DG10','L-509.20DG10','M-060.DG','M-406.4PD','NOSTAGE'),
'refmode' : ('FRF',),
'serialnum' : ('118015797'),
'serialnum' : ('118075764'),
}
For a standard mesoSPIM V5 with PI stages, the following pi_parameters are necessary (replace the
serialnumber with the one of your controller):
pi_parameters = {'controllername' : 'C-884',
'stages' : ('L-509.20DG10','L-509.40DG10','L-509.20DG10','M-060.DG','M-406.4PD','NOSTAGE'),
'refmode' : ('FRF',),
'serialnum' : ('118015799'),
If 'stage_type' = 'PI_NcontrollersNstages' (mesoSPIM V5 with multiple single-axis controllers):
pi_parameters = {'axes_names': ('x', 'y', 'z', 'theta', 'f'),
'stages': ('L-509.20SD00', 'L-509.40SD00', 'L-509.20SD00', None, 'MESOSPIM_FOCUS'),
'controllername': ('C-663', 'C-663', 'C-663', None, 'C-663'),
'serialnum': ('**********', '**********', '**********', None, '**********'),
'refmode': ('FRF', 'FRF', 'FRF', None, 'RON')
}
'''

'''
Filterwheel configuration
'''

'''
For a DemoFilterWheel, no COMport needs to be specified, for a Ludl Filterwheel,
a valid COMport is necessary.
For a DemoFilterWheel, no COMport needs to be specified.
For a Ludl Filterwheel, a valid COMport is necessary. Ludl marking 10 = position 0.
'''
filterwheel_parameters = {'filterwheel_type' : 'DemoFilterWheel', # 'DemoFilterWheel' or 'Ludl'
'COMport' : 'COM53'}

# Ludl marking 10 = position 0

'''
A Ludl double filter wheel can be
'''

filterdict = {'Empty-Alignment' : 0, # Every config should contain this
'405-488-647-Tripleblock' : 1,
'405-488-561-640-Quadrupleblock' : 2,
Expand All @@ -259,9 +260,6 @@

'''
Zoom configuration
'''

'''
For the DemoZoom, servo_id, COMport and baudrate do not matter. For a Dynamixel zoom,
these values have to be there
'''
Expand Down Expand Up @@ -302,10 +300,18 @@
'6.3x' : 1.03}

'''
Initial acquisition parameters
HDF5 parameters, if this format is used for data saving (optional).
Downsampling and compression slows down writing by 5x - 10x, use with caution.
Imaris can open these files if no subsampling and no compression is used.
'''
hdf5 = {'subsamp': ((1, 1, 1),), #((1, 1, 1),) no subsamp, ((1, 1, 1), (1, 4, 4)) for 2-level (z,y,x) subsamp.
'compression': None, # None, 'gzip', 'lzf'
'flip_xyz': (True, True, False) # match BigStitcher coordinates to mesoSPIM axes.
}

'''
Initial acquisition parameters
Used as initial values after startup
When setting up a new mesoSPIM, make sure that:
* 'max_laser_voltage' is correct (5 V for Toptica MLEs, 10 V for Omicron SOLE)
* 'galvo_l_amplitude' and 'galvo_r_amplitude' (in V) are correct (not above the max input allowed by your galvos)
Expand Down Expand Up @@ -369,4 +375,4 @@
'camera_binning':'1x1',
'camera_sensor_mode':'ASLM',
'average_frame_rate': 4.969,
}
}
Loading

0 comments on commit fdbcc0f

Please sign in to comment.