I need some help on spreadsheets in Matlab
Show older comments
I have written a script for analysing images of biological cells, which segments them and quantify the output.
Now I need to make Matlab write this information in a spreadhsheet.
This script utililizes the regionpropstool i Matlablab, and creates an array of information on each component like:
- Surface Are
- Perimeter
- MaximumAxisLength
- MinimumAxisLength
There is always an unknown amount of cells (Cn) that has an uknown amount of mitochondrion (Mn).
I need to make Matlabs add the following information to a spreadsheet:
C1 | C2 | C3 | C4 | ...Cn
M1 data
M2
M3 data
M4
..
Mn
The problems is that I dont know how to make Matlab add a new row or column, each time it processes a cell. So how does it assign a number to Cn and Mn
6 Comments
Kevin Chng
on 25 Oct 2018
Edited: Kevin Chng
on 25 Oct 2018
Write information to spreadshett
Typically, there are 3 ways
1) readtable(), you structure your information in table first, and then write it to excel or spreadsheet.
2) xlswrite(), write matrix to spreadsheet.
3) ActiveX, it is more flexible, it can change colour, or specific which coloumn or row number of spreadsheet to be written.
excel = actxsever('Excel.Application');
wb = excel.Workbooks.Open('somefile.xlsx');
ws = wb.Worksheets.Item('sheetname');
ws.Range('B2:B8').Insert;
.........
which one do you prefer?W ecan discuss further. You may further explain how is the flow of your logic? like what are you going to structur your data before writing them to spreadsheet.
Guillaume
on 25 Oct 2018
You can make regionprops return a table directly which is trivial to write into a spreadsheet. However, it sounds like what you want is a bit more complicated and I'm a bit unclear on what you have.
Is regionprop applied to cells or mitochondria? I assume it's mitochondria. If so where do the multiple cells come in? What actual data would go into your example sheet. Obviously if have cells as columns, mitochondria as rows you can only have one of {'Area', 'Perimeter', 'MajorAxisLength', 'MinorAxisLength'} inside the spreadsheet cells. Would the other ones go into different sheets?
Perhaps it would be a good idea for you to attach an example mat file that shows what form your results actually take.
August Hoel
on 25 Oct 2018
Guillaume
on 26 Oct 2018
Hey again, what I want is to quantify different parameters for every induvidual mitochondrion in the cell. My supervisor has told me to replicate his protocol in MatLab: https://doi.org/10.1002/cyto.a.20198
I have replicated all the image processing and enhancement steps, and turned the picture into Binary: (see picture)
Now I want to extract data, and I used the following code:
%%Label items for quantification
[mitLabel, mitNum] = bwlabel(Ibin);
%Set parameter
mitStats = regionprops(mitLabel, 'All');
%Extract arrays for area, perimeter, major axis length and minor axis length for each element in binary image
mitArea = [mitStats.Area];
mitPerimeter = [mitStats.Perimeter];
mitMaxL = [mitStats.MajorAxisLength];
mitMinL = [mitStats.MinorAxisLength];
I am processing a unknown amount of images that varies with each experiment, so I simply cant define which columns and rows I want MatLab to fill specifically.
So I need a a code that adds a new variable Cn+1 (Cell numer x +1) to the adjacent cell Cn(Cell nr n) for every picture of cell that is processed, I also need it to the same for every mitochondria thats in the cell:
C1 | C2 | C3 | C4 | ...Cn
M1 data
M2
M3 data
M4
..
Mn
I want one excel-sheet for each parameter, such as area, perimeter, major axis lenght, minor axis lenght etc.
I also need to convert pixels to micrometer unit, so if there is any good way to do this, that would be great. I also need to exclude elements smaller than what I specify.
I hope this explained it a little better. Thanks.
Guillaume
on 26 Oct 2018
Thank you, your explanation is much clearer. I do something similar for my work except that I look at images of droplets. I have an unspecified number of images each with a varying number of droplets.
What I don't particularly understand is your proposed storage. Wouldn't each cell (image?) has a varying number of mitochondria? In that case, it doesn't really make sense to have the storage you propose, which is in effect a 3D array (Cell x Mitochondria x paremeter). In my opinion, you would be better off using a 2D storage where each row is a mitochondria, and the cell it comes from as another parameter. Something like:
Mitochondria | Cell | Area | Perimeter | MajorAxis | MinorAxis
1 1 xxx yyyy zzzz ccccc
2 1 xxx yyyy zzzz ccccc
3 1 xxx yyyy zzzz ccccc
1 2 xxx yyyy zzzz ccccc
2 2 xxx yyyy zzzz ccccc
1 3 xxx yyyy zzzz ccccc
....
With regards to conversion from pixel to micrometer, this really warrant its own question. To do this you need to know the scale of your images. You know this either by taking an image of an object of known size under the same imaging conditions, or you know this becaue you know the magnification of your imaging system.
August Hoel
on 26 Oct 2018
Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!