Bio formats in Matlab - Bfopen - string for filename

14 visualizaciones (últimos 30 días)
ian Handsportman
ian Handsportman el 23 de Oct. de 2020
Editada: Mario Malic el 23 de Oct. de 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..

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Oct. de 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 comentarios
ian Handsportman
ian Handsportman el 23 de Oct. de 2020
I'll get myself some new glasses...
Mario Malic
Mario Malic el 23 de Oct. de 2020
Editada: Mario Malic el 23 de Oct. de 2020
You can change fonts or increase font size as well.

Iniciar sesión para comentar.

Más respuestas (1)

Mario Malic
Mario Malic el 23 de Oct. de 2020
Editada: Mario Malic el 23 de Oct. de 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));

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by