Subtract a Weka class

May I know if it is possible to create a class in Weka and then subtract the class from my images. I have a stack of XCT scans and I am planning on carrying out porosity analysis using WEKA. However, there are fractures in the samples that show up as lines in the image, with the same grayscale intensity as the pores. My thought is to create a separate class for these fractures based on their shape and then delete this class from the image.
If this is not the best approach, I would appreciate other suggestions.

Could you post a sample image, @jubilee? It would help us to make more concrete suggestions about how best to analyze it.

Without knowing exactly how the images look, but based on what you describe: perhaps the Morphological Segmentation plugin would work.

What do you mean by “subtract the class” from your images? If you successfully segmented the fractures in a separate class, you can later use those regions as a mask to let them out of your analysis, for example.

As @ctrueden suggested, it would be great if you can post here an example image so we better understand your problem.

2 Likes

Hopefully, you can see this image. I would like to eliminate the streaks and fractures in the image in order to estimate the porosity more accurately.

1 Like

@jubilee Thanks!

As you noticed, TIFF files do not display properly in web browsers, although they can still be downloaded. I downloaded your TIFF before you changed it to a JPEG; it is best to avoid using JPEGs for scientific analysis. For displaying images on the forum in a lossless way (at least for 8-bit or 16-bit data), you can convert to PNG, which I have done here:

This image is actually very nice and clean. I am curious why you need TWS at all, when a simple threshold and Analyze Particles workflow appears to work nicely in my non-expert hands:

Here is the macro which performs the steps I did above:

setAutoThreshold("Default");
run("Analyze Particles...", "  circularity=0.00-1.00 exclude clear add");
roiManager("Show All without labels");
resetThreshold();
2 Likes

Thanks for your response. I have tried to use a simple threshold workflow and I agree with you that it could work nicely provided I know the cutoff point for my threshold. However, I do not want to just pick a threshold that looks good since I am running the analysis on stacks of images obtained pre and post reaction to obtain the porosity change. This is why I am thinking of using TWS since I can determine which of the pixels are pores pre reaction and then use the same information post reaction. Simple thresholding as you will see from your segmented image will only capture the macropores with certainty.

I am not a statistician or bioimage analyst by training, but in my experience, TWS will not give you any sort of statistical guarantee above and beyond what you get from autothresholding. As a human, what you are looking for to detect a pore is a contrast between the sample and the pores, no? Autothresholding is actually ideal for detecting these. And if you are concerned about intensity fluctuations in various parts of your image, you can use local thresholding. And if you want to filter by shape (which makes sense here), you can use Analyze Particles and/or Extended Particle Analyzer.

Maybe some bioimage analysts and/or algorithms experts here have more thoughts, opinions, comments about the best scientific approach in this case? @imagejan @tswayne @biovoxxel @iarganda @tinevez?

2 Likes

Hi @jubilee,

I’m trying to figure out what structures in your image are the pores. You mention the default threshold only gives you the macropores. Here’s a zoomed-up screenshot of part of the image, thresholded as @ctrueden illustrated, with the thresholded areas outlined in yellow. Could you point out some examples of pores that are being missed?

About the fractures, I agree with @iarganda that you could create a separate class for them, then mask them out for analysis.

Or, if you have just one class of objects that includes pores and fractures, you could run Analyze Particles and filter particles by circularity.

Hope this helps.

3 Likes

Hi @tswayne,
Find attached. I have zoomed in further into the image you sent. The points I have highlighted in red are potentially pores which are not showing up as solid black due to PVE (consider the larger pores). I can manually include these pixels in my thresholding but I am looking for a better way so that I can keep the process consistent for all my stacks.

1 Like

How did you choose those points? From a non-expert perspective they don’t look any different from other points around them that you didn’t select. Did you use any morphological or intensity value to take your decision?

4 Likes

That Is true. They do not look different from the other points because I only selected a few as an illustration. Also, I am going by my knowledge of the material and the BSE images with higher resolution.

Can you tell us how to differentiate them then? It is important so we can translate that knowledge into the program, in other words, to know which features are relevant.

3 Likes

I will classify the pixels with similar grayscale intensities as the streaks in the zoomed in section uploaded by @tswayne and below as pores.

I am sorry, but I’m not following. If you can classify them based only on grayscale intensities, you should be able to apply a simple threshold, which I don’t think is the case. I assume you differentiate them based on something else apart from intensity values, such as shape, location, proximity to other structures, size, etc. Isn’t it the case?

1 Like

If you have higher-resolution images, is it possible to use them for analysis?

This is the key. To make a good analysis pipeline, it is necessary to translate your expert knowledge into defined criteria, possibly using parameters like what @iarganda mentioned – shape, location, etc.

3 Likes

Just a passing comment: the type of feature you are trying to detect (pixel sized regions) is for sure below the effective limit of the image resolution. Such small features in those images cannot be reliably detected because you are working at the Nyquist limit, plus there is inherent noise in every image. The way forward would be to use higher magnification, so that the features sizes are relatively larger than the resolution. Note that the greyscale resolution of the image is not good either, it is quite blocky and so it would be even more difficult to be reliable about this.

4 Likes

Thanks for your responses. The scan was carried out at the limit of the resolution of the scanner hence I may not be able to get a scan with a better resolution for this sample. Also, since I am using pre and post reaction segmentation to infer the porosity change, a global threshold of the stack should suffice for the porosity analysis since the streaks are fibers which are non reactive and will be assigned to the same class following segmentation. Hence, I no longer need to classify the fibers as a discrete class. However, I am having an issue with carrying out a global threshold on my stack. I set a threshold limit based on the fist image in my stack and applied the same threshold to the other images. When I scrolled through the stacks after applying the threshold, fewer pixels were captured as pores in each slice as I moved along the stack (more pixels were captured as pores in the first image compared to the last). I tried to resolve this problem by initially generating a stack histograms before setting the threshold. However this did not solve the problem. Do you have any suggestion on how I can solve this problem?

You might want to apply histogram matching to all slices in your stack so the threshold works for most of them. Have a look at this other post.

3 Likes

Thanks, @iarganda. The output is much better.

1 Like