Skip to content

Commit

Permalink
Merge pull request #262 from matt-sd-watson/dev
Browse files Browse the repository at this point in the history
Update readimc to 0.7.0 + lenient parsing option
  • Loading branch information
Milad4849 authored May 28, 2024
2 parents 4b7ee5f + 0d05847 commit c21376a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
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
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit c21376a

Please sign in to comment.