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

Update readimc to 0.7.0 + lenient parsing option #262

Merged
merged 6 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/data/
/steinbock/_version.py
images.csv

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

napari[all]==0.4.19
lxml_html_clean==0.1.1

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
Expand Down
19 changes: 17 additions & 2 deletions steinbock/preprocessing/_cli/imc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion steinbock/preprocessing/imc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -458,6 +461,7 @@ def try_preprocess_images_from_disk(
channel_names=channel_names,
hpf=hpf,
unzip=unzip,
strict=strict,
):
yield (
Path(mcd_file),
Expand Down
Loading