Splitting multistack TIFF and merging colors

cellprofiler

#1

Hi all,

I was wondering whether this was possible to do with CP…I have a multilayered TIFF file (generated from Ilastik) which contains 3 colors (RGB) and 11 separate images. All the images are in the same plane and are of the same size, and what I would like to do is split them into separate RGB images (using ColortoGray) that however is the composite of all the separate stacks into one image.
So at the end I would like to end up with a single plane TIFF file for each color which is a combination of all the aformentioned planes. You can download an example stack picture from here:

I’ve succesfully used ColortoGray before but never for something like this. Any ideas?
Thanks!


#3

As a second note I’m using CP 2.2


#4

There is quite a simple solution to this in Fiji (Image J).

Drag your image into the Fiji, and you get a stack of images. Click ‘Image’----->‘Stacks’------>‘Stack to images’. Then you get 33 different images.

For cellprofiler, I think it cannot make it currently.


#5

Hi,
Thanks for the quick answer!
But whan I’m looking for is to end up with either 1 picture (RGB) which is a merge of all 33 images (but in a single plane/stack) or even better 3 pictures, one which is the merge for all split red channels of each file, one for the green channel and one for the blue channel.
With the Image-Stack plugin I get 33 different images.
Any ideas?
Thanks again!


#6

When you say combined, do you mean something like “tiled”? Because then you could use the CellProfiler “Tile” module to do something similar. If not, can you explain a bit more specifically what you mean by “combine”?


#7

Hi Roberto_Spada:

As far as I know, the only possible way is to use the MATLAB. Thus, I write a script for you. Before that, you need to split the image from Fiji. Currently there is something wrong with the ‘imwrite’ in the script (I am sorry I don’t want to fix it). But I think you can use ‘imshow(red)’ ‘imshow(green)’ ‘imshow(blue)’ ‘imshow(merged)’ to get the final images. I am 100% sure, this is the result you want.

Red channel: merged from image 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31
green channel: merged from image 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32
Blue channel: merged from image 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33

Roberto_Spada.zip (2.5 MB)

Please find the merged channel of red, green, blue and all merged images in the file attached (in the result file) .


#8

Hi!
Thanks for your feedback. When I mean combine I’m talking about actually merging all the images into one (but for each separate channel). What jedyzdc did is exactly what I am looking for. Is this something that CP can handle directly? I was thinking of a workflow that would work something like this: 1) Split original multilayered TIFF file into separate channels with CP 2) If necessary give the split channels a color with GraytoColor 2) merge (maybe with Tile function?) the separate channels into one file (with only 1 layer) 3) Proceed with ColortoGray.
Does that make sense and could something like that be done in CP?
Thank you so much for your help.
All the best
Roberto


#9

This seems indeed to be what I’m looking for!
Thanks for the help. Best thing would be if there were a way to do this in CP. Maybe the Tile function bcimini was mentioning could help?


#10

Part of the problem is that CP isn’t nicely reading your OME metadata; unfortunately this a known issue (that we’re working on solving!). You can see below that rather than 3 channels in 11 frames, you have 33 “timepoints”.

There are some workarounds discussed elsewhere in the forum; I’ve also attached a pipeline that clunkily in NamesAndTypes tries to get around it by explicitly calling out each “timepoint” and associating it with its correct channel.

Once you have the “parsing the channel” issue solved though, the rest of the solution is quite simple- use the MakeProjection module to sum (or max project, or whatever method of combination you like) each channel and use SaveImages to save on the last cycle.

SumProjectionPipeline.cppipe (8.0 KB)


#11

Thank you for this. I have never tried.

It should work well. But when I run your pipeline, there is something wrong. Maybe you can help me with it?Error


#12

Looks like the sum is therefore likely >1; this could be fixed by using a max projection rather than a sum projection (better idea) or by adding a RescaleIntensity module to bring the scale down to 1.


#13

Thanks so much for this. Sorry for being such a newbie on this, but when I try and load my multistack file and update the metadata all I get is the following:


is that what I would have to hack by uploading a separate csv file?
Thanks again for all your help on this


#14

Make sure you hit the top “Update metadata” before the bottom “update”; sometimes it helps to close and re-open if that doesn’t work.