Read in part of large histological (ndpi) file

14 visualizzazioni (ultimi 30 giorni)
SysSys
SysSys il 18 Ago 2024
Modificato: Ashish Uthama il 20 Ago 2024
I want to read in a very large histological image file (file size: 2.05 GB, *.ndpi file, pixel size: 57856 x 1.111e+05) and don't have enough RAM.
I tried blockedImage and thought it would fit great but still, I am unable to get my data in highest resolution.
I tried:
% p,f are path and filename for the 2.05 GB *.ndpi file
A = blockedImage(strcat(p,f));
levelSizeInfo = table((1:length(A.Size))', ...
A.Size(:,1), ...
A.Size(:,2), ...
A.Size(:,1)./A.Size(:,2), ...
'VariableNames',["Resolution Level" "Image Width" "Image Height" "Aspect Ratio"])
and obtained
levelSizeInfo =
9×4 table
Resolution Level Image Width Image Height Aspect Ratio
________________ ___________ ____________ ____________
1 57856 1.111e+05 0.52074
2 28928 55552 0.52074
3 14464 27776 0.52074
4 7232 13888 0.52074
5 3616 6944 0.52074
6 1808 3472 0.52074
7 904 1736 0.52074
8 407 1188 0.34259
9 203 594 0.34175
So I want to assess the resolution level 1 information and therefore tried to split it up in smaller patches:
bls = selectBlockLocations(A,"Levels",1,"BlockSize",[4096, 4096]);
bimds = blockedImageDatastore(A, "BlockLocationSet", bls);
However, I cannot assess these 4096 x 4096 blocks.
I tried to work with:
>> while hasdata(bimds)
[data, info] = read(bimds);
disp(info);
end
Error using images.blocked.TIFF/getIOBlock (line 139)
Out of memory.
But get the above error message. Is there any possibility that I read in my large image and split it up until my memory is sufficient and then assess the data? I don't want to use lower resolution, since I am really interested in some specific histological information only reliable visible as highest resolution.
I would be also happy, when I would provide voxel coordinate start and end position and split it up manually such that it fits my RAM. I can do it in python but I would like to work with this dataset in Matlab as well.
Similar to this (which was not working either):
>> img = bigimage(strcat(p,f));
%Starting coordinates
coordStart = [250 250];
%Ending Coordinates
coordEnd = [750,750];
%Extract the region between the aforementioned coordinates
blk1 = getRegion(img,1,coordStart, coordEnd);
%Display the image
bigimageshow(bigimage(blk1))
Error using imread (line 440)
Unable to read TIFF file "SSES-1_MAX.ndpi". File is corrupt or image does not contain any readable strips.
Thanks in advance!

Risposte (1)

Ashish Uthama
Ashish Uthama il 20 Ago 2024
Modificato: Ashish Uthama il 20 Ago 2024
NDPI look like TIFF file, but unfortunately, they dont stick to the spec. It internally stores the full res image likely compressed that make it hard for TIFF tools to extract just a part of it.
Do you have any tools to convert it to a TIFF file?
Another option is to try this custom adapter which uses OpenSlide to interepret this non-standard TIFF file:
Then blockedImage ought to work as expected.

Community Treasure Hunt

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

Start Hunting!

Translated by