diff --git a/.gitignore b/.gitignore index f88fa272..df3bf2a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /data/ /steinbock/_version.py +images.csv # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/requirements.txt b/requirements.txt index 5924cb59..51850ac0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,17 +3,18 @@ anndata==0.8.0 # cellpose # not included in default Docker containers (see Dockerfile for version) click==8.1.3 click-log==0.4.0 -deepcell==0.12.4 +deepcell==0.12.6 fcswrite==0.6.2 h5py==3.8.0 imageio==2.25.0 -napari[all]==0.4.17 +lxml_html_clean==0.1.1 +napari[all]==0.4.19 networkx==3.0 numpy==1.23.5 # deepcell 0.12.4 requires <1.24 opencv-python-headless==4.7.0.68 pandas==1.5.3 pyyaml==6.0 -readimc==0.6.2 +readimc==0.7.0 scikit-image==0.19.3 scipy==1.10.0 tifffile==2023.1.23.1 diff --git a/steinbock/preprocessing/_cli/imc.py b/steinbock/preprocessing/_cli/imc.py index c7e89c35..87b98cfb 100644 --- a/steinbock/preprocessing/_cli/imc.py +++ b/steinbock/preprocessing/_cli/imc.py @@ -191,9 +191,19 @@ def panel_cmd( show_default=True, help="Path to the image information output file", ) +@click.option( + "--strict", + "strict", + default=True, + show_default=True, + type=bool, + help="Use strict parsing (skip and throw errors on corrupted ROIs)", +) @click_log.simple_verbosity_option(logger=steinbock_logger) @catch_exception(handle=SteinbockException) -def images_cmd(mcd_dir, txt_dir, unzip, panel_file, hpf, img_dir, image_info_file): +def images_cmd( + mcd_dir, txt_dir, unzip, panel_file, hpf, img_dir, image_info_file, strict +): channel_names = None if Path(panel_file).is_file(): panel = io.read_panel(panel_file) @@ -212,7 +222,12 @@ def images_cmd(mcd_dir, txt_dir, unzip, panel_file, hpf, img_dir, image_info_fil recovery_txt_file, recovered, ) in imc.try_preprocess_images_from_disk( - mcd_files, txt_files, channel_names=channel_names, hpf=hpf, unzip=unzip + mcd_files, + txt_files, + channel_names=channel_names, + hpf=hpf, + unzip=unzip, + strict=strict, ): img_file_stem = Path(mcd_or_txt_file).stem if acquisition is not None: diff --git a/steinbock/preprocessing/imc.py b/steinbock/preprocessing/imc.py index 263552e6..50b5db3c 100644 --- a/steinbock/preprocessing/imc.py +++ b/steinbock/preprocessing/imc.py @@ -334,6 +334,7 @@ def _try_preprocess_mcd_images_from_disk( channel_names: Optional[Sequence[str]] = None, hpf: Optional[float] = None, unzip: bool = False, + strict: bool = False, ) -> Generator[Tuple[Acquisition, np.ndarray, Optional[Path], bool], None, None]: try: with MCDFile(mcd_file) as f_mcd: @@ -355,7 +356,7 @@ def _try_preprocess_mcd_images_from_disk( ) continue try: - img = f_mcd.read_acquisition(acquisition) + img = f_mcd.read_acquisition(acquisition, strict=strict) if channel_ind is not None: img = img[channel_ind, :, :] img = preprocess_image(img, hpf=hpf) @@ -415,6 +416,7 @@ def try_preprocess_images_from_disk( channel_names: Optional[Sequence[str]] = None, hpf: Optional[float] = None, unzip: bool = False, + strict: bool = False, ) -> Generator[ Tuple[Path, Optional["Acquisition"], np.ndarray, Optional[Path], bool], None, @@ -439,6 +441,7 @@ def try_preprocess_images_from_disk( channel_names=channel_names, hpf=hpf, unzip=unzip, + strict=strict, ): yield Path(mcd_file), acquisition, img, recovery_txt_file, recovered del img @@ -458,6 +461,7 @@ def try_preprocess_images_from_disk( channel_names=channel_names, hpf=hpf, unzip=unzip, + strict=strict, ): yield ( Path(mcd_file),