marcnol / pyHiM

Multiplexed DNA-FISH data analysis pipeline
GNU Lesser General Public License v3.0
4 stars 2 forks source link

Bug (`deinterleave_channels`) - with raw image from AIRYSCAN #243

Open XDevos opened 8 months ago

XDevos commented 8 months ago

For skimage we need:

  1. https://scikit-image.org/docs/stable/api/skimage.io.html#skimage.io.ImageCollection
  2. https://scikit-image.org/docs/stable/api/skimage.io.html#skimage.io.concatenate_images

Or, for PILLOW:

from PIL import Image, ImageSequence

path = "/mnt/grey/DATA/rawData_2024/Experiment_4_Marion_RNA-FISH_DNA-FISH_rut/rep_1/rut_intron_WF/tiff/"
img = "scan_001_DAPI_020_ROI.tif"

with Image.open(path + "/" + img) as im:
     index = 1
     for frame in ImageSequence.Iterator(im):
         index += 1
         print(index)
MarionBardou commented 8 months ago

Found a solution for stack with multiple frames that are not detected as 3D images by io.imread (skimage) or imread (tifffile) :

from skimage import io
from tifffile import imread, imwrite
import numpy as np
from tifffile import TiffFile

# Number of channels in stack
c = 3

path_stack = "/mnt/grey/DATA/rawData_2024/Experiment_4_Marion_RNA-FISH_DNA-FISH_rut/rep_1/rut_intron_WF/tiff/"

for n in range(20, 39):  # Adjust the range accordingly
    if n < 10:
        filename = "00" + str(n)
    else:
        filename = "0" + str(n)

    im_coll = io.ImageCollection(f"{path_stack}scan_001_DAPI_{filename}_ROI.tif")
    stack = io.concatenate_images(im_coll)
    stack_RNA = stack[2::c]  # Extracting the third channel
    imwrite(f"/mnt/grey/DATA/ProcessedData_2024/Experiment_4_Marion_RNA-FISH_DNA-FISH_rut/rep_1/Raw_RNA-FISH/scan_001_DAPI_{filename}_ROI_converted_decon_ch02.tif", stack_RNA)