<jupyter_start><jupyter_text>This is a notebook to run the preprocessing pipeline prior to uploading your MIBItiffs to deepcell<jupyter_code># import required packages
import os
import numpy as np
import skimage.io as io
import xarray as xr

# add package to system path
import sys
sys.path.append("../")

from segmentation.utils import data_utils<jupyter_output><empty_output><jupyter_text>This script is currently configured as a template to run with the provided example data. If running your own data, make a copy of this notebook first before modifying it.                         Go to file-> make a copy to create a copy of this notebook<jupyter_code># load MIBItiff from MIBI/O-based directory structure
data_dir = "../data/example_dataset/input_data/input_data_TIFF"

# either get all points in the folder
pointfiles = os.listdir(data_dir)
pointfiles = [pointfile for pointfile in pointfiles if pointfile.startswith("Point")
              and pointfile.endswith("-MassCorrected-Filtered.tiff")]

# optionally, select a specific set of points manually
# pointfiles = ["Point1_RowNumber0_Depth_Profile0-MassCorrected-Filtered.tiff",
#               "Point2_RowNumber0_Depth_Profile0-MassCorrected-Filtered.tiff"]

mibitiff_files = [os.path.join(data_dir, pointfile) for pointfile in pointfiles]
# load channels to be included in deepcell data
channels = ["HH3", "Membrane"] # nuclear and membrane channels
data_xr = data_utils.load_imgs_from_mibitiff(mibitiff_files, channels)

# save xarray for running through deepcell
data_xr.to_netcdf(os.path.join(data_dir, "deepcell_input.xr"), format="NETCDF4")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07692307692307693, 'fraction_numerical': 0.004884004884004884, 'mean_word_length': 5.092936802973978, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '339898', 'license': 'Apache-2.0', 'n_tokens_mistral': 507, 'n_tokens_neox': 496, 'n_words': 159, 'path': 'scripts/Deepcell_Preprocessing_MIBItiff.ipynb', 'repo_name': 'mapazarr/segmentation', 'size': '1638'}