Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename mantis to shrimpy #147

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install the mantis package
- name: Install the shrimpy package
run: pip install -e ".[dev]"

- name: Check code style with Black
Expand All @@ -49,7 +49,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install the mantis package
- name: Install the shrimpy package
run: pip install -e ".[dev]"

- name: Run tests
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing guide

Thanks for your interest in contributing to `mantis`!
Thanks for your interest in contributing to `shrimpy`!

## Getting started

Expand All @@ -10,10 +10,10 @@ and how you can install and use the package.
## Making changes

Any change made to the `main` branch or release maintenance branches
need to be proposed in a [pull request](https://github.com/czbiohub/mantis/pulls) (PR).
need to be proposed in a [pull request](https://github.com/czbiohub-sf/shrimPy/pulls) (PR).

Follow [these instructions](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
to [fork](https://github.com/czbiohub/mantis/fork) the repository.
to [fork](https://github.com/czbiohub-sf/shrimPy/fork) the repository.

## Setting up a development environment

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PACKAGE_NAME := mantis
PACKAGE_NAME := shrimpy

.PHONY: setup-develop
setup-develop:
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ pip install .
```

## Setting up the mantis microscope
The mantis microscope implements simultaneous label-free and light-sheet imaging as described in [Ivanov et al.](https://www.biorxiv.org/content/10.1101/2023.12.19.572435v1) The two imaging modalities are acquired on two independent arms of the microscope running separate instances of [Micro-Manager](https://micro-manager.org/) and [pycromanager](https://pycro-manager.readthedocs.io/). shrimPy was developed to enable robust long-term imaging with mantis and efficient analysis of resulting TB-scale datasets.
The mantis microscope implements simultaneous label-free and light-sheet imaging as described in [Ivanov et al.](https://www.biorxiv.org/content/10.1101/2023.12.19.572435v1) The two imaging modalities are acquired on two independent arms of the microscope running separate instances of [Micro-Manager](https://micro-manager.org/) and [pycromanager](https://pycro-manager.readthedocs.io/). shrimPy was developed to enable robust long-term imaging with shrimpy and efficient analysis of resulting TB-scale datasets.

The [Setup Guide](docs/setup_guide.md) outlines how the mantis microscope is configured.


## Data acquisition with mantis
## Data acquisition with shrimpy

Mantis acquisitions and analyses use a command-line interface.
shrimpy acquisitions and analyses use a command-line interface.

A list of `shrimpy` commands can be displayed with:
```sh
Expand All @@ -45,20 +45,20 @@ Data are acquired using `shrimpy run-acquisition`, and a list of arguments can b
shrimpy run-acquisition --help
```

The mantis acquisition is configured using a YAML file. An example of a configuration file can be found [here](mantis/acquisition/settings/example_acquisition_settings.yaml).
The shrimpy acquisition is configured using a YAML file. An example of a configuration file can be found [here](shrimpy/acquisition/settings/example_acquisition_settings.yaml).

This is an example of a command which will start an acquisition on the mantis microscope:

```pwsh
mantis run-acquisition \
shrimpy run-acquisition \
--config-filepath path/to/config.yaml \
--output-dirpath ./YYYY_MM_DD_experiment_name/acquisition_name
```

The acquisition may also be run in "demo" mode with the Micro-manager `MMConfig_Demo.cfg` config. This does not require any microscope hardware. A demo run can be started with:

```pwsh
mantis run-acquisition \
shrimpy run-acquisition \
--config-filepath path/to/config.yaml \
--output-dirpath ./YYYY_MM_DD_experiment_name/acquisition_name \
--mm-config-filepath path/to/MMConfig_Demo.cfg
Expand All @@ -81,11 +81,11 @@ iohub convert \

# DESKEW FLUORESCENCE
# estimate deskew parameters
mantis estimate-deskew \
shrimpy estimate-deskew \
-i ./acq_name_lightsheet.zarr/0/0/0 \
-o ./deskew.yml
# apply deskew parameters
mantis deskew \
shrimpy deskew \
-i ./acq_name_lightsheet.zarr/*/*/* \
-c ./deskew_params.yml \
-o ./acq_name_lightsheet_deskewed.zarr
Expand All @@ -99,18 +99,18 @@ recorder reconstruct \
# TODO: rename function calls as below
# REGISTER
# estimate registration parameters
mantis estimate-registration \
shrimpy estimate-registration \
--input-source ./acq_name_labelfree_reconstructed.zarr/0/0/0 \
--input-target ./acq_name_lightsheet_deskewed.zarr/0/0/0 \
-o ./register.yml
# optimize registration parameters
mantis optimize-registration \
shrimpy optimize-registration \
--input-source ./acq_name_labelfree_reconstructed.zarr/0/0/0 \
--input-target ./acq_name_lightsheet_deskewed.zarr/0/0/0 \
-c ./register.yml \
-o ./register_optimized.yml
# register data
mantis register \
shrimpy register \
--input-source ./acq_name_labelfree_reconstructed.zarr/*/*/* \
--input-target ./acq_name_lightsheet_deskewed.zarr/*/*/* \
-c ./register_optimized.yml \
Expand Down
8 changes: 4 additions & 4 deletions docs/data_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ YYYY_MM_DD <experiment_description>
| ...
|
| |--- logs # contains acquisition logs
| |--- mantis_acquisition_log_YYYYMMDDTHHMMSS.txt
| |--- shrimpy_acquisition_log_YYYYMMDDTHHMMSS.txt
| |--- conda_environment_log_YYYYMMDDTHHMMSS.txt
|
|--- <acq-name>_<n> # one experiment folder may contain multiple acquisitions
Expand All @@ -43,11 +43,11 @@ YYYY_MM_DD <experiment_description>

```

An example dataset is provided in: `//ESS/comp_micro/rawdata/mantis/2023_02_21_mantis_dataset_standard/`. (TODO: this example is now outdates)
An example dataset is provided in: `/hpc/instruments/cm.mantis/2023_02_21_mantis_dataset_standard/`. (TODO: this example is now outdates)

Each acquisition will contain a PTCZYX dataset; some dimensions may be singleton.

The structure of the mantis acquisition log file is not final and is subject to change. Input is welcome. Currently, acquisition script writes one log file per call.
The structure of the shrimpy acquisition log file is not final and is subject to change. Input is welcome. Currently, acquisition script writes one log file per call.

A `positions.csv` file will accompany each acquisition. This file is needed as it carries information about the position labels, which is not saved by `pycromanager`. In the future, we may decide to manage that differently - see [pycro-manager#575](https://github.com/micro-manager/pycro-manager/issues/575). A template for this file is provided [here](positions.csv).

Expand Down Expand Up @@ -80,7 +80,7 @@ YYYY_MM_DD_<experiment_description>
| |--- lightsheet # zarr dataset with TCZYX dimensions
| ...
|
|--- mantis_acquisition_log_YYYYMMDDTHHMMSS.txt
|--- shrimpy_acquisition_log_YYYYMMDDTHHMMSS.txt
|--- platemap.csv
|--- positions.csv
|--- <plate_metadata>.csv
Expand Down
16 changes: 8 additions & 8 deletions docs/mantis_usage.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Overview - unofficial
Mantis microscope is a fast multimodal microscope capable of acquiring label-free and fluorescence measurments simultaneously via two remote-refocus based arms that quickly acquire volumetric information.
The mantis microscope is a fast multimodal microscope capable of acquiring label-free and fluorescence measurments simultaneously via two remote-refocus based arms that quickly acquire volumetric information.

---
## Table of contents
Expand All @@ -12,7 +12,7 @@ Mantis microscope is a fast multimodal microscope capable of acquiring label-fre
- [Temperature probe](#temperature-probe)
- [Sample Preparation](#sample-preparation)
- [Apply silicone oil to the plate/slide](#apply-silicone-oil-to-the-plateslide)
- [Setting up the acquisition using `Mantis Acquisition Engine`](#setting-up-the-acquisition-using-mantis-acquisition-engine)
- [Setting up the acquisition using `shrimpy Acquisition Engine`](#setting-up-the-acquisition-using-shrimpy-acquisition-engine)
- [Micromanager with Label-free configuration](#micromanager-with-label-free-configuration)
- [Micromanager with Light-sheet configuration](#micromanager-with-light-sheet-configuration)
- [Setup autofocus](#setup-autofocus)
Expand Down Expand Up @@ -48,10 +48,10 @@ Mantis microscope is a fast multimodal microscope capable of acquiring label-fre
**Note: This layer should have minimal number of bubbles and enough oil for autofocus to engage. Make sure to wear gloves and discard them before touching any other microscope or computer part. Handling the oil can be messy and we want to keep things clean.

---
## Setting up the acquisition using `Mantis Acquisition Engine`
## Setting up the acquisition using `shrimpy Acquisition Engine`
1. Initialize two instances of micromanager to prepare both arms for acquisition.
1. Micromanager *230312* version with `mantis-LF.cfg` configuration.
2. Micromanager *230312 Nightly Build* version with `mantis-LS.cfg` configuration.
1. Micromanager *230312* version with `shrimpy-LF.cfg` configuration.
2. Micromanager *230312 Nightly Build* version with `shrimpy-LS.cfg` configuration.
##### Micromanager with Label-free configuration
2. Using the micromanager with the `label-free` configuration, set `Channel LS` property group to `External Control`. This will reset the microscope to the default configurations including the filter cube to position 6. Then, set the `Imaging Path` propety group to `Epi`. Set the `Channel - LF` property group to `BF`.
3. Focus the sample and check the focus is ~4700um.
Expand Down Expand Up @@ -81,7 +81,7 @@ Check the LED on the microscope body and find the PFS button on the microscope f
** Note: when it autofocus engages, the beep can be easily missed.

### YAML file:
1. Copy the default [yaml file](../mantis/acquisition/settings/example_acquisition_settings.yaml) or one from a previous acquisition similar to the planned acquisition into the acquisition folder
1. Copy the default [yaml file](../shrimPy/acquisition/settings/example_acquisition_settings.yaml) or one from a previous acquisition similar to the planned acquisition into the acquisition folder
2. Go over the YAML file and change the appropriate parameters.
3. Most likely one will change the parameters for:
- ROI
Expand Down Expand Up @@ -109,11 +109,11 @@ Check the LED on the microscope body and find the PFS button on the microscope f
## Run the acquisition
1. Open powershell
2. Activate enviroment
-`conda activate mantis`
-`conda activate shrimpy`
3. Navigate to the acquisition folder:
-`cd /path/to/acquisition`
4. Run the acquisition engine
-`mantis run-acquisition --help` for instructions.
-`shrimpy run-acquisition --help` for instructions.

---
## FAQ
Expand Down
22 changes: 11 additions & 11 deletions docs/setup_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ SpinView provides control of [FLIR](https://www.flir.com/) cameras on the micros

## Install CellDrive

CellDrive provides control of the [Meadowlark Optics](https://www.meadowlark.com/) liquid crystals (LCs) on the microscope. Install the latest version of the software which can be obtained from our Meadowlark representative. Copies of the installer are also available on ESS at TODO. We currently use software version 1.04. Ensure that both LCs can be controlled through CellDrive. The mantis acquisition controls the LCs via external voltage input - put both LCs in External Input mode.
CellDrive provides control of the [Meadowlark Optics](https://www.meadowlark.com/) liquid crystals (LCs) on the microscope. Install the latest version of the software which can be obtained from our Meadowlark representative. Copies of the installer are also available on ESS at TODO. We currently use software version 1.04. Ensure that both LCs can be controlled through CellDrive. The shrimpy acquisition controls the LCs via external voltage input - put both LCs in External Input mode.

## Update TriggerScope Firmware

The [TriggerScope](https://advancedresearch-consulting.com/product/triggerscope-4/) is used to generate electrical signals which synchronize the acquisition on the mantis microscope. Firmware for the TriggerScope is available on the [micro-manager/TriggerScopeMM](https://github.com/micro-manager/TriggerScopeMM) GitHub repo. Different versions of the TriggerScope board are available - for example V3, V4, V4B. Be sure to follow the installation instruction and install the right firmware version for a given TriggerScope board. To track the version of the firmware that is currently installed, write the 7 digit Git hash of the last commit.

## Install Vortran Stradus

The [Vortran](https://www.vortranlaser.com/) lasers on the mantis microscope are controlled using the Stradus GUI application. Install the latest version of the software which can be obtained from our Vortran representative or on ESS at `software\StradusV4_0_0`. We currently use software version 4.0.0. The mantis acquisition engine uses [coPylot](https://github.com/czbiohub-sf/coPylot) to control the lasers during acquisition.
The [Vortran](https://www.vortranlaser.com/) lasers on the mantis microscope are controlled using the Stradus GUI application. Install the latest version of the software which can be obtained from our Vortran representative or on ESS at `software\StradusV4_0_0`. We currently use software version 4.0.0. The shrimpy acquisition engine uses [coPylot](https://github.com/czbiohub-sf/coPylot) to control the lasers during acquisition.

TODO: Update setup instructions to reflect requirements for coPylot control.

## Install Thorlabs Kinesis

Thorlabs Kinesis is used to control the [PIA13](https://www.thorlabs.com/thorproduct.cfm?partnumber=PIA13) stages for positioning objectives in the microscope remote refocus paths. Install the latest version of the software available from the manufacturer's [website](https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=10285). We currently use version 1.14.30. The mantis acquisition engine uses [coPylot](https://github.com/czbiohub-sf/coPylot) to control the stages during acquisition.
Thorlabs Kinesis is used to control the [PIA13](https://www.thorlabs.com/thorproduct.cfm?partnumber=PIA13) stages for positioning objectives in the microscope remote refocus paths. Install the latest version of the software available from the manufacturer's [website](https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=10285). We currently use version 1.14.30. The shrimpy acquisition engine uses [coPylot](https://github.com/czbiohub-sf/coPylot) to control the stages during acquisition.

TODO: Update the setup instructions to reflect requirements for coPylot control.

## Install Micro-manager

The Micro-manager nightly build tested and recommended for the mantis acquisition engine is declared in [`mantis/__init__.py`](../mantis/__init__.py) and can be obtained with:
The Micro-manager nightly build tested and recommended for the shrimpy acquisition engine is declared in [`shrimpy/__init__.py`](../shrimPy/__init__.py) and can be obtained with:

```python
import mantis
print(mantis.__mm_version__)
import shrimpy
print(shrimpy.__mm_version__)
```

* Download the recommended [Micro-Manager nightly build](https://download.micro-manager.org/nightly/2.0/Windows/) and install following the installer prompts in the `C:\Program Files\Micro-Manager-2.0_YYYY_MM_DD` directory.
Expand All @@ -47,18 +47,18 @@ print(mantis.__mm_version__)

## Test the hardware setup

* Launch Micro-manager using the `mantis-LS.cfg` and `mantis-LF.cfg` config files. You should not encounter any errors during startup.
* Launch Micro-manager using the `shrimpy-LS.cfg` and `shrimpy-LF.cfg` config files. You should not encounter any errors during startup.

* Run the mantis acquisition in demo mode with
* Run the shrimpy acquisition in demo mode with

```pwsh
mantis run-acquisition `
shrimpy run-acquisition `
--data-dirpath path/to/data/directory `
--name test_acquisition `
--mm-config-file path/to/MMConfig_Demo.cfg `
--settings mantis/acquisition/settings/demo_acquisition_settings.yaml
--settings shrimpy/acquisition/settings/demo_acquisition_settings.yaml
```

* TODO: Write mantis test, some of which will test the microscope hardware
* TODO: Write shrimpy test, some of which will test the microscope hardware

* TODO: Compose an acquisition that can test the microscope hardware without requiring a sample
61 changes: 32 additions & 29 deletions examples/acquire_data.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
from mantis.acquisition.acq_engine import (
MantisAcquisition,
from shrimpy.acquisition.acq_engine import (
shrimpyAcquisition,
ChannelSliceAcquisitionSettings,
PositionTimeAcquisitionSettings)
PositionTimeAcquisitionSettings,
)

# it is possible to use different acq rate for LF and LS

pt_acq_settins = PositionTimeAcquisitionSettings(
num_timepoints = 3,
time_interval_s = 15,
xyz_positions = None, # will be acquired from MM later
position_labels = None,
focus_stage = 'ZDrive',
use_autofocus = True,
autofocus_method = 'PFS'
num_timepoints=3,
time_interval_s=15,
xyz_positions=None, # will be acquired from MM later
position_labels=None,
focus_stage='ZDrive',
use_autofocus=True,
autofocus_method='PFS',
)

lf_acq_settings = ChannelSliceAcquisitionSettings(
roi=None,
exposure_time_ms = 10,
z_scan_stage = 'MCL Piezo',
z_start = 0,
z_end = 60,
z_step = 5,
channel_group = 'Channel - LF',
channels = [f'State{i}' for i in range(5)],
use_sequence = True,
exposure_time_ms=10,
z_scan_stage='MCL Piezo',
z_start=0,
z_end=60,
z_step=5,
channel_group='Channel - LF',
channels=[f'State{i}' for i in range(5)],
use_sequence=True,
)

ls_acq_settings = ChannelSliceAcquisitionSettings(
roi = (0, 896, 2048, 256), # centered in FOV,
exposure_time_ms = 10,
z_scan_stage = 'AP Galvo',
z_start = -2/10, # in Volts
z_end = 2/10,
z_step = 0.01, # equivalent to 330 nm
channel_group = 'Channel - LS',
channels = ['GFP EX488 EM525-45'],
use_sequence = True,
roi=(0, 896, 2048, 256), # centered in FOV,
exposure_time_ms=10,
z_scan_stage='AP Galvo',
z_start=-2 / 10, # in Volts
z_end=2 / 10,
z_step=0.01, # equivalent to 330 nm
channel_group='Channel - LS',
channels=['GFP EX488 EM525-45'],
use_sequence=True,
)

acq = MantisAcquisition(acquisition_directory=r'D:\2023_02_17_mantis_dataset_standard', verbose=False)
acq = shrimpyAcquisition(
acquisition_directory=r'D:\2023_02_17_shrimpy_dataset_standard', verbose=False
)

acq.define_lf_acq_settings(lf_acq_settings)
acq.define_ls_acq_settings(ls_acq_settings)
acq.defile_position_time_acq_settings(pt_acq_settins)

acq.acquire(name = 'acq1')
acq.acquire(name='acq1')
acq.close()

print('done')
13 changes: 6 additions & 7 deletions examples/acquire_defocus_stack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from pycromanager import Core, Studio
from mantis.acquisition.microscope_operations import (
setup_kim101_stage,
from shrimpy.acquisition.microscope_operations import (
setup_kim101_stage,
acquire_ls_defocus_stack_and_display,
set_relative_kim101_position,
)
Expand All @@ -21,9 +21,9 @@
# run 5 times over
for i in range(5):
data = acquire_ls_defocus_stack_and_display(
mmc,
mmStudio,
z_stage,
mmc,
mmStudio,
z_stage,
z_range,
galvo,
galvo_range,
Expand All @@ -33,7 +33,7 @@
focus_indices = []
for stack in data:
idx = focus_from_transverse_band(
stack, NA_det=1.35, lambda_ill=0.55, pixel_size=6.5/40/1.4
stack, NA_det=1.35, lambda_ill=0.55, pixel_size=6.5 / 40 / 1.4
)
focus_indices.append(idx)

Expand All @@ -45,4 +45,3 @@
print(f'O3 displacement: {o3_displacement} steps')

set_relative_kim101_position(z_stage, o3_displacement)

Loading
Loading