NaN issue with filename in Table

Hello great community!

as part of a very long macro, I try to write the filename of the current analyzed image in a table.
I defined an array to write elements for the table away. works for all the columns except the file name.

the following code:

names[i]= filename;
print(names[i]);  //prints the correct filename

//next does returns NaN for some reason with some filenames...
Table.set("Filename", rowcount, names[i]); 

//this returns the correct filename
Table.set("Filename", rowcount, filename);

my workaround is ok but it clutters my Table in case there is no measurement for [i].
it does seem to work for some files and not others. only difference in the file name is the sequence number.

any better ways of doing this?

kind regards,

Jan

I use fiji 1.52p on MacOs Mojave

Could you give us an example of the filenames that give the problem?
How do you get the filename in the first place?

I usually use the getTitle(); function and that gave me never any issues.

Thanks for the reply Schmiedc!

I use the filename = getTitle();

one of the names giving isues is “Patryk BDA FN 2 re imaging_Region 021_A488.tiff”

one that works is “Patryk BDA FN 2 re imaging_Region 019_A488.tiff”

kind regards,

Jan

The filenames are almost identical. I guess there is a different problem in your macro.
I suspect it has something to do with the array names.

I would check if it really contains what you think in these instances by using Array.show(names);

Maybe you can post the entire macro. It misses a few bits that would reproduce the issue.

Array.show(names); gives me a list of the filename where a measurement was taken and 0 when the object is out of the ROI I am measuring.

in the Table it gives me now all 0 rather than NaN where the file name should be.

Also just noticed that the end bit of my macro stopped working. it gives me a correct list of names but only closes 1 window. This is a similar mechanism of itereating through the elements of an array…


list = getList("window.titles");
    Array.show(list);
     for (i=0; i<list.length; i++){
     winame = list[i];
      selectWindow(winame);
     run("Close");}

Seems like there is a weird thing going on with arrays on a mac. will run it on a PC when I am at work.
If it would help I can past the macro (have to discuss with researcher if he is happy for it to be in the open) but it is pretty much a work in progress and already over 100 lines of code…

1 Like