BodenmillerGroup / ImcSegmentationPipeline

A pixel classification based multiplexed image segmentation pipeline
https://bodenmillergroup.github.io/ImcSegmentationPipeline/
MIT License
83 stars 35 forks source link

Dimesion mismatch between 'masks' & 'image'-tiffs after 2_segment_ilastik #54

Closed maxgrigori closed 3 years ago

maxgrigori commented 3 years ago

Dear Votti,

I have an issue at the end of the '2_segment_ilastik'-step of the pipeline, which I just cannot seem to get around....

The step itself works fine and the segmentation seems to be successful, however the generated masks are being mostly saved as 250x250pixel -tiff files, while my image-tiff-files in the histocat-folder from earlier are usually larger (e.g. 607x453 in one ROI).

This mismatch in dimensions seems to be causing an error when I try using histoCat or ImaCytE afterwards. Both programs fail to load the tiff-files and give following error instead:

C:\Program Files\BerndBodenmillerGroup\histoCAT\application>Samples arranged..Loading Masks,Tiffs of all Samples.. Warning: File: C:\Users\Maxim\AppData\Local\Temp\Maxim\mcrCache8.4\histoC0\histoCAT\Loading_New\Load_Functions\Load_mask.m Line: 162 Column: 5 This try-catch syntax will continue to work in R2007b, but may be illegal or may mean something different in future releases of MATLAB. See MATLAB R2007a Release Notes, "Warning Generated by try-catch" for details.

In Load_MatrixDB at 29
In Master_LoadSamples at 41
In gui_mainfcn at 95
In histoCAT at 42
In @(hObject,eventdata)histoCAT('Master_LoadSamples',hObject,eventdata,guidata(hObject))
Error using iptassert (line 19)
Size of I doesn't match size information found in the first input argument.

Error in regionprops>ParseInputs (line 1168)

Error in regionprops (line 154)

Error in Process_SingleCell_Tiff_Mask>@(chan)struct2array(regionprops(Current_Mask,chandat{chan},'MeanIntensity'))' (line 80)

Error in Process_SingleCell_Tiff_Mask (line 81)

Error in DataProcessing_Master (line 29)

Error in Master_LoadSamples (line 50)

Error in gui_mainfcn (line 95)

Error in histoCAT (line 42)

Error in @(hObject,eventdata)histoCAT('Master_LoadSamples',hObject,eventdata,guidata(hObject))

Error while evaluating Menu Callback

I was following your guide for segmentation and have tried playing around with the settings as well, but I cannot get around this error and histoCat refuses to work. Do you know how to fix this issue?

It would be splendid! Thank You for the help beforehand! Best, Max

votti commented 3 years ago

Hi,

Are you sure you are not accidentally processing the "training" crop images stored in the ulastik subfolder?

to do this correctly train first a classifier using the crops and then apply the vlassifier to the .h5 files from the tiff subfolder. These probabilities should give you the right masks.

Does this make sense to you?

Best, Vito

On Sun, Dec 13, 2020, 16:57 maxgrigori notifications@github.com wrote:

Dear Votti,

I have an issue at the end of the '2_segment_ilastik'-step of the pipeline, which I just cannot seem to get around....

The step itself works fine and the segmentation seems to be successful, however the generated masks are being mostly saved as 250x250pixel -tiff files, while my image-tiff-files in the histocat-folder from earlier are usually larger (e.g. 607x453 in one ROI).

This mismatch in dimensions seems to be causing an error when I try using histoCat or ImaCytE afterwards. Both programs fail to load the tiff-files and give following error instead:

C:\Program Files\BerndBodenmillerGroup\histoCAT\application>Samples arranged..Loading Masks,Tiffs of all Samples.. Warning: File: C:\Users\Maxim\AppData\Local\Temp\Maxim\mcrCache8.4\histoC0\histoCAT\Loading_New\Load_Functions\Load_mask.m Line: 162 Column: 5 This try-catch syntax will continue to work in R2007b, but may be illegal or may mean something different in future releases of MATLAB. See MATLAB R2007a Release Notes, "Warning Generated by try-catch" for details.

In Load_MatrixDB at 29 In Master_LoadSamples at 41 In gui_mainfcn at 95 In histoCAT at 42 In @(hObject,eventdata)histoCAT('Master_LoadSamples',hObject,eventdata,guidata(hObject)) Error using iptassert (line 19) Size of I doesn't match size information found in the first input argument.

Error in regionprops>ParseInputs (line 1168)

Error in regionprops (line 154)

Error in Process_SingleCell_Tiff_Mask>@(chan)struct2array(regionprops(Current_Mask,chandat{chan},'MeanIntensity'))' (line 80)

Error in Process_SingleCell_Tiff_Mask (line 81)

Error in DataProcessing_Master (line 29)

Error in Master_LoadSamples (line 50)

Error in gui_mainfcn (line 95)

Error in histoCAT (line 42)

Error in @(hObject,eventdata)histoCAT('Master_LoadSamples',hObject,eventdata,guidata(hObject))

Error while evaluating Menu Callback

I was following your guide for segmentation and have tried playing around with the settings as well, but I cannot get around this error and histoCat refuses to work. Do you know how to fix this issue?

It would be splendid! Thank You for the help beforehand! Best, Max

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BodenmillerGroup/ImcSegmentationPipeline/issues/54, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4R2KHYSCKJHJS2YWK2K5LSUTQAHANCNFSM4UZTATTA .

maxgrigori commented 3 years ago

Hi Votti,

Thank You for your fast reply! I am processing my own sample tiff-files, which I have generated after ilastik-training using your pipeline. After the ilastik-training they were stored in tiffs-subfolder, which I have given as directory for the '2_segment_ilastik'-step. And the masks seem to fit as well...

I hope this explains it ok, I do not have a lot of background and experience, sorry.

Thanks for your help! Best, Max

Edit: I have also redone and checked this step a few times now. I hope I am not unlucky enough to have processed the "training" files each time :)

Edit2: Checked it again, just to be sure! I have been processing my own sample "post-ilastik" .h5-files and the tiff-masks generated fit the tiff-images and the mcd-files, so they are based on my samples :) It's just that they are being saved in this 250x250 format, which seems to clash with histoCat (and ImaCytE also) down the line...

votti commented 3 years ago

Hey, For training we do crop images to a 250x250 size. these images usually also have the crop-dimensions attached to them in the format _x[number]_y[number]_w[number]_h[number].

These crops are not the one you want to create your masks from but instead the 'complete' ilastik images.

Can you send me the filenames of the masks you received?

maxgrigori commented 3 years ago

Hi Votti, Of course. For example: h5-file: 20201026_SK_MG_UC_biopsies_6292-1_s0_a1_ac_ilastik_s2.h5 Probabilities-tiff-file: 20201026_SK_MG_UC_biopsies_6292-1_s0_a1_ac_ilastik_x727_y1135_w500_h500_Probabilities.tiff (500x500px) Resulting mask-fiff-file: 20201026_SK_MG_UC_biopsies_6292-1_s0_a1_ac_ilastik_x727_y1135_w500_h500_Probabilities_mask.tiff (250x250px)

tiff-files in corresponding histocat-folder: 669x885px in size

Thanks for the help! Best, Max

votti commented 3 years ago

So you ARE working with the training crops. This is evident from the naming: _x727_y1135_w500_h500_

Can you remove the _x[]_y[]_w[]_h[]_Probablities.tiff with the crop coordinates from your tiffs folder and apply the trained classifier to the _ac_ilastik.h5 files in your tiffs folder? Then you should then only load the files ending with _ilastik_Probabilities.tiff into the segmentation pipeline.

Do you know what I mean? Best

maxgrigori commented 3 years ago

Blast! Alright, I will try this now and report the result. Thank You Votti.

Best, Max

maxgrigori commented 3 years ago

This was the issue. It works now! I just hadn't noticed I was using the training crops. Thank You very much! Best, Max