I am having problem un using load command.

I am having this problem is using load command. Anyone who can help me please?
% Extract 10 cell features for each image in 'imageInfo'
clear
tic
% nucleus area in real size
mpp_40 = 0.2525; % 40X
realMin = 80*mpp_40^2;
realMax = 1100*mpp_40^2;
realPSize = 2000*mpp_40;
% Load openslide library
openslide_load_library();
strc = load('C:/image-mRNA-prognostic-model-master/imageAndClinicalInfo/imageInfo.mat');
imInfo = strc.imageInfo;
dirData = 'C:/image-mRNA-prognostic-model-master/bin.png';
% process each image
nFile = size(imInfo, 1);
for i = 1:nFile
t1 = tic;
file = imInfo.file{i};
parts = regexp(file, '/', 'split');
filename = parts{2}(1:end-4);
% test if the image is already processed
if exist(['extractCellFeas_cellLevel/', filename, '.mat'], 'file');
fprintf('image %d/%d already processed\n', i, nFile);
continue;
end
slidePtr = openslide_open([dirData, file]);
mpp = imInfo.mppX(i);
width = imInfo.width(i);
height = imInfo.height(i);
ps = round(realPSize/mpp);
%% select patches using thumnail
% Get thumbnail
thumnail = openslide_read_associated_image(slidePtr, 'thumbnail');
thumnail = thumnail(:, :, 2:4);
[ht, wt, ~] = size(thumnail);
ratio = width/wt;
% patch size in thumbnail
pst = round(ps/ratio);
% select patches of interest in thumbnail image
[X, Y] = meshgrid(1:pst:wt-pst+1, 1:pst:ht-pst+1);
xy = [X(:), Y(:)];
d1 = size(xy, 1);
indOk = zeros(d1, 1);
for j = 1:d1
r = xy(j, 2);
c = xy(j, 1);
rows = r:r+pst-1;
cols = c:c+pst-1;
tile = thumnail(rows, cols, :);
tMean = mean(tile, 3);
if sum(tMean(:)>210) < pst*pst/2
indOk(j) = 1;
end
end
xy = xy(indOk==1, :)-1; % move upper-left point to (0, 0)
xy = round(xy*ratio);
% remvoe coordinates exceeding width or height
indOk = xy(:, 1)<=width-ps & xy(:, 2)<=height-ps;
xy = xy(indOk, :);
%% extract cell features for each tile
d1xy = size(xy, 1);
cellFeas = cell(d1xy, 1);
for ixy = 1:d1xy
x = xy(ixy, 1);
y = xy(ixy, 2);
tile = openslide_read_region(slidePtr, x, y, ps, ps, 0);
tile = tile(:, :, 2:4);
areaMin = round(realMin/mpp^2);
bw = hmt(tile, areaMin);
statsR = regionprops('table', bw, tile(:, :, 1), 'area', 'MeanIntensity',...
'MajorAxisLength', 'MinorAxisLength', 'centroid');
statsR.Area = statsR.Area*mpp^2;
statsR.MajorAxisLength = statsR.MajorAxisLength*mpp;
statsR.MinorAxisLength = statsR.MinorAxisLength*mpp;
indOk = statsR.Area <= realMax;
statsR = statsR(indOk, :);
if size(statsR, 1) < 80
continue;
end
statsG = regionprops('table', bw, tile(:, :, 2), 'MeanIntensity');
statsB = regionprops('table', bw, tile(:, :, 3), 'MeanIntensity');
statsG = statsG(indOk, :);
statsB = statsB(indOk, :);
feas1_7 = [statsR.Area, statsR.MajorAxisLength, statsR.MinorAxisLength,...
statsR.MajorAxisLength ./ statsR.MinorAxisLength,...
statsR.MeanIntensity, statsG.MeanIntensity, statsB.MeanIntensity];
% last 3 features derived from Delaunay graph
centroids = statsR.Centroid;
feas8_10 = zeros(size(statsR, 1), 3);
DT = delaunayTriangulation(double(centroids));
E = edges(DT);
for k = 1:size(centroids, 1)
edgesCell = E(sum(E==k, 2)~=0, :);
dist = zeros(size(edgesCell, 1), 1);
for m = 1:numel(dist)
p1 = centroids(edgesCell(m, 1), :);
p2 = centroids(edgesCell(m, 2), :);
dist(m) = norm(p1-p2);
end
feas8_10(k, :) = [mean(dist), max(dist), min(dist)];
end
cellFeas{ixy, 1} = [feas1_7, feas8_10*mpp];
end
cellFeas(cellfun(@isempty, cellFeas)) = []; % remove empty elements
save(['extractCellFeas_cellLevel', '/', filename, '.mat'], 'cellFeas');
fprintf('image %d/%d processed, time %f\n', i, nFile, toc(t1));
end
toc
% Close whole-slide image, note that the slidePtr must be removed manually
openslide_close(slidePtr)
clear slidePtr
% Unload library
openslide_unload_library

15 commentaires

Ashish Azad
Ashish Azad le 22 Juin 2020
Hi Muhammad,
Could you be please more specific where exactly you are getting error, and also paste the error here.
dirData = 'C:/image-mRNA-prognostic-model-master/bin.png';
That already includes a file extension. Is bin.png truly a directory name or is it a file name?
file = imInfo.file{i};
parts = regexp(file, '/', 'split');
filename = parts{2}(1:end-4);
You can be sure that filename will not have any / in it, but file probably does have / in it (otherwise you would not split it)
slidePtr = openslide_open([dirData, file]);
Is file certain to start with a / ? Because dirData does not end in a / . Is file intended to be within a directory named bin.png ? Use fullfile()
Image Analyst
Image Analyst le 22 Juin 2020
And, you forgot to attach ''C:/image-mRNA-prognostic-model-master/imageAndClinicalInfo/imageInfo.mat"
Actually, this is the whole simulation. I don't how should i ask this question. I need to run this simulation and test it for more files. This is a ready made simulation but i am stuck at some errors. Can anyone guide me how should i ask this question here and you guys can help me in sorting out this issue
Steven Lord
Steven Lord le 25 Juin 2020
What does "this problem" mean?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support using the telephone icon in the upper-right corner of this page so we can investigate.
Actually, i sent the crash report but they said you are using third part product so contact them. This is a whole simulation and i have to run many m-files in it. The basic purpose of this simulation is to extract the image feautures and corrleate witht the existing data.
The third part product is Open Slide Library i guess.
Move the
strc = load('C:/image-mRNA-prognostic-model-master/imageAndClinicalInfo/imageInfo.mat');
To before the
openslide_load_library();
If you still have a problem with the load() crashing MATLAB then you can construct an example that does not use openslide library at all, and Mathworks will pay attention to that.
Muhammad Adeel Ahsan Awan
Muhammad Adeel Ahsan Awan le 25 Juin 2020
Modifié(e) : Walter Roberson le 25 Juin 2020
Hey Walter i somewhat knows why my MATLAB is crashing. The file command is unable to read the info in file imageInfo.mat.
Because i ran little chunks of program, every things works good but there shows an error at line 23. I ran this command in command window and i got the error mentioned below.
imInfo.file{i}
Error:
Array indices must be positive integers or logical values.
I will have to modify the data in imageInfo file to be filed. but, i don't know how to.
Walter Roberson
Walter Roberson le 25 Juin 2020
If you run in chunks then you probably did not execute the for i so probably i has its default value of sqrt(-1)
Ohh i got it. But, the way you mentioned earlier, it is not working even that way.
Could you confirm that if you do nothing other than run
strc = load('C:/image-mRNA-prognostic-model-master/imageAndClinicalInfo/imageInfo.mat');
at the command line, that MATLAB crashes?
no it gets loaded sorry i was doing "i" mistake, the code crashes at this line now i checked and i am sure. Line 33
slidePtr = openslide_open([dirData, file]);

Connectez-vous pour commenter.

Réponses (1)

I did there was a mistake. I changed it. and the code is working fine uptill this part.
% Extract 10 cell features for each image in 'imageInfo'
clear
tic
% nucleus area in real size
mpp_40 = 0.2525; % 40X
realMin = 80*mpp_40^2;
realMax = 1100*mpp_40^2;
realPSize = 2000*mpp_40;
% Load openslide library
%openslide_load_library();
strc = load('imageAndClinicalInfo/imageInfo.mat');
imInfo = strc.imageInfo;
dirData = 'imageAndClinicalInfo/images/';
% process each image
nFile = size(imInfo, 1);
for i = 1:nFile
t1 = tic;
file = imInfo.file{i};
parts = regexp(file, '/', 'split');
filename = parts{2}(1:end-4);
% test if the image is already processed
if exist(['extractCellFeas_cellLevel/', filename, '.mat'], 'file');
fprintf('image %d/%d already processed\n', i, nFile);
continue;
end
Is there any way that i can attach simulation or provide you th link of Github ?

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by