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

PR#100 merge bug fix #115

Merged
merged 3 commits into from
Feb 23, 2025
Merged
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
7 changes: 4 additions & 3 deletions software/control/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from control.multipoint_built_in_functionalities import malaria_rtp

import control.utils as utils
import control.utils_channel as utils_channel
import control.utils_config as utils_config
import control.tracking as tracking
import control.serial_peripherals as serial_peripherals
Expand Down Expand Up @@ -499,7 +500,7 @@ def __init__(
def turn_on_illumination(self):
if self.illuminationController is not None and not "LED matrix" in self.currentConfiguration.name:
self.illuminationController.turn_on_illumination(
int(utils.extract_wavelength_from_config_name(self.currentConfiguration.name))
int(utils_channel.extract_wavelength_from_config_name(self.currentConfiguration.name))
)
elif SUPPORT_SCIMICROSCOPY_LED_ARRAY and "LED matrix" in self.currentConfiguration.name:
self.led_array.turn_on_illumination()
Expand All @@ -510,7 +511,7 @@ def turn_on_illumination(self):
def turn_off_illumination(self):
if self.illuminationController is not None and not "LED matrix" in self.currentConfiguration.name:
self.illuminationController.turn_off_illumination(
int(utils.extract_wavelength_from_config_name(self.currentConfiguration.name))
int(utils_channel.extract_wavelength_from_config_name(self.currentConfiguration.name))
)
elif SUPPORT_SCIMICROSCOPY_LED_ARRAY and "LED matrix" in self.currentConfiguration.name:
self.led_array.turn_off_illumination()
Expand Down Expand Up @@ -563,7 +564,7 @@ def set_illumination(self, illumination_source, intensity, update_channel_settin
# update illumination
if self.illuminationController is not None:
self.illuminationController.set_intensity(
int(utils.extract_wavelength_from_config_name(self.currentConfiguration.name)), intensity
int(utils_channel.extract_wavelength_from_config_name(self.currentConfiguration.name)), intensity
)
elif ENABLE_NL5 and NL5_USE_DOUT and "Fluorescence" in self.currentConfiguration.name:
wavelength = int(self.currentConfiguration.name[13:16])
Expand Down
17 changes: 0 additions & 17 deletions software/control/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from scipy.ndimage import label
from scipy import signal
import os
from control._def import CHANNEL_COLORS_MAP
from typing import Optional, Tuple
from enum import Enum, auto
import squid.logging
Expand Down Expand Up @@ -175,22 +174,6 @@ def ensure_directory_exists(raw_string_path: str):
path.mkdir(parents=True, exist_ok=True)


def extract_wavelength_from_config_name(name):
# Split the string and find the wavelength number immediately after "Fluorescence"
parts = name.split()
if "Fluorescence" in parts:
index = parts.index("Fluorescence") + 1
if index < len(parts):
return parts[index].split()[0] # Assuming 'Fluorescence 488 nm Ex' and taking '488'
for color in ["R", "G", "B"]:
if color in parts or "full_" + color in parts:
return color
return None


def get_channel_color(channel):
channel_info = CHANNEL_COLORS_MAP.get(extract_wavelength_from_config_name(channel), {"hex": 0xFFFFFF, "name": "gray"})
return channel_info["hex"]
class SpotDetectionMode(Enum):
"""Specifies which spot to detect when multiple spots are present.

Expand Down
18 changes: 18 additions & 0 deletions software/control/utils_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from control._def import CHANNEL_COLORS_MAP

def extract_wavelength_from_config_name(name):
# Split the string and find the wavelength number immediately after "Fluorescence"
parts = name.split()
if "Fluorescence" in parts:
index = parts.index("Fluorescence") + 1
if index < len(parts):
return parts[index].split()[0] # Assuming 'Fluorescence 488 nm Ex' and taking '488'
for color in ["R", "G", "B"]:
if color in parts or "full_" + color in parts:
return color
return None


def get_channel_color(channel):
channel_info = CHANNEL_COLORS_MAP.get(extract_wavelength_from_config_name(channel), {"hex": 0xFFFFFF, "name": "gray"})
return channel_info["hex"]
5 changes: 2 additions & 3 deletions software/control/utils_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from pydantic_xml import BaseXmlModel, element, attr
from typing import List, Optional
from pathlib import Path
import control.utils as utils

import control.utils_channel as utils_channel

class LaserAFConfig(BaseModel):
"""Pydantic model for laser autofocus configuration"""
Expand Down Expand Up @@ -34,7 +33,7 @@ class ChannelMode(BaseXmlModel, tag='mode'):

def __init__(self, **data):
super().__init__(**data)
self.color = utils.get_channel_color(self.name)
self.color = utils_channel.get_channel_color(self.name)

class ChannelConfig(BaseXmlModel, tag='modes'):
"""Root configuration file model"""
Expand Down
3 changes: 1 addition & 2 deletions software/main_hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def show_acq_config(cfm):
log.error("Couldn't setup logging to file!")
sys.exit(1)

log.info(f"Squid Repository State: {
.get_squid_repo_state_description()}")
log.info(f"Squid Repository State: {control.utils.get_squid_repo_state_description()}")

legacy_config = False
cf_editor_parser = ConfigParser()
Expand Down
2 changes: 1 addition & 1 deletion software/setup_22.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mkdir -p "$SQUID_SOFTWARE_ROOT/cache"
# install libraries
pip3 install qtpy pyserial pandas imageio crc==1.3.0 lxml numpy tifffile scipy napari pyreadline3
pip3 install opencv-python-headless opencv-contrib-python-headless
pip3 install napari[all] scikit-image dask_image ome_zarr aicsimageio basicpy pytest pytest-qt gitpython matplotlib
pip3 install napari[all] scikit-image dask_image ome_zarr aicsimageio basicpy pytest pytest-qt gitpython matplotlib pydantic_xml

# install camera drivers
cd "$DAHENG_CAMERA_DRIVER_ROOT"
Expand Down
Loading