Slicing in paraview - paraview

The Slice option in Paraview with selection plane, has a origin and normal to define the plane.
I am trying to export the slice data in csv format. However, the simulation domain is very large and therefore the slice also is quite large (which needs to be processed in matlab further). I need only the specific region of the slice. Is it possible to reduce the slice by creating a plane based on points by user or any other alternatives?

If you're only interested in a part of the slice, you can use the Clip filter on the volume to extract the region of interest and then slice this region.
select your volume
use the Clip filter
in the properties panel, set the Clip Type parameter as "Box"
set the dimensions of the box
in the GUI: move the circles of the Clip widget
in the Python Shell: your_volume.ClipType.Bounds = [xmin, xmax, ymin, ymax, zmin, zmax], where your_volume in the volume proxy
check the Inside Out option, to keep only what is in the clip box
create your slice from the clip proxy

Related

How To Create an ROI Mask of a Freesurfer Surface

I have been working on a project extracting different cortical depths from freesurfer constructions (ie 0%, 25%,50%,75%,100%), and then projecting the intensity values onto the surfaces. My end goal is to get the intensity values within an ROI of each depth layer.
So far I have been able to create equivolumetric surfaces at each depth using surface_tools, then I projected the intensity values from the original volumetric file onto the surface vertices using the mri_vol2surf command. The end result of this is an Nx1 .mgh file that has the intensity values of each vertex within the selected depth layer. I can open up this file in matlab using the load_mgh script, but I don't think I can open it with anything else.
My question is how to create an ROI mask within this layer because I don't need the whole pial surface, just part of the layer at each depth. I have tried to draw a label mask in Freesurfer with the original volume and the pial files at each depth (to use as guide lines) loaded. Then I tried to convert the label file for the ROI I drew to a volumetric file using mri_label2vol (this way I can use mri_mask).
The problem is that when I apply mri_mask to the original .mgh file generated by vol2surf it creates a matrix that is still 2D, and all the values are 1 (rather than their normal intensities, just isolated to an ROI rather than the whole layer). I'm wondering if I should convert the .mgh file from vol2surf back into voxel space before trying to mask it with the label file.
I was thinking about using surf2vol with each surface layer, the original volume, and the -mkmask flag. Supposedly this is meant to create a volume that is comprised of all the voxels that intersect a surface file. If I had something like this I could then create ROIs for each layer volume and mask the way I would normally mask an MRI volume.
Also a suggestion about a better way to do this in general would be greatly appreciated. I think I'm overcomplicating it.
I have attached pictures of the layer files when loaded into freesurfer, and the .mgh files generated by vol2surf after mapping the intensity values to the surface vertices.

Crop an image using multiple coordinates in Matlab

I used the "imfreehand" to crop an irregular shape and save its positions into a variable. This position variable is a 85*2 double matrix (85 points, X and Y coordinates). Now, I want to use the same position to crop another image (different layer of the image, but the location of the objects is the same). The functions I can find all requires rectangle positions (X1,X2,Y1,Y2). In my situation, I have 82 different (X,Y) coordinates, how can I use the position information to crop a new image?
From what I understand, you want to take the coordinates created by imfreehand(...) to create a cropable object on another image. You can use the function impoly(hparent,position) for this purpose.
The MathWorks page provides an example to guide you on its usage.

How to fill colors in contour circles in paraview?

I have a triangulation surface, and there is a point data named rhoA on it. I plot rhoA in paraview and plot the contour with just one contour value. So you can see many circles on the surface.
But what I need is to fill red colors in the circles and don't show other parts. So how to do it in paraview?
Use the Clip filter and set the Clip Type to Scalar. Set the Scalars property to rhoA and set Value to your threshold value. This filter will cut cells, giving you a more precise surface than the Threshold filter will.
Here is an example of the results you can expect doing this:
You can either :
Use the banded countour filter from VTK, that you will need to expose with a XML only plugin first (hard but precise and efficient)
Use treshold filter (the cut will not be on the contour, whole cells will be extracted)

how to identify an object appears homogenously white

I have a segmented image. i need to verify the intensity variation of the ellipse like structure present in the image. I need to check whether that ellipse is homogeneously white
original image
ellipse like structure is inside the rectangle
my segmented image is
i want to compare the original image (which is homogeneous white) with the segmented region.
regionprops is perfect for this sort of task. You can pass it your segmented binary image, and your original image to retrieve a list of the pixels in each region (presuming each region is not connected, as shown in your sample image). These will be in the form of a n x 1 vector for each region, returned as a struct array.
stats = regionprops(BW, I, 'PixelValues');
(You may want to retrieve other values returned by regionprops, like BoundingBox or Centroid, to help identify which set of pixels belongs to which region more easily. Consult the documentation to see what options are available.).
You can then define some statistical function to show the variation within each region, for example, to calculate the variance and standard deviation for each:
for n = 1:length(stats)
stats(n).var = var(stats(n).PixelValues);
stats(n).std = std(stats(n).PixelValues);
end
If you have some other specific definition of "intensity variation" in mind, then you need to develop some function that calculates it, then just call that instead of a built in like var or std.

Texture analysis on irregular region of interest

I have an image which I would like to extract the GLCM texture in an area of interest(AOI). But AOI is a non-rectangular shape.
As an image is always stored as a matrix in Matlab, even if the AOI is an irregular polygonal area the neighboring pixels will also have to be used to make it a rectangular region. Since all the pixels outside the area of interest are made equal to zero, does this affect the features extracted from texture analysis.
Is it possible to do any kind of image analysis on non-rectangular regions?
Yes, if the pixels outside the area of interest were being used when computing the gray level cooccurrence matrix, then the result would be incorrect -- that is, would not suit your requirements, as border processing is a matter of choice.
Existing software systems offer this feature:
If you use matlab, according to http://www.mathworks.com/help/toolbox/images/ref/graycomatrix.html, you would need to assign to the pixels of the input image which are outside the AOI the value Nan.
In Mathematica, very conveniently the function ImageCooccurrence has an option named Masking which allows to pass any AOI as a binary mask. From http://reference.wolfram.com/mathematica/ref/ImageCooccurrence.html: