From a035b7b5bcadcd923e16fdb2419417d94b35a4ce Mon Sep 17 00:00:00 2001 From: matt-sd-watson Date: Tue, 14 May 2024 09:10:40 -0400 Subject: [PATCH 1/5] use readimc 0.7.0 w/ lenient parsing --- requirements.txt | 4 ++-- steinbock/preprocessing/imc.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5924cb59..106748b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,8 +13,8 @@ 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 -xtiff==0.7.9 +xtiff==0.7.9 \ No newline at end of file diff --git a/steinbock/preprocessing/imc.py b/steinbock/preprocessing/imc.py index 263552e6..daf18497 100644 --- a/steinbock/preprocessing/imc.py +++ b/steinbock/preprocessing/imc.py @@ -355,7 +355,7 @@ def _try_preprocess_mcd_images_from_disk( ) continue try: - img = f_mcd.read_acquisition(acquisition) + img = f_mcd.read_acquisition(acquisition, strict=False) if channel_ind is not None: img = img[channel_ind, :, :] img = preprocess_image(img, hpf=hpf) From b558aecb6d147d153b93ce03f58c4698ca48d6b5 Mon Sep 17 00:00:00 2001 From: matt-sd-watson Date: Tue, 14 May 2024 09:57:23 -0400 Subject: [PATCH 2/5] Add strict as click --- .gitignore | 1 + steinbock/preprocessing/_cli/imc.py | 12 ++++++++++-- steinbock/preprocessing/imc.py | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) 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/steinbock/preprocessing/_cli/imc.py b/steinbock/preprocessing/_cli/imc.py index c7e89c35..3f001c63 100644 --- a/steinbock/preprocessing/_cli/imc.py +++ b/steinbock/preprocessing/_cli/imc.py @@ -191,9 +191,17 @@ 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 +220,7 @@ 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 daf18497..5a4cb497 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, strict=False) + 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), From 22ad48f0b95d03a06184f96e73fd4f253f11a127 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 14:00:16 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- requirements.txt | 2 +- steinbock/preprocessing/_cli/imc.py | 11 +++++++++-- steinbock/preprocessing/imc.py | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 106748b9..bd66e889 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,4 @@ readimc==0.7.0 scikit-image==0.19.3 scipy==1.10.0 tifffile==2023.1.23.1 -xtiff==0.7.9 \ No newline at end of file +xtiff==0.7.9 diff --git a/steinbock/preprocessing/_cli/imc.py b/steinbock/preprocessing/_cli/imc.py index 3f001c63..87b98cfb 100644 --- a/steinbock/preprocessing/_cli/imc.py +++ b/steinbock/preprocessing/_cli/imc.py @@ -201,7 +201,9 @@ def panel_cmd( ) @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, strict): +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) @@ -220,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, strict=strict + 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 5a4cb497..50b5db3c 100644 --- a/steinbock/preprocessing/imc.py +++ b/steinbock/preprocessing/imc.py @@ -441,7 +441,7 @@ def try_preprocess_images_from_disk( channel_names=channel_names, hpf=hpf, unzip=unzip, - strict=strict + strict=strict, ): yield Path(mcd_file), acquisition, img, recovery_txt_file, recovered del img @@ -461,7 +461,7 @@ def try_preprocess_images_from_disk( channel_names=channel_names, hpf=hpf, unzip=unzip, - strict=strict + strict=strict, ): yield ( Path(mcd_file), From 8cf35de0d2854b9a4ed8037beb56dac11e89ccb8 Mon Sep 17 00:00:00 2001 From: matt-sd-watson Date: Tue, 14 May 2024 11:18:15 -0400 Subject: [PATCH 4/5] update dependencies --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 106748b9..305808e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,11 +3,11 @@ 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 +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 From 0d058478842e2b673c3b54140ee98390dcabe245 Mon Sep 17 00:00:00 2001 From: matt-sd-watson Date: Tue, 28 May 2024 09:09:13 -0400 Subject: [PATCH 5/5] dependencies for lxml --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 36cf5280..51850ac0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ deepcell==0.12.6 fcswrite==0.6.2 h5py==3.8.0 imageio==2.25.0 +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