Thresholding help

Hi, 

I am a newbie to Knime, so building my first workflow with much help from the examples.  I have images with three channels - red, green and bright field.  I have used the brightfield to create a mask, applied this to the red and green images, and taken the average fluorsecence from each cell.  Now I want to create a second mask,  using the red channel (I have bright puncta here I want to exclude), combine the mask with the one created from the bright field, and then apply this mask to the green channel.  I tried to threshold the masked red image to create the second mask but of course I just get back the same mask as before.  Is there a way to exclude the 'masked' pixels, eg convert them to NaN, then the threshold node will just look at the pixels within the cell? I also tried to just mask the red image, global threshold works for some images but not for others, I need it to be robust, is there a way to make it more stringent? Or is there another obvious approach to this problem?

I attach my knime workflow, but without data as it is too big without.

Another quick question, is there a good place to read up onthe different pixels types within knime, some I know but most I don't.

Thanks 

Hello aclany11,

first of all: Regarding your workflow you are really not a newbie anymore ;)

About your questions:
* Attached an example workflow (some minor changes) how to extract the very bright spots from the red channel and recombine the resulting mask with the brightfield mask (excluded the spots). I also used some other nodes (e.g. projector, resampler and image segment features directly for calculation of both the mean and number of pixels).

 

* Global Thresholder should work. Another idea would be the "Spot Detection" Node from our repository (not the trackmate one). If you don't have success with this node, maybe you could provide some of your hard examples (diverse examples) and we will have a look how to segment your spots more robust.
 

* About Pixel types: We are really sorry that we don't have a good documentation for pixeltypes, factories, labelings, images etc yet. We are really working on that. In general you will find some information about pixel types right here: http://de.wikibooks.org/wiki/Java_Standard:_Primitive_Datentypen . The keyword "unsigned" just marks a datatype for not beeing negative. Example: ByteType ranges from -128 to +127. UnsignedByteType is the variant from 0 to 255 (just added 128). Again: We are working on a real documentation for all that stuff.

 

* One remark: Don't use column appender as this may go wrong if the ordering of the cells is not the same. I prefer to use the "Joiner" node (see example flow).

 

I hope this helps, if not don't hesitate to ask. We are happy to receive and give any kind of feedback ;)

 

Christian

Thankyou for the quick reply, and the workflow looks much simpler than mine. 

Couple of comments, why the gaussian filter for the bright field but not the RFP? But this lead me to try a median filter before thresholding the images (because I understand how that works better) and this really helps lose the salt n pepper background.  And I will try the spot detector.

Are the dimension extender and resampler required together to get the 3D mask?

I was wary of the join tables as I don't fully understand 'inner' and 'outer' join, and the filling up of colums with missing values, so I used a sorter node before join, because I realised the segment features nodes labelled the RFP and GFP images differently even though they used the same mask.  Is there an obvious reason for this?

Thanks for your help, back to the fine tuning.......

 

Hi,

 

Couple of comments, why the gaussian filter for the bright field but not the RFP? But this lead me to try a median filter before thresholding the images (because I understand how that works better) and this really helps lose the salt n pepper background.

 

In the bright field I tried to get rid of the holes in the mask. In the RFP it also worked well without it. Median filter also seems to be a good choice. You could also try the Quantile Filter which is a fast approximation of the Median Filter (which is slow by definition ;)). One remark. it's important that you do your intensity measurement on the orginal data again and not on the filtered one.

 

And I will try the spot detector.

 

I think the Node Description might help here. If this node doesn't work I will upload another workflow how to detect your spots (Laplacian of Gaussian). Just came to my mind yesterday.

 

Are the dimension extender and resampler required together to get the 3D mask?

 

Exactly. The dimension extender add the "Z" coordinate again to the projected X,Y Image, s.t. you have X,Y,Z. The resampler simply extends the mask then to three Z planes. The connected component analysis is then performed on each XY plane individually (see dimension selection of CCA) and so you have three indivudal segments in each plane on which the measurement is done.

 

I was wary of the join tables as I don't fully understand 'inner' and 'outer' join, and the filling up of colums with missing values, so I used a sorter node before join.

 

First, you don't need a sorter node before the join. The joiner internally sort hisself. You can leave the settings as they are (inner/outer), just make sure that there is a one two one correspondence between the two tables you are joining (e.g. RowId and RowId, as in my example).

 

because I realised the segment features nodes labelled the RFP and GFP images differently even though they used the same mask.  Is there an obvious reason for this?

 

What exactly do you mean? Different RowIds or Different Labels? Are the labelings (after CCA) the same?

 

Cheers,

Christian

 

Hi Christian, 

What exactly do you mean? Different RowIds or Different Labels? Are the labelings (after CCA) the same?

Different labels, so 5 cells in an image, labelled 1-5 but in a different order.  But actually I can't recreate the issue now.  I had a large table, each new column appended to see how it developed, but now I wanted to test with more data I stopped that and just passed the columns neccessary for the next node, maybe the successive passing of data created the issue. 

Thanks for the explantions, I think I have it working now. 

Do you have much experience with the cell clump splitter, I know this is something almost impossible to automate well, but either it has very little effect(with a high max value of local maxima), so splits nothing or it gets stuck and doesn't process to the end( with a high value).  My heap space is not full, although it seems to do better if I try it shortly after opening Knime rather than after using the program for  while.  For the moment I took the node out of hte work flow, but for the future it would be nice to use it.

Thanks again.

Hi again,

 

Do you have much experience with the cell clump splitter, I know this is something almost impossible to automate well, but either it has very little effect(with a high max value of local maxima), so splits nothing or it gets stuck and doesn't process to the end( with a high value).

 

Cell clump splitting is really hard to automate. So our cell clump splitter node heavily relies on the assumption that your cells are somehow ellipsoidish (as a lot of the other automated algorithms are). Maybe the ImageJ1 Macro Watershed (in the node called: IJ Macro from the KNIME ImageJ2 Extension) on the binary image as input helps better?

 

My heap space is not full, although it seems to do better if I try it shortly after opening Knime rather than after using the program for  while.  For the moment I took the node out of hte work flow, but for the future it would be nice to use it.

 

Hm this shoudln't be a problem at all. Could you provide us some more information about your system (heap space size, operating system, knime version, knime image processing version etc) then I will try to reproduce it here and see what I can do.

 

Cheers,

 

Christian

 

Hi, 

Sorry for the delay in replying, other projects have taken prioity for a while.  Now I have chance to get back to working with knime. 

Hm this shoudln't be a problem at all. Could you provide us some more information about your system (heap space size, operating system, knime version, knime image processing version etc) then I will try to reproduce it here and see what I can do.

Heap Space - Xmx2048m, MaxPermSize=512m

OS X 10.8.5

Knime version - 2.8.0

Knime image processing version - 1.0.5.201307250802

I also have another question, I have some images processed to a point, and cropped using segment cropper (so individual cells isolated from the image), now I want to obtain a list of the pixel values from this cropped image.  Either as a csv format I can import into excel and work with or as a format the histogram node can read.  I want to create a histogram of the pixel intensities, I realise I can do this with the image segment feature node, but then I lose the individual value of each pixel, I only have the number of pixels in each bin.  So can I output a list of pixel values from the segment cropper or is there a better way?

Many Thanks

 

 

Hi,

nice that you find some time again working on KNIME. We are looking forward to help you if you have any questions :-)

Heap Space - Xmx2048m, MaxPermSize=512m

OS X 10.8.5

Knime version - 2.8.0

Knime image processing version - 1.0.5.201307250802

Could you try to update KNIME to KNIME 2.8.2? (Help -> Check for Updates) and check whether the problem still occurs?

I also have another question, I have some images processed to a point, and cropped using segment cropper (so individual cells isolated from the image), now I want to obtain a list of the pixel values from this cropped image.  Either as a csv format I can import into excel and work with or as a format the histogram node can read.  I want to create a histogram of the pixel intensities, I realise I can do this with the image segment feature node, but then I lose the individual value of each pixel, I only have the number of pixels in each bin.  So can I output a list of pixel values from the segment cropper or is there a better way?

I attached an example workflow how to create several histograms from a list of images. First, you need to install the JFreeChart Extension from the KNIME Update-Site (Help -> Install New Software -> KNIME Updates & Extensions -> JFreeChart). You can configure the Histogram Node (JFreeChart) via Flow Variables. If you need help with that, let me know what you want to do and I can explain it.

Does this workflow help?


Cheers,
Christian

 

Hi Christian, 

I've updated and I'll test it and let you know about the memory issue.

As for the histogram work flow, it didn't really help.  Maybe I didn't explain well enough.  I have 20 segments for each sample, I want to take the pixel intensities of all the segments, group them into bins eg 0-0.1, 0.1-0.2........ then sum the values in each bin, so not a count of how many values in each but the sum of the values.  I also want the bins to be the same for each sample although the range of values will be different.  Do you think this is doable with the histogram node?  I don't see how to configure it with flow variables in a way that is better or easier than with the dialogue.

So far I have done as in your workflow - Img to data row - Split collection column - Transpose - then I am using a loop to write each column to a csv, using append so I get a single column - CSV reader(here I can't pass the filename variable to the reader without causing loop problems so it is manually done) - Numeric binner(perfect except it forgets the bin setting when reset or copied) - Groupby - Line plot.   I will in the end join everything after the Groupby node to plot the final line plot.  

I have just realised maybe I should join the different samples together before the Numeric binner, so I will go try that.  If you know a way to configure the numeric Binner other than manually setting each value, that may save me from insanity.  I need bins from 0-11 in 0.1 intervals.

Thankyou lots for your help.

 

Hi,

I think now I understood (hopefully). Well, I would try to give the values "GroupNames" such that you can make use of the GroupBy node (sum over groups). I added a simple example workflow, in which I add 0.0 if the value is between 0.0 - 0.1, 0.1 if the value if between 0.1 - 0.2 etc... and then I took the sum over the individual groups. In the end I took the sum over the sums (such that we have an aggregated result for all images).

If you need a more special rule to assign these "groups" you could use a JavaSnippet for that. I can help you with this, if you provide me more details and the attached workflow doesn't help.

Cheers,

Christian

Hi Christian, 

Thanks.  Using the Round Double node to create the group names is brilliant!!  This essentially does the same as the binning node but is MUCH less tedious to set up.  You have saved me hours thankyou.  

About my heap space issue, it has been much better since updating to the new version yesterday, but it still maxed out on me today.  Even after running the garbage collector the heap space remained full.  

Many Thanks

Hi, 

This analysis is finished, at least until tomorrow when my boss sees it.  Thankyou for your help.  The trick with rounding numbers is a good workaround, but can I somehow request an addition to the numerical binner to allow the same bins to be applied to several columns.  Or to allow the automatic generation of bins based on a given range and interval (not drawing these from the data).  I realised at the end that maybe wider bins would have been better but the use of rounding doesn't allow for eg 0.2 wide bins.

Lot of thanks for your help.

 

Hi,

i attached another, a little bit modified workflow. It contains now a JavaSnippet which does the job for arbitrary step-sizes (see variable factor in java snippet).

Ich hope this helps ;-)

Cheers,

Christian

Hi Christian, 

Yes, this works exactly as I would want.  I think I need togo learn some Java.  I have done a bit of Java scripting, enough to realise this is different, but never Java.  If you could reccomend somewhere to learn the basics that would be great, or I'll go look for something to get me started.

Thanks again for your help