Bio formats in Matlab - Bfopen - string for filename
13 views (last 30 days)
Show older comments
ian Handsportman
on 23 Oct 2020
Edited: Mario Malic
on 23 Oct 2020
I'm trying to read in Zeiss Zen .czi files from a directory with bfopen,
Directory="/home/ian/Zenfiles/airy-neuron/";
Dirlist=dir(fullfile(Directory,'*.czi'));
Filecounter=2 %a loop in full code
Filenamein=Dirlist(Filecounter).name
Newimagename=fullfile(Directory+Filenamein);
Newimage=bfopen(Newimagename);
This appears to produce a correctly formatted file name eg "/home/ian/Zenfiles/airy-neuron/Tile0.czi" but it produces an error -
Error using bfGetReader (line 43)
The value of 'id' is invalid. It must satisfy the function: ischar.
Error in bfopen (line 114)
r = bfGetReader(id, stitchFiles);
Manually typing the file, it appears bfopen needs it written as '/home/ian/Zenfiles/airy-neuron/Tile0.czi' but I can't get that to manifest in the code. I'm probably missing something obvious but I'm going slowly mad. Can anyone help? I have a Tb of images to get through..
0 Comments
Accepted Answer
Walter Roberson
on 23 Oct 2020
Directory = '/home/ian/Zenfiles/airy-neuron/';
Dirlist = dir(fullfile(Directory,'*.czi'));
Filecounter = 2 %a loop in full code
Filenamein = Dirlist(Filecounter).name
Newimagename = fullfile(Directory, Filenamein);
Newimage = bfopen(Newimagename);
OR use your existing code except
Newimage = bfopen(char(Newimagename));
bfopen() does not handle string objects. Your Directory is a string object and you used "+" to concatenate to it, producing a string object result. fullfile() would not be doing anything useful there, but fullfile() has the property that it returns a string object if any input is a string object, so your Newimagename is coming out as a string object.
4 Comments
Mario Malic
on 23 Oct 2020
Edited: Mario Malic
on 23 Oct 2020
You can change fonts or increase font size as well.
More Answers (1)
Mario Malic
on 23 Oct 2020
Edited: Mario Malic
on 23 Oct 2020
As seen on the error, you have to provide a file path as a character array.
Quotation marks denote strings, you can adjust your code
Newimagename=char(fullfile(Directory+Filenamein));
Fixed
Newimagename=char(fullfile(Directory,Filenamein));
0 Comments
See Also
Categories
Find more on Characters and Strings 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!