Bio formats in Matlab - Bfopen - string for filename

14 vues (au cours des 30 derniers jours)
ian Handsportman
ian Handsportman le 23 Oct 2020
Modifié(e) : Mario Malic le 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..

Réponse acceptée

Walter Roberson
Walter Roberson le 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 commentaires
ian Handsportman
ian Handsportman le 23 Oct 2020
I'll get myself some new glasses...
Mario Malic
Mario Malic le 23 Oct 2020
Modifié(e) : Mario Malic le 23 Oct 2020
You can change fonts or increase font size as well.

Connectez-vous pour commenter.

Plus de réponses (1)

Mario Malic
Mario Malic le 23 Oct 2020
Modifié(e) : Mario Malic le 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));

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by